diff --git a/src/bundle/components/profile_v3/profile-infos_v3.vue b/src/bundle/components/profile_v3/profile-infos_v3.vue new file mode 100644 index 00000000..c7e35e00 --- /dev/null +++ b/src/bundle/components/profile_v3/profile-infos_v3.vue @@ -0,0 +1,34 @@ + + + diff --git a/src/bundle/components/profile_v3/profile-routing_v3.vue b/src/bundle/components/profile_v3/profile-routing_v3.vue new file mode 100644 index 00000000..87d702df --- /dev/null +++ b/src/bundle/components/profile_v3/profile-routing_v3.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/bundle/lib.ts b/src/bundle/lib.ts index 9741676b..f1c08424 100644 --- a/src/bundle/lib.ts +++ b/src/bundle/lib.ts @@ -1,4 +1,10 @@ -import { h, getCurrentInstance, createApp, watch } from 'vue' +import { + h, + getCurrentInstance, + createApp, + watch, + // defineCustomElement, // TODO: Update vue package and use this defineCustomElement +} from 'vue' import VueDOMPurifyHTML from 'vue-dompurify-html' import { createPinia, storeToRefs } from 'pinia' @@ -20,6 +26,8 @@ import LayerMetadata from '@/components/layer-metadata/layer-metadata.vue' import HeaderBar from '@/components/header-bar/header-bar.vue' import ProfileDraw from './components/profile_v3/profile-draw_v3.vue' import ProfileMeasures from './components/profile_v3/profile-measures_v3.vue' +import ProfileRouting from './components/profile_v3/profile-routing_v3.vue' +import ProfileInfos from './components/profile_v3/profile-infos_v3.vue' import FooterBar from '@/components/footer/footer-bar.vue' import ToolbarDraw from '@/components/footer/toolbar-draw.vue' import LayerPanel from '@/components/layer-panel/layer-panel.vue' @@ -37,6 +45,8 @@ import { useAppStore } from '@/stores/app.store' import { useMapStore } from '@/stores/map.store' import { useProfileDrawv3Store } from './stores/profile-draw_v3.store' import { useProfileMeasuresv3Store } from './stores/profile-measures_v3.store' +import { useProfileRoutingv3Store } from './stores/profile-routing_v3.store' +import { useProfileInfosv3Store } from './stores/profile-infos_v3.store' import { useDrawStore } from '@/stores/draw.store' import { useStyleStore } from '@/stores/style.store' import { useThemeStore } from '@/stores/config.store' @@ -135,6 +145,8 @@ export { HeaderBar, ProfileDraw, ProfileMeasures, + ProfileRouting, + ProfileInfos, FooterBar, ToolbarDraw, LayerPanel, @@ -154,6 +166,8 @@ export { useMapStore, useProfileDrawv3Store, useProfileMeasuresv3Store, + useProfileRoutingv3Store, + useProfileInfosv3Store, useDrawStore, useStyleStore, useThemeStore, diff --git a/src/bundle/stores/profile-infos_v3.store.ts b/src/bundle/stores/profile-infos_v3.store.ts new file mode 100644 index 00000000..9227dc48 --- /dev/null +++ b/src/bundle/stores/profile-infos_v3.store.ts @@ -0,0 +1,55 @@ +import { Ref, ref } from 'vue' +import { acceptHMRUpdate, defineStore } from 'pinia' +import { Map } from 'ol' + +import { DrawnFeature } from '@/services/draw/drawn-feature' +import { ProfileData } from '@/components/common/graph/elevation-profile' + +/** + * This store is a wrapper to use original in v3. + * This store is used by any drawn feature graph v4 component in the v3 drawing panel. + * + * @deprecated this store is meant to be removed when v4 is fully operational + */ +export const useProfileInfosv3Store = defineStore( + 'profile-infos-v3', + () => { + /** + * Emulate a DrawnFeature with feature coming from v3 + * @deprecated this property is meant to be removed when Drawing and Measures in v4 are fully operational + */ + const feature_v3: Ref = ref(undefined) + + /** + * Activate or deactivate positioning for infos, deactivation is need for eg. + * when infos panel is closed but the features are still on the map, + * in this case, we need to deactivate the geomarker (as we don't see the profile anymore) + */ + const activePositioning_v3 = ref(true) + + function setProfileData( + map: Map, + feature: DrawnFeature, + profileData: ProfileData + ) { + feature_v3.value = undefined + feature['map'] = map // Needed by CSV Exporter + feature['label'] = feature['label'] ?? 'mnt' // Needed by CSV Exporter (= fileName) + feature['getProfile'] = () => Promise.resolve(profileData) + feature_v3.value = feature + } + + return { + feature_v3, + activePositioning_v3, + setProfileData, + } + }, + {} +) + +if (import.meta.hot) { + import.meta.hot.accept( + acceptHMRUpdate(useProfileInfosv3Store, import.meta.hot) + ) +} diff --git a/src/bundle/stores/profile-routing_v3.store.ts b/src/bundle/stores/profile-routing_v3.store.ts new file mode 100644 index 00000000..973cd116 --- /dev/null +++ b/src/bundle/stores/profile-routing_v3.store.ts @@ -0,0 +1,55 @@ +import { Ref, ref } from 'vue' +import { acceptHMRUpdate, defineStore } from 'pinia' +import { Map } from 'ol' + +import { DrawnFeature } from '@/services/draw/drawn-feature' +import { ProfileData } from '@/components/common/graph/elevation-profile' + +/** + * This store is a wrapper to use original in v3. + * This store is used by any drawn feature graph v4 component in the v3 drawing panel. + * + * @deprecated this store is meant to be removed when v4 is fully operational + */ +export const useProfileRoutingv3Store = defineStore( + 'profile-routing-v3', + () => { + /** + * Emulate a DrawnFeature with feature coming from v3 + * @deprecated this property is meant to be removed when Drawing and Measures in v4 are fully operational + */ + const feature_v3: Ref = ref(undefined) + + /** + * Activate or deactivate positioning for routing, deactivation is need for eg. + * when routing panel is closed but the routing features are still on the map, + * in this case, we need to deactivate the geomarker (as we don't see the profile anymore) + */ + const activePositioning_v3 = ref(true) + + function setProfileData( + map: Map, + feature: DrawnFeature, + profileData: ProfileData + ) { + feature_v3.value = undefined + feature['map'] = map // Needed by CSV Exporter + feature['label'] = feature['label'] ?? 'mnt' // Needed by CSV Exporter (= fileName) + feature['getProfile'] = () => Promise.resolve(profileData) + feature_v3.value = feature + } + + return { + feature_v3, + activePositioning_v3, + setProfileData, + } + }, + {} +) + +if (import.meta.hot) { + import.meta.hot.accept( + acceptHMRUpdate(useProfileRoutingv3Store, import.meta.hot) + ) +} diff --git a/src/components/feature-elevation-profile/feature-elevation-profile.vue b/src/components/feature-elevation-profile/feature-elevation-profile.vue index 6435a295..ca5284eb 100644 --- a/src/components/feature-elevation-profile/feature-elevation-profile.vue +++ b/src/components/feature-elevation-profile/feature-elevation-profile.vue @@ -34,11 +34,22 @@ defineEmits<{ (e: 'close'): void }>() -const props = defineProps<{ - feature: DrawnFeature | undefined -}>() +const props = withDefaults( + defineProps<{ + feature: DrawnFeature | undefined + enableExportCSV?: boolean + activatePositioning?: boolean + }>(), + { + enableExportCSV: true, + activatePositioning: true, + } +) -const profilePosition = useProfilePosition(undefined) +const profilePosition = useProfilePosition( + undefined, + () => props.activatePositioning +) const profilePositionStore = useProfilePositionStore() const { t } = useTranslation() @@ -125,14 +136,16 @@ function onOutProfile() { + +