This commit is contained in:
isUnknown 2024-12-19 19:27:38 +01:00
parent 6d70187cb9
commit c578538fe0
10 changed files with 195 additions and 107 deletions

View file

@ -26,9 +26,15 @@
>
<hgroup class="order-last">
<h3 class="card__title | font-serif | text-lg">
<router-link :to="'/' + step.uri" class="link-full">{{
step.label
}}</router-link>
<router-link
:to="
step.id === 'clientBrief'
? '/' + page.uri + '/client-brief'
: '/' + step.uri
"
class="link-full"
>{{ step.label }}</router-link
>
</h3>
</hgroup>
<div class="card__meta | flex">
@ -42,17 +48,20 @@
<figure
v-if="step.id === 'clientBrief' && step.files[0]?.type === 'image'"
class="card__images"
:data-count="step.files.length"
:data-count="
step.files.filter((file) => file.type === 'image').length
"
:data-plus="
step.files.length > 3 ? step.files.length - 3 : undefined
"
>
<img
v-for="image in step.files.slice(0, 3)"
:key="image.uuid"
:src="image.url"
:alt="image.alt"
/>
<template v-for="image in step.files.slice(0, 3)" :key="image.uuid">
<img
v-if="image.type === 'image'"
:src="image.url"
:alt="image.alt"
/>
</template>
</figure>
<figure
v-if="step.id === 'virtualSample'"
@ -87,70 +96,93 @@
</footer>
</article>
<template v-if="step.id === 'clientBrief' && hasOneBriefType()">
<button
v-if="step.files[0].type === 'document'"
class="btn | w-full"
@click="toImagesBrief()"
>
Ajouter un brief via la plateforme
</button>
<div class="btn | w-full" v-else>
<label for="upload-pdf">
Ajouter brief PDF
<input
id="upload-pdf"
type="file"
@change="addPdf($event, step.uri)"
accept="application/pdf"
ref="pdfInput"
hidden
/>
</label>
</div>
</template>
<template
v-if="
(step.id == 'clientBrief' &&
step.files.find((file) => file.type === 'document')) ||
step.id == 'proposal' ||
(step.id == 'industrialIdeation' && step.files.length)
"
>
<article
class="card"
v-for="(file, index) in step.files"
:key="file.name"
>
<hgroup class="order-last">
<h3 class="card__title | font-serif | text-lg">
<router-link
:to="'/' + step.uri + '&fileIndex=' + index"
class="link-full"
<template v-for="(file, index) in step.files" :key="file.name">
<article class="card" v-if="file.type === 'document'">
<hgroup class="order-last">
<h3 class="card__title | font-serif | text-lg">
<router-link
:to="'/' + step.uri + '&fileIndex=' + index"
class="link-full"
>
{{
file.label.length
? file.label
: file.name.replace(".pdf", "")
}}
</router-link>
</h3>
</hgroup>
<div class="card__meta | flex">
<time
class="card__date | text-grey-700"
:datetime="dayjs(file.modified).format('YYYY-M-DD')"
>{{ dayjs(file.modified).format("DD MMMM YYYY") }}</time
>
{{
file.label.length
? file.label
: file.name.replace(".pdf", "")
}}
</router-link>
</h3>
</hgroup>
<div class="card__meta | flex">
<time
class="card__date | text-grey-700"
:datetime="dayjs(file.modified).format('YYYY-M-DD')"
>{{ dayjs(file.modified).format("DD MMMM YYYY") }}</time
>
</div>
<template v-if="index === 0">
<figure
v-if="file.cover"
class="card__images pdf-cover"
style="aspect-ratio: unset"
>
<img :src="file.cover" alt="" />
</figure>
<div v-else class="card__images" data-icon="document"></div>
</template>
<footer
v-if="file.comments?.length > 0"
class="order-last | text-sm text-primary font-medium"
>
<template v-if="step.id === 'proposal'">
<router-link
:to="'/' + step.uri + '&fileIndex=' + index + '&comments'"
</div>
<template v-if="step.id === 'clientBrief' || index === 0">
<figure
v-if="file.cover"
class="card__images pdf-cover"
style="aspect-ratio: unset"
>
{{ file.comments.length }} commentaire{{
file.comments.length > 1 ? "s" : ""
}}
</router-link>
<img :src="file.cover" alt="" />
</figure>
<div v-else class="card__images" data-icon="document"></div>
</template>
<template v-else>
<router-link :to="'/' + step.uri + '&comments=true'">
{{ file.comments.length }} commentaire{{
file.comments.length > 1 ? "s" : ""
}}
</router-link>
</template>
</footer>
</article>
<footer
v-if="file.comments?.length > 0"
class="order-last | text-sm text-primary font-medium"
>
<template v-if="step.id === 'proposal'">
<router-link
:to="'/' + step.uri + '&fileIndex=' + index + '&comments'"
>
{{ file.comments.length }} commentaire{{
file.comments.length > 1 ? "s" : ""
}}
</router-link>
</template>
<template v-else>
<router-link :to="'/' + step.uri + '&comments=true'">
{{ file.comments.length }} commentaire{{
file.comments.length > 1 ? "s" : ""
}}
</router-link>
</template>
</footer>
</article>
</template>
</template>
</template>
@ -189,16 +221,20 @@ import "dayjs/locale/fr";
import { usePageStore } from "../../stores/page";
import { computed } from "vue";
import { useProjectStore } from "../../stores/project";
import { useRouter } from "vue-router";
import { useBriefStore } from "../../stores/brief";
const { step } = defineProps({
step: Object,
});
const emit = defineEmits(["update:file"]);
const router = useRouter();
dayjs.locale("fr");
const { page } = usePageStore();
const { addPdf } = useBriefStore();
const { setStatus } = useProjectStore();
const steps = page.steps.map((item) => {
@ -225,6 +261,16 @@ function getFrontView(track) {
const frontView = track.files.find((file) => file.name === frontViewName);
return frontView;
}
function hasOneBriefType() {
const hasImage = step.files.some((file) => file.type === "image");
const hasDocument = step.files.some((file) => file.type === "document");
return hasImage ^ hasDocument;
}
function toImagesBrief() {
router.push(location.pathname + "/client-brief?step=images");
}
</script>
<style scoped>