From b15071f56f41d72d81e1db16f8128058eab0e27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Thu, 25 Jul 2024 16:45:05 +0200 Subject: [PATCH 01/81] fix: wrong close button on PoiCard in Notebook #340 --- components/Home/Home.vue | 2 ++ components/PoisCard/PoiCard.vue | 6 +++++- components/PoisCard/PoisDeck.vue | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/Home/Home.vue b/components/Home/Home.vue index 5f418507..6c6c3b06 100644 --- a/components/Home/Home.vue +++ b/components/Home/Home.vue @@ -639,6 +639,7 @@ function handlePoiCardClose() { && selectedFeature.properties.metadata && showPoi " + :can-close="device.smallScreen" :poi="selectedFeature" class="tw-grow-0" :explorer-mode-enabled="explorerModeEnabled" @@ -668,6 +669,7 @@ function handlePoiCardClose() { && selectedFeature.properties.metadata && showPoi " + :can-close="device.smallScreen" :poi="selectedFeature" class="tw-grow-0 tw-text-left tw-h-full" :explorer-mode-enabled="explorerModeEnabled" diff --git a/components/PoisCard/PoiCard.vue b/components/PoisCard/PoiCard.vue index fe51911b..f3bccad9 100644 --- a/components/PoisCard/PoiCard.vue +++ b/components/PoisCard/PoiCard.vue @@ -18,6 +18,10 @@ export default defineNuxtComponent({ }, props: { + canClose: { + type: Boolean, + default: true, + }, poi: { type: Object as PropType, required: true, @@ -66,7 +70,7 @@ export default defineNuxtComponent({ class="poiDescription tw-z-10 tw-flex tw-flex-col tw-w-full md:tw-max-w-xl tw-mx-0 tw-overflow-y-auto tw-shadow-md tw-pointer-events-auto md:tw-flex-row md:tw-w-auto md:tw-mx-auto md:tw-rounded-xl tw-bg-white" > Date: Thu, 18 Jul 2024 15:38:40 +0200 Subject: [PATCH 02/81] chore: use setSelectedFeature store action #226 --- components/MainMap/FavoriteMenu.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/MainMap/FavoriteMenu.vue b/components/MainMap/FavoriteMenu.vue index c2170789..d39ee4c8 100644 --- a/components/MainMap/FavoriteMenu.vue +++ b/components/MainMap/FavoriteMenu.vue @@ -21,7 +21,8 @@ const emit = defineEmits(['toggleFavoriteMode', 'toggleNoteBookMode']) const device = useDevice() const notebookModal = ref(false) -const { isModeFavorites, selectedFeature } = storeToRefs(useMapStore()) +const mapStore = useMapStore() +const { isModeFavorites } = storeToRefs(mapStore) const { favoriteCount } = storeToRefs(useFavoriteStore()) function explore(poi: ApiPoi) { @@ -35,7 +36,7 @@ function onClose() { } function onZoomClick(poi: ApiPoi) { - selectedFeature.value = poi + mapStore.setSelectedFeature(poi) notebookModal.value = false props.goToSelectedPoi(poi) } From adc27d7675f432fec113df28690eba3464e2aa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Thu, 18 Jul 2024 16:45:00 +0200 Subject: [PATCH 03/81] refactor: move initialPoi logic on page level #338 --- components/Home/Embedded.vue | 4 +--- components/Home/Home.vue | 4 ---- pages/embedded.vue | 6 +++--- pages/index.vue | 7 ++++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/components/Home/Embedded.vue b/components/Home/Embedded.vue index b2a61690..d6f52cd0 100644 --- a/components/Home/Embedded.vue +++ b/components/Home/Embedded.vue @@ -22,7 +22,6 @@ import { flattenFeatures } from '~/utils/utilities' const props = defineProps<{ boundaryArea?: Polygon | MultiPolygon initialCategoryIds?: number[] - initialPoi?: ApiPoi }>() // @@ -60,8 +59,7 @@ onMounted(() => { } menuStore.setSelectedCategoryIds(enabledCategories) } - if (props.initialPoi) - mapStore.setSelectedFeature(props.initialPoi) + if (props.boundaryArea) { initialBbox.value = getBBoxFeature(props.boundaryArea) } diff --git a/components/Home/Home.vue b/components/Home/Home.vue index 6c6c3b06..badf89db 100644 --- a/components/Home/Home.vue +++ b/components/Home/Home.vue @@ -36,7 +36,6 @@ import type { ApiAddrSearchResult, ApiSearchResult } from '~/lib/apiSearch' const props = defineProps<{ boundaryArea?: Polygon | MultiPolygon initialCategoryIds?: number[] - initialPoi?: ApiPoi }>() // @@ -122,9 +121,6 @@ onMounted(async () => { menuStore.setSelectedCategoryIds(enabledCategories) } - if (props.initialPoi) - mapStore.setSelectedFeature(props.initialPoi) - $tracking({ type: 'page', title: (route.name && String(route.name)) || undefined, diff --git a/pages/embedded.vue b/pages/embedded.vue index f78a953e..350809f0 100644 --- a/pages/embedded.vue +++ b/pages/embedded.vue @@ -4,12 +4,14 @@ import { storeToRefs } from 'pinia' import Embedded from '~/components/Home/Embedded.vue' import type { ApiPoi } from '~/lib/apiPois' import { siteStore as useSiteStore } from '~/stores/site' +import { mapStore as useMapStore } from '~/stores/map' // // Composables // const { params, query, path } = useRoute() const siteStore = useSiteStore() +const mapStore = useMapStore() const { config, settings } = storeToRefs(siteStore) const { API_ENDPOINT, API_PROJECT, API_THEME } = config.value! const { $trackingInit } = useNuxtApp() @@ -21,7 +23,6 @@ const boundaryGeojson = ref() const categoryIdsJoin = ref() const poiId = ref() const categoryIds = ref() -const initialPoi = ref() // // Hooks @@ -75,7 +76,7 @@ if (categoryIds.value && poiId.value) { if (!data.value) throw createError({ statusCode: 404, message: 'Initial POI not found !' }) - initialPoi.value = data.value! + mapStore.setSelectedFeature(data.value!) } @@ -83,7 +84,6 @@ if (categoryIds.value && poiId.value) { diff --git a/pages/index.vue b/pages/index.vue index 281f9cd3..5c46f0cb 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -4,12 +4,14 @@ import { storeToRefs } from 'pinia' import Home from '~/components/Home/Home.vue' import type { ApiPoi } from '~/lib/apiPois' import { siteStore as useSiteStore } from '~/stores/site' +import { mapStore as useMapStore } from '~/stores/map' // // Composables // const { params, query, path } = useRoute() const siteStore = useSiteStore() +const mapStore = useMapStore() const { config, settings } = storeToRefs(siteStore) const { API_ENDPOINT, API_PROJECT, API_THEME } = config.value! const { $trackingInit } = useNuxtApp() @@ -21,7 +23,6 @@ const boundaryGeojson = ref() const categoryIdsJoin = ref() const poiId = ref() const categoryIds = ref() -const initialPoi = ref() // // Hooks @@ -66,6 +67,7 @@ else { categoryIds.value = categoryIdsJoin.value?.split(',').map(id => Number.parseInt(id)) +// Fetch inital POI const { data, error } = await useFetch(`${API_ENDPOINT}/${API_PROJECT}/${API_THEME}/poi/${poiId.value}.geojson?geometry_as=bbox&short_description=true`) if (categoryIds.value && poiId.value) { @@ -75,7 +77,7 @@ if (categoryIds.value && poiId.value) { if (!data.value) throw createError({ statusCode: 404, message: 'Initial POI not found !' }) - initialPoi.value = data.value! + mapStore.setSelectedFeature(data.value!) } @@ -83,7 +85,6 @@ if (categoryIds.value && poiId.value) { From 61d0625b037ab515313f75c1f944e658c895c04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Thu, 18 Jul 2024 16:45:34 +0200 Subject: [PATCH 04/81] fix: client code executed on server #338 --- components/Fields/Coordinates.vue | 5 +- components/Home/Home.vue | 31 ++++++----- components/PoisCard/PoiCardContent.vue | 77 +++++++++++++------------- lib/coordinates.ts | 20 +++---- utils/isIOS.ts | 4 ++ 5 files changed, 69 insertions(+), 68 deletions(-) diff --git a/components/Fields/Coordinates.vue b/components/Fields/Coordinates.vue index 2706e443..8f1e0493 100644 --- a/components/Fields/Coordinates.vue +++ b/components/Fields/Coordinates.vue @@ -5,7 +5,6 @@ import type { PropType } from 'vue' import { defineNuxtComponent } from '#app' import ExternalLink from '~/components/UI/ExternalLink.vue' import { coordinatesHref } from '~/lib/coordinates' -import { isIOS } from '~/utils/isIOS' export function isCoordinatesEmpty(geom: GeoJSON.Geometry): boolean { return !(geom && geom.type === 'Point' && geom.coordinates) @@ -30,9 +29,7 @@ export default defineNuxtComponent({ }, mounted() { - // isOS is client side only - this.href - = isIOS !== undefined ? coordinatesHref(this.geom, isIOS()) : undefined + this.href = coordinatesHref(this.geom) }, }) diff --git a/components/Home/Home.vue b/components/Home/Home.vue index badf89db..a1964e6d 100644 --- a/components/Home/Home.vue +++ b/components/Home/Home.vue @@ -229,21 +229,24 @@ const siteName = computed(() => { // watch(selectedFeature, () => { showPoi.value = !!selectedFeature.value - routerPushUrl() - - if (selectedFeature.value) { - $tracking({ - type: 'popup', - poiId: - selectedFeature.value.properties.metadata.id - || selectedFeature.value.properties?.id, - title: selectedFeature.value.properties?.name, - location: window.location.href, - path: route.path, - categoryIds: selectedFeature.value.properties?.metadata?.category_ids || [], - }) + + if (process.client) { + routerPushUrl() + + if (selectedFeature.value) { + $tracking({ + type: 'popup', + poiId: + selectedFeature.value.properties.metadata.id + || selectedFeature.value.properties?.id, + title: selectedFeature.value.properties?.name, + location: window.location.href, + path: route.path, + categoryIds: selectedFeature.value.properties?.metadata?.category_ids || [], + }) + } } -}) +}, { immediate: true }) watch(selectedCategoryIds, (a, b) => { if (a !== b) { diff --git a/components/PoisCard/PoiCardContent.vue b/components/PoisCard/PoiCardContent.vue index c38b9d7a..d7c4cda6 100644 --- a/components/PoisCard/PoiCardContent.vue +++ b/components/PoisCard/PoiCardContent.vue @@ -10,7 +10,6 @@ import type { ApiPoi, ApiPoiId, ApiPoiProperties } from '~/lib/apiPois' import { coordinatesHref } from '~/lib/coordinates' import { favoriteStore } from '~/stores/favorite' import { mapStore } from '~/stores/map' -import { isIOS } from '~/utils/isIOS' import ContribFieldGroup from '~/components/Fields/ContribFieldGroup.vue' import type { ContribFields } from '~/composables/useContrib' import useDevice from '~/composables/useDevice' @@ -43,11 +42,17 @@ export default defineNuxtComponent({ }, }, - setup() { + setup(props) { const device = useDevice() + const routeHref = ref() + + onMounted(() => { + routeHref.value = coordinatesHref(props.poi.geometry) + }) return { device, + routeHref, } }, @@ -125,7 +130,7 @@ export default defineNuxtComponent({ } else { const u = new URL(url) - if (u.hostname !== window.location.hostname) { + if (process.client && u.hostname !== window.location.hostname) { return url } else { @@ -136,12 +141,6 @@ export default defineNuxtComponent({ } } }, - - coordinatesHref(): string | undefined { - return isIOS !== undefined - ? coordinatesHref(this.poi.geometry, isIOS()) - : undefined - }, }, emits: { @@ -196,33 +195,35 @@ export default defineNuxtComponent({ {{ name }} - + + +
Date: Mon, 22 Jul 2024 15:55:27 +0200 Subject: [PATCH 05/81] refactor: poi-card to script setup style #338 --- components/PoisCard/PoiCard.vue | 96 ++++++++++++--------------------- 1 file changed, 35 insertions(+), 61 deletions(-) diff --git a/components/PoisCard/PoiCard.vue b/components/PoisCard/PoiCard.vue index f3bccad9..ae7d38e3 100644 --- a/components/PoisCard/PoiCard.vue +++ b/components/PoisCard/PoiCard.vue @@ -1,72 +1,44 @@ - From cb3b105c3c4192ca0c304db033bc86d5e13e945d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 22 Jul 2024 16:11:13 +0200 Subject: [PATCH 06/81] refactor: delete method for direct event emit usage #338 --- components/Search/Search.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/Search/Search.vue b/components/Search/Search.vue index fcbc467d..4c0dd1f9 100644 --- a/components/Search/Search.vue +++ b/components/Search/Search.vue @@ -155,10 +155,6 @@ export default defineNuxtComponent({ methods: { ...mapActions(menuStore, ['addSelectedCategoryIds', 'applyFilters']), - setSelectedFeature(feature: ApiPoi): void { - this.$emit('selectFeature', feature) - }, - reset() { this.searchMenuItemsResults = null this.searchPoisResults = null @@ -237,7 +233,7 @@ export default defineNuxtComponent({ onPoiClick(searchResult: SearchResult) { getPoiById(this.config!, searchResult.id).then( (poi) => { - this.setSelectedFeature(poi) + this.$emit('selectFeature', poi) }, ) @@ -250,7 +246,7 @@ export default defineNuxtComponent({ ) if (feature) { const f = formatApiAddressToFeature(feature, true) - this.setSelectedFeature(f) + this.$emit('selectFeature', f) } this.reset() }, From 1fb5e84fcbbc6632169b8666da4f68c64da6c8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 22 Jul 2024 16:32:23 +0200 Subject: [PATCH 07/81] refactor: poi-card display scenarios #338 --- components/Home/Home.vue | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/components/Home/Home.vue b/components/Home/Home.vue index a1964e6d..f4df3104 100644 --- a/components/Home/Home.vue +++ b/components/Home/Home.vue @@ -62,7 +62,7 @@ const initialBbox = ref(null) const isMenuItemOpen = ref(false) const isOnSearch = ref(false) const showFavoritesOverlay = ref(false) -const showPoi = ref(false) +const isPoiCardShown = ref(false) const mapFeaturesRef = ref>() // @@ -149,12 +149,8 @@ const favoritesModeEnabled = computed(() => { return settings!.themes[0]?.favorites_mode ?? true }) -const isPoiCardVisible = computed(() => { - return !!(selectedFeature.value && showPoi.value) -}) - const isBottomMenuOpened = computed(() => { - return ((device.value.smallScreen && isPoiCardVisible.value) || isMenuItemOpen.value) + return ((device.value.smallScreen && isPoiCardShown.value) || isMenuItemOpen.value) }) const fitBoundsPaddingOptions = computed((): FitBoundsOptions['padding'] => { @@ -169,7 +165,7 @@ const fitBoundsPaddingOptions = computed((): FitBoundsOptions['padding'] => { else { return { top: 100, - bottom: isPoiCardVisible.value ? 400 : 100, + bottom: isPoiCardShown.value ? 400 : 100, right: 100, left: isModeExplorerOrFavorites.value ? 50 : 500, } @@ -228,7 +224,7 @@ const siteName = computed(() => { // Watchers // watch(selectedFeature, () => { - showPoi.value = !!selectedFeature.value + isPoiCardShown.value = !!selectedFeature.value if (process.client) { routerPushUrl() @@ -353,21 +349,21 @@ function onBottomMenuButtonClick() { if (!isModeFavorites.value) { if (isBottomMenuOpened.value) { if (selectedFeature.value) - setPoiVisibility(false) + setPoiCardDisplay(false) isMenuItemOpen.value = false } else if (!isModeExplorer.value) { isMenuItemOpen.value = true } - else if (selectedFeature.value && !isPoiCardVisible.value) { - setPoiVisibility(true) + else if (selectedFeature.value && !isPoiCardShown.value) { + setPoiCardDisplay(true) } } else if (selectedFeature.value) { - if (!isModeExplorer.value && !showPoi.value) + if (!isModeExplorer.value && !isPoiCardShown.value) mapStore.setSelectedFeature(null) else - setPoiVisibility(false) + setPoiCardDisplay(false) } } @@ -428,7 +424,7 @@ function toggleExploreAroundSelectedPoi(feature?: ApiPoi) { goToSelectedFeature() if (device.value.smallScreen) - showPoi.value = false + isPoiCardShown.value = false } else { allowRegionBackZoom.value = false @@ -463,13 +459,12 @@ function scrollTop() { header.scrollTop = 0 } -function setPoiVisibility(visible: boolean) { - showPoi.value = visible +function setPoiCardDisplay(visible: boolean) { + isPoiCardShown.value = visible } function handlePoiCardClose() { mapStore.setSelectedFeature(null) - setPoiVisibility(false) } @@ -609,7 +604,7 @@ function handlePoiCardClose() { >