correction about issue #1556 : Fix location on homepage and location clearing
This commit is contained in:
parent
3ed4105879
commit
9403a9d60a
|
@ -374,7 +374,7 @@ const asyncData = async (query: string): Promise<void> => {
|
|||
};
|
||||
|
||||
const selectedAddressText = computed(() => {
|
||||
if (!selected) return undefined;
|
||||
if (!selected || !selected.id) return undefined;
|
||||
return addressFullName(selected);
|
||||
});
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
:default-text="locationDefaultText"
|
||||
labelClass="sr-only"
|
||||
:placeholder="t('e.g. Nantes, Berlin, Cork, …')"
|
||||
v-on:update:modelValue="modelValueUpdate"
|
||||
/>
|
||||
<o-button native-type="submit" icon-left="magnify">
|
||||
<template v-if="search">{{ t("Go!") }}</template>
|
||||
|
@ -95,6 +96,10 @@ const search = computed({
|
|||
},
|
||||
});
|
||||
|
||||
const modelValueUpdate = (newlocation: IAddress | null) => {
|
||||
emit("update:location", newlocation);
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
emit("submit");
|
||||
const { lat, lon } = addressToLocation(location.value);
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
<search-fields
|
||||
v-model:search="search"
|
||||
v-model:location="location"
|
||||
:locationDefaultText="location?.description"
|
||||
:locationDefaultText="location?.description ?? userLocation?.name"
|
||||
v-on:update:location="updateLocation"
|
||||
:fromLocalStorage="true"
|
||||
/>
|
||||
<!-- Categories preview -->
|
||||
|
@ -237,6 +238,7 @@ const currentUserParticipations = computed(
|
|||
|
||||
const location = ref(null);
|
||||
const search = ref("");
|
||||
const noLocation = ref(false);
|
||||
|
||||
watch(location, (newLoc, oldLoc) =>
|
||||
console.debug("LOCATION UPDATED from", { ...oldLoc }, " to ", { ...newLoc })
|
||||
|
@ -428,6 +430,13 @@ const currentUserLocation = computed(() => {
|
|||
|
||||
const userLocation = computed(() => {
|
||||
console.debug("new userLocation");
|
||||
if (noLocation.value) {
|
||||
return {
|
||||
lon: null,
|
||||
lat: null,
|
||||
name: null,
|
||||
};
|
||||
}
|
||||
if (location.value) {
|
||||
console.debug("userLocation is typed location");
|
||||
return addressToLocation(location.value);
|
||||
|
@ -502,6 +511,10 @@ const performGeoLocation = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const updateLocation = (newlocation: IAddress | null) => {
|
||||
noLocation.value = newlocation == null;
|
||||
};
|
||||
|
||||
/**
|
||||
* View Head
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue