From 8bb4f552cd662f439e813678d479b53fe9d352a7 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 28 Jan 2025 07:26:20 +0100 Subject: [PATCH] close DTL panel exactly at the same time as the dialog --- src/components/project/TitledPdfWrapper.vue | 4 +++- src/components/project/virtual-sample/VirtualSample.vue | 5 +++-- src/stores/dialog.js | 5 ----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/project/TitledPdfWrapper.vue b/src/components/project/TitledPdfWrapper.vue index e455f56..e7d1e4e 100644 --- a/src/components/project/TitledPdfWrapper.vue +++ b/src/components/project/TitledPdfWrapper.vue @@ -63,8 +63,10 @@ const api = useApiStore(); const { page } = storeToRefs(usePageStore()); const isOpen = ref(true); + watch(isOpen, (newValue) => { router.push({ name: route.name }); + openedFile.value = null; }); openedFile.value = route.query.fileIndex @@ -73,7 +75,7 @@ openedFile.value = route.query.fileIndex const correspondingDTLProposal = computed(() => { const hasDTLProposal = page.value?.designToLight; - if (!hasDTLProposal) return false; + if (!hasDTLProposal || !isOpen.value || !openedFile.value) return false; const correspondingDTLProposal = page.value.designToLight.find((proposal) => { return openedFile.value.source === proposal.location.source; diff --git a/src/components/project/virtual-sample/VirtualSample.vue b/src/components/project/virtual-sample/VirtualSample.vue index 069a69a..d01558a 100644 --- a/src/components/project/virtual-sample/VirtualSample.vue +++ b/src/components/project/virtual-sample/VirtualSample.vue @@ -129,6 +129,7 @@ const route = useRoute(); const isOpen = ref(true); watch(isOpen, (newValue) => { router.push({ name: route.name }); + openedFile.value = null; }); const downloadText = computed(() => { @@ -145,7 +146,7 @@ const downloadText = computed(() => { const correspondingDTLProposal = computed(() => { const hasDTLProposal = page.value?.designToLight; - if (!hasDTLProposal) return false; + if (!hasDTLProposal || !isOpen.value || !openedFile.value) return false; const correspondingDTLProposal = page.value.designToLight.find((proposal) => { if (activeTab.value === "dynamic") { @@ -158,7 +159,7 @@ const correspondingDTLProposal = computed(() => { } else { return ( proposal.location.type === "static" && - openedFile.value.source === proposal.location.source + openedFile.value?.source === proposal.location.source ); } }); diff --git a/src/stores/dialog.js b/src/stores/dialog.js index 30b3374..437477a 100644 --- a/src/stores/dialog.js +++ b/src/stores/dialog.js @@ -18,11 +18,6 @@ export const useDialogStore = defineStore("dialog", () => { function updateFile(newFile) { openedFile.value = newFile; - - // if (!content.value.files) return; - // content.value.files = content.value.files.map((file) => - // file.id === newFile.id ? newFile : file - // ); } const route = useRoute();