2024-11-27 17:51:49 +01:00
|
|
|
<template>
|
|
|
|
|
<Dialog
|
|
|
|
|
id="add-pdf"
|
|
|
|
|
v-model:visible="isOpen"
|
|
|
|
|
modal
|
|
|
|
|
:draggable="false"
|
2025-09-09 09:37:34 +02:00
|
|
|
:dismissableMask="true"
|
2026-02-02 18:21:11 +01:00
|
|
|
:header="t('dialogs.pdfTitle')"
|
2024-11-27 17:51:49 +01:00
|
|
|
class="dialog"
|
2025-01-27 15:53:23 +01:00
|
|
|
:class="[
|
|
|
|
|
{ 'with-comments': isCommentsOpen },
|
|
|
|
|
{ 'with-dtl': correspondingDTLProposal },
|
|
|
|
|
]"
|
2024-11-27 17:51:49 +01:00
|
|
|
:closeOnEscape="true"
|
|
|
|
|
>
|
|
|
|
|
<template #header>
|
|
|
|
|
<button
|
|
|
|
|
v-if="
|
2026-01-30 09:13:31 +01:00
|
|
|
['clientBrief', 'extendedBrief'].includes(dialog.content.id) &&
|
2024-11-27 17:51:49 +01:00
|
|
|
dialog.content.isValidated !== true
|
|
|
|
|
"
|
|
|
|
|
class="btn"
|
|
|
|
|
@click="validate()"
|
|
|
|
|
>
|
2026-02-02 18:21:11 +01:00
|
|
|
{{ t('buttons.validate') }}
|
2024-11-27 17:51:49 +01:00
|
|
|
</button>
|
|
|
|
|
<h2
|
|
|
|
|
v-if="openedFile"
|
|
|
|
|
class="font-serif text-lg"
|
|
|
|
|
:title="openedFile?.label.length ? openedFile.label : openedFile.name"
|
|
|
|
|
>
|
|
|
|
|
{{ openedFile?.label.length ? openedFile.label : openedFile.name }}
|
|
|
|
|
</h2>
|
|
|
|
|
</template>
|
|
|
|
|
<div id="vpv-container">
|
|
|
|
|
<PdfViewer />
|
|
|
|
|
</div>
|
|
|
|
|
</Dialog>
|
2025-01-27 11:22:57 +01:00
|
|
|
<DTLPanel
|
|
|
|
|
v-if="correspondingDTLProposal"
|
|
|
|
|
:proposals="[correspondingDTLProposal]"
|
|
|
|
|
/>
|
2024-11-27 17:51:49 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-09-09 09:37:34 +02:00
|
|
|
import Dialog from 'primevue/dialog';
|
|
|
|
|
import PdfViewer from './PdfViewer.vue';
|
|
|
|
|
import DTLPanel from '../design-to-light/DTLPanel.vue';
|
|
|
|
|
import { computed, ref, watch } from 'vue';
|
|
|
|
|
import { useDialogStore } from '../../stores/dialog';
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
import { useApiStore } from '../../stores/api';
|
|
|
|
|
import { usePageStore } from '../../stores/page';
|
2026-02-02 18:21:11 +01:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2024-11-27 17:51:49 +01:00
|
|
|
|
2026-02-02 18:21:11 +01:00
|
|
|
const { t } = useI18n();
|
2024-11-27 17:51:49 +01:00
|
|
|
const { openedFile, isCommentsOpen } = storeToRefs(useDialogStore());
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
|
|
|
|
const dialog = useDialogStore();
|
|
|
|
|
const api = useApiStore();
|
2025-01-27 11:22:57 +01:00
|
|
|
const { page } = storeToRefs(usePageStore());
|
2024-11-27 17:51:49 +01:00
|
|
|
|
|
|
|
|
const isOpen = ref(true);
|
2025-01-28 20:06:41 +01:00
|
|
|
const hasDTLProposal = computed(() => {
|
|
|
|
|
return page.value?.designToLight;
|
|
|
|
|
});
|
2025-01-28 07:26:20 +01:00
|
|
|
|
2024-11-27 17:51:49 +01:00
|
|
|
watch(isOpen, (newValue) => {
|
|
|
|
|
router.push({ name: route.name });
|
2025-01-28 07:26:20 +01:00
|
|
|
openedFile.value = null;
|
2024-11-27 17:51:49 +01:00
|
|
|
});
|
|
|
|
|
|
2024-11-28 14:45:45 +01:00
|
|
|
openedFile.value = route.query.fileIndex
|
|
|
|
|
? dialog.content.files[route.query.fileIndex]
|
2025-09-09 09:37:34 +02:00
|
|
|
: dialog.content.files.find((file) => file.type === 'document');
|
2024-11-28 14:45:45 +01:00
|
|
|
|
2025-01-27 11:22:57 +01:00
|
|
|
const correspondingDTLProposal = computed(() => {
|
2025-01-28 20:06:41 +01:00
|
|
|
if (!hasDTLProposal.value || !isOpen.value || !openedFile.value) return false;
|
2025-01-27 11:22:57 +01:00
|
|
|
|
|
|
|
|
const correspondingDTLProposal = page.value.designToLight.find((proposal) => {
|
2025-01-28 20:06:41 +01:00
|
|
|
return openedFile.value.source === proposal.location?.source;
|
2025-01-27 11:22:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!correspondingDTLProposal) return false;
|
|
|
|
|
|
|
|
|
|
return correspondingDTLProposal;
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-27 17:51:49 +01:00
|
|
|
// Functions
|
|
|
|
|
async function validate() {
|
|
|
|
|
const response = await api.validateBrief(
|
2026-01-30 09:13:31 +01:00
|
|
|
route.path + '/' + dialog.content.slug,
|
2024-11-27 17:51:49 +01:00
|
|
|
route.fullPath
|
|
|
|
|
);
|
|
|
|
|
if (response.success) {
|
|
|
|
|
dialog.content.isValidated = true;
|
|
|
|
|
} else {
|
|
|
|
|
console.alert(response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
#vpv-container {
|
|
|
|
|
width: var(--dialog-max-w);
|
|
|
|
|
height: calc(var(--dialog-max-h) - var(--dialog-header-h));
|
|
|
|
|
background: black;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.with-comments .vpv-pages-container-wrapper {
|
|
|
|
|
margin-right: var(--dialog-comments-w, 20rem);
|
|
|
|
|
}
|
|
|
|
|
</style>
|