Allow to remove user location setting
Closes #671 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
30c81ee3a8
commit
1fff71ee0e
|
@ -150,7 +150,7 @@ export default class AddressAutoComplete extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
get queryText(): string {
|
get queryText(): string {
|
||||||
if (this.value) {
|
if (this.value !== undefined) {
|
||||||
return new Address(this.value).fullName;
|
return new Address(this.value).fullName;
|
||||||
}
|
}
|
||||||
return this.initialQueryText;
|
return this.initialQueryText;
|
||||||
|
|
|
@ -46,6 +46,12 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</b-autocomplete>
|
</b-autocomplete>
|
||||||
|
<b-button
|
||||||
|
:disabled="!queryText"
|
||||||
|
@click="resetAddress"
|
||||||
|
class="reset-area"
|
||||||
|
icon-left="close"
|
||||||
|
/>
|
||||||
</b-field>
|
</b-field>
|
||||||
<div class="map" v-if="selected && selected.geom && selected.poiInfos">
|
<div class="map" v-if="selected && selected.geom && selected.poiInfos">
|
||||||
<map-leaflet
|
<map-leaflet
|
||||||
|
@ -295,6 +301,12 @@ export default class FullAddressAutoComplete extends Vue {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetAddress(): void {
|
||||||
|
this.$emit("input", null);
|
||||||
|
this.queryText = "";
|
||||||
|
this.selected = new Address();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -13,9 +13,9 @@ export interface ICurrentUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserPreferredLocation {
|
export interface IUserPreferredLocation {
|
||||||
range?: number;
|
range?: number | null;
|
||||||
name?: string;
|
name?: string | null;
|
||||||
geohash?: string;
|
geohash?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserSettings {
|
export interface IUserSettings {
|
||||||
|
|
|
@ -80,6 +80,12 @@
|
||||||
</option>
|
</option>
|
||||||
</b-select>
|
</b-select>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
<b-button
|
||||||
|
:disabled="address == undefined"
|
||||||
|
@click="resetArea"
|
||||||
|
class="reset-area"
|
||||||
|
icon-left="close"
|
||||||
|
/>
|
||||||
</b-field>
|
</b-field>
|
||||||
<p>
|
<p>
|
||||||
{{
|
{{
|
||||||
|
@ -239,11 +245,11 @@ export default class Preferences extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get locationRange(): number | undefined {
|
get locationRange(): number | undefined | null {
|
||||||
return this.loggedUser?.settings?.location?.range;
|
return this.loggedUser?.settings?.location?.range;
|
||||||
}
|
}
|
||||||
|
|
||||||
set locationRange(locationRange: number | undefined) {
|
set locationRange(locationRange: number | undefined | null) {
|
||||||
if (locationRange) {
|
if (locationRange) {
|
||||||
this.updateUserSettings({
|
this.updateUserSettings({
|
||||||
location: {
|
location: {
|
||||||
|
@ -253,6 +259,16 @@ export default class Preferences extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetArea(): void {
|
||||||
|
this.updateUserSettings({
|
||||||
|
location: {
|
||||||
|
geohash: null,
|
||||||
|
name: null,
|
||||||
|
range: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private async updateUserSettings(userSettings: IUserSettings) {
|
private async updateUserSettings(userSettings: IUserSettings) {
|
||||||
await this.$apollo.mutate<{ setUserSetting: string }>({
|
await this.$apollo.mutate<{ setUserSetting: string }>({
|
||||||
mutation: SET_USER_SETTINGS,
|
mutation: SET_USER_SETTINGS,
|
||||||
|
@ -262,3 +278,10 @@ export default class Preferences extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.reset-area {
|
||||||
|
align-self: center;
|
||||||
|
position: relative;
|
||||||
|
top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue