2024-07-31 00:33:21 +02:00
|
|
|
<template>
|
2024-10-07 03:19:22 +02:00
|
|
|
<Transition>
|
|
|
|
<div v-if="isEtapeValid || isPageValid">
|
|
|
|
<div class="content-wrapper">
|
|
|
|
<ModaleHeader
|
|
|
|
:content="etape.title ? etape : page"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
|
|
|
<main>
|
|
|
|
<div v-for="partie in etape.parties || page.parties" class="partie">
|
|
|
|
<ModaleCarteSensible
|
|
|
|
v-if="partie.type === 'carte_sensible'"
|
|
|
|
:partie="partie" />
|
|
|
|
<ModaleTitreTexte
|
|
|
|
v-if="partie.type === 'titre_texte'"
|
|
|
|
:partie="partie"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
|
|
|
<ModaleChiffresCles
|
|
|
|
v-if="partie.type === 'chiffres_cles'"
|
|
|
|
:partie="partie"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
|
|
|
<ModaleDiaporama
|
|
|
|
v-if="partie.type === 'diaporama'"
|
2024-10-07 23:39:50 +02:00
|
|
|
:partie="partie"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
2024-10-07 03:19:22 +02:00
|
|
|
<ModaleEntretien
|
|
|
|
v-if="partie.type === 'entretien'"
|
|
|
|
:partie="partie"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
|
|
|
<ModaleExergue
|
|
|
|
v-if="partie.type === 'exergue'"
|
|
|
|
:partie="partie"
|
|
|
|
:couleur="etape.couleur || brandColor" />
|
|
|
|
<ModaleVideos
|
|
|
|
v-if="partie.type === 'video'"
|
|
|
|
:partie="partie" />
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<ModaleFooter
|
|
|
|
:content="etape || page"
|
2024-10-07 23:39:50 +02:00
|
|
|
:couleur="etape.couleur || brandColor"
|
|
|
|
:map="map" />
|
2024-09-29 21:36:21 +02:00
|
|
|
</div>
|
2024-10-07 03:19:22 +02:00
|
|
|
</div>
|
|
|
|
</Transition>
|
2024-07-31 00:33:21 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2024-10-07 03:19:22 +02:00
|
|
|
import { computed, watch, onMounted } from 'vue';
|
2024-08-05 21:08:09 +02:00
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
import { useContentStore } from '../stores/content';
|
2024-10-07 23:39:50 +02:00
|
|
|
import { useMapStore } from '../stores/mapState';
|
2024-08-05 21:08:09 +02:00
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
2024-09-29 21:36:21 +02:00
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
import ModaleHeader from './components/ModaleHeader.vue';
|
|
|
|
import ModaleFooter from './components/ModaleFooter.vue';
|
|
|
|
|
|
|
|
import ModaleCarteSensible from './components/parties/ModaleCarteSensible.vue';
|
|
|
|
import ModaleTitreTexte from './components/parties/ModaleTitreTexte.vue';
|
|
|
|
import ModaleChiffresCles from './components/parties/ModaleChiffresCles.vue';
|
|
|
|
import ModaleDiaporama from './components/parties/ModaleDiaporama.vue';
|
|
|
|
import ModaleEntretien from './components/parties/ModaleEntretien.vue';
|
|
|
|
import ModaleExergue from './components/parties/ModaleExergue.vue';
|
|
|
|
import ModaleVideos from './components/parties/ModaleVideos.vue';
|
2024-09-29 21:36:21 +02:00
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
import { useUtils } from './composables/useUtils';
|
|
|
|
const { isObjectEmpty, scrollTop } = useUtils();
|
2024-08-05 21:08:09 +02:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
const store = useContentStore();
|
2024-10-07 23:39:50 +02:00
|
|
|
const mapState = useMapStore();
|
2024-08-05 21:08:09 +02:00
|
|
|
const route = useRoute();
|
2024-07-31 00:33:21 +02:00
|
|
|
|
2024-10-07 23:39:50 +02:00
|
|
|
const { loading, error, href, map, etape, page } = storeToRefs(store);
|
|
|
|
const { duration } = storeToRefs(mapState);
|
2024-07-31 00:33:21 +02:00
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
const isEtapeValid = computed(() => !error.value && !loading.value && etape.value && !isObjectEmpty(etape.value));
|
|
|
|
const isPageValid = computed(() => !error.value && !loading.value && page.value && !isObjectEmpty(page.value));
|
2024-07-31 02:13:40 +02:00
|
|
|
|
2024-10-07 23:39:50 +02:00
|
|
|
let isModaleEtape, wasModaleEtape;
|
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
const brandColor = "#80c8bf";
|
2024-08-05 21:08:09 +02:00
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
let isProgrammaticNavigation = false;
|
2024-08-05 21:08:09 +02:00
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
const handleRouteChange = () => {
|
|
|
|
watch(
|
|
|
|
() => route.params.id,
|
2024-10-07 23:39:50 +02:00
|
|
|
(newId) => {
|
2024-10-07 03:19:22 +02:00
|
|
|
if (isProgrammaticNavigation) {
|
|
|
|
isProgrammaticNavigation = false;
|
|
|
|
return;
|
2024-09-29 21:36:21 +02:00
|
|
|
}
|
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
if (!newId) {
|
2024-10-07 23:39:50 +02:00
|
|
|
store.emptyAll(map.value);
|
2024-10-07 03:19:22 +02:00
|
|
|
} else {
|
2024-10-07 23:39:50 +02:00
|
|
|
store.fetchEtapeData(newId, map.value);
|
2024-10-07 03:19:22 +02:00
|
|
|
if (!etape.value?.data) {
|
2024-10-07 23:39:50 +02:00
|
|
|
store.fetchStaticData(newId, map.value);
|
2024-10-07 03:19:22 +02:00
|
|
|
}
|
|
|
|
scrollTop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ immediate: true }
|
|
|
|
);
|
2024-09-29 21:36:21 +02:00
|
|
|
};
|
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
const handleColorChange = () => {
|
|
|
|
watch(
|
|
|
|
() => href.value,
|
|
|
|
() => {
|
|
|
|
document.documentElement.style.setProperty('--etape-couleur', etape.value.couleur || brandColor);
|
|
|
|
}
|
|
|
|
);
|
2024-09-29 21:36:21 +02:00
|
|
|
};
|
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
const handleHrefChange = () => {
|
|
|
|
watch(
|
|
|
|
() => href.value,
|
|
|
|
(newHref) => {
|
|
|
|
const relativePath = newHref.split('.fr')[1];
|
2024-10-07 23:39:50 +02:00
|
|
|
isProgrammaticNavigation = true;
|
|
|
|
if (newHref == '') {
|
|
|
|
router.push('/');
|
|
|
|
mapState.unlockMap(map.value)
|
|
|
|
} else {
|
|
|
|
if (relativePath && relativePath !== '' && relativePath !== '/') {
|
|
|
|
mapState.lockMap(map.value);
|
|
|
|
router.push(relativePath);
|
|
|
|
scrollTop();
|
|
|
|
}
|
2024-08-05 21:08:09 +02:00
|
|
|
}
|
2024-07-31 02:13:40 +02:00
|
|
|
}
|
2024-10-07 03:19:22 +02:00
|
|
|
);
|
2024-09-29 21:36:21 +02:00
|
|
|
};
|
|
|
|
|
2024-10-07 23:39:50 +02:00
|
|
|
const handleMapMovement = () => {
|
|
|
|
watch(
|
|
|
|
() => href.value,
|
|
|
|
() => {
|
|
|
|
isModaleEtape = !isObjectEmpty(etape.value);
|
|
|
|
|
|
|
|
if (!wasModaleEtape && isModaleEtape) {
|
|
|
|
document.documentElement.style.setProperty('--modale-enter-delay', `${duration.value}s`);
|
|
|
|
mapState.zoomToPlace(map.value, etape.value.coordinates.lat, etape.value.coordinates.lon);
|
|
|
|
|
|
|
|
} else if (wasModaleEtape && isModaleEtape) {
|
|
|
|
document.documentElement.style.setProperty('--modale-leave-delay', 0);
|
|
|
|
document.documentElement.style.setProperty('--modale-enter-delay', `${duration.value * 2}s`);
|
|
|
|
mapState.resetMap(map.value);
|
|
|
|
setTimeout(() => {
|
|
|
|
mapState.zoomToPlace(map.value, etape.value.coordinates.lat, etape.value.coordinates.lon);
|
|
|
|
}, duration.value * 1000);
|
|
|
|
|
|
|
|
} else if (wasModaleEtape && !isModaleEtape) {
|
|
|
|
document.documentElement.style.setProperty('--modale-leave-delay', 0);
|
|
|
|
mapState.resetMap(map.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
wasModaleEtape = isModaleEtape;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-10-07 03:19:22 +02:00
|
|
|
onMounted(() => {
|
2024-10-07 23:39:50 +02:00
|
|
|
isModaleEtape = !isObjectEmpty(etape.value);
|
|
|
|
wasModaleEtape = isModaleEtape;
|
2024-10-07 03:19:22 +02:00
|
|
|
handleRouteChange();
|
|
|
|
handleColorChange();
|
|
|
|
handleHrefChange();
|
2024-10-07 23:39:50 +02:00
|
|
|
handleMapMovement();
|
2024-10-07 03:19:22 +02:00
|
|
|
});
|
|
|
|
</script>
|
2024-07-31 02:13:40 +02:00
|
|
|
|
2024-09-29 21:36:21 +02:00
|
|
|
<style scss>
|
2024-10-07 23:39:50 +02:00
|
|
|
.v-enter-active {
|
|
|
|
transition: all 0.5s linear var(--modale-enter-delay);
|
|
|
|
}
|
|
|
|
|
2024-07-31 02:13:40 +02:00
|
|
|
.v-leave-active {
|
2024-10-07 23:39:50 +02:00
|
|
|
transition: all 0.5s linear var(--modale-leave-delay);
|
2024-07-31 02:13:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.v-enter-from,
|
|
|
|
.v-leave-to {
|
2024-10-07 23:39:50 +02:00
|
|
|
transform: translateY(20vh);
|
2024-07-31 02:13:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-07 23:39:50 +02:00
|
|
|
.v-enter-to,
|
2024-07-31 02:13:40 +02:00
|
|
|
.v-leave-from {
|
2024-10-07 23:39:50 +02:00
|
|
|
transform: translateY(0vh);
|
2024-07-31 02:13:40 +02:00
|
|
|
}
|
|
|
|
</style>
|