designtopack/src/components/project/ProjectStep.vue

296 lines
9.1 KiB
Vue
Raw Normal View History

<template>
2024-11-21 11:27:14 +01:00
<section
class="flex-1"
:aria-labelledby="step.id"
2024-11-21 11:47:36 +01:00
:data-status="setStatus(page.steps, page.content.currentstep, step)"
2024-11-21 11:27:14 +01:00
>
2024-11-18 16:21:07 +01:00
<h2 :id="step.id">
<span :data-icon="step.id">{{ step.label }}</span>
</h2>
<div class="cards | flow">
2024-11-21 18:10:24 +01:00
<template
v-if="
step.id === 'clientBrief' ||
step.files.dynamic ||
step.files.static ||
step.files.length
"
>
2024-12-11 14:37:06 +01:00
<article
class="card"
v-if="
step.id !== 'proposal' &&
step.id !== 'industrialIdeation' &&
step.id !== 'physicalSample'
"
>
2024-10-23 09:48:27 +02:00
<hgroup class="order-last">
2024-11-19 15:55:27 +01:00
<h3 class="card__title | font-serif | text-lg">
2024-12-19 19:27:38 +01:00
<router-link
:to="
step.id === 'clientBrief'
? '/' + page.uri + '/client-brief'
: '/' + step.uri
"
class="link-full"
>{{ step.label }}</router-link
>
2024-11-19 15:55:27 +01:00
</h3>
2024-10-23 09:48:27 +02:00
</hgroup>
<div class="card__meta | flex">
<time
class="card__date | text-grey-700"
2024-11-21 18:10:24 +01:00
:datetime="dayjs(step.modified).format('YYYY-M-DD')"
>{{ dayjs(step.modified).format("DD MMMM YYYY") }}</time
>
2024-10-23 09:48:27 +02:00
</div>
2024-11-21 18:10:24 +01:00
<!-- All images -->
<figure
v-if="step.id === 'clientBrief' && step.files[0]?.type === 'image'"
class="card__images"
2024-12-19 19:27:38 +01:00
:data-count="
step.files.filter((file) => file.type === 'image').length
"
:data-plus="
step.files.length > 3 ? step.files.length - 3 : undefined
"
>
2024-12-19 19:27:38 +01:00
<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>
2024-11-21 18:10:24 +01:00
<figure
v-if="step.id === 'virtualSample'"
class="card__images"
:data-count="step.files.dynamic.length"
:data-plus="
step.files.dynamic.length > 3
? step.files.dynamic.length - 3
: undefined
"
>
<img
v-for="track in step.files.dynamic"
:key="track.files.slug"
:src="getFrontView(track).url"
:alt="getFrontView(track).alt"
2024-11-21 18:10:24 +01:00
/>
</figure>
<!-- Document -->
<div
2024-11-21 18:10:24 +01:00
v-if="step.files[0]?.type === 'document'"
class="card__images"
data-icon="document"
></div>
2024-11-20 08:39:26 +01:00
<footer
2024-11-21 18:10:24 +01:00
v-if="step?.files[0]?.comments?.length > 0"
2024-11-20 08:39:26 +01:00
class="order-last | text-sm text-primary font-medium"
>
2024-11-21 18:10:24 +01:00
{{ step.files[0].comments.length }} commentaire{{
step.files[0].comments.length > 1 ? "s" : ""
2024-11-08 12:25:00 +01:00
}}
</footer>
2024-11-18 16:21:07 +01:00
</article>
2024-11-21 18:10:24 +01:00
2024-12-19 19:27:38 +01:00
<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>
2024-12-11 14:37:06 +01:00
<template
v-if="
2024-12-19 19:27:38 +01:00
(step.id == 'clientBrief' &&
step.files.find((file) => file.type === 'document')) ||
2024-12-11 14:37:06 +01:00
step.id == 'proposal' ||
(step.id == 'industrialIdeation' && step.files.length)
"
>
2024-12-19 19:27:38 +01:00
<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
2024-11-21 18:10:24 +01:00
>
2024-12-19 19:27:38 +01:00
</div>
<template v-if="step.id === 'clientBrief' || index === 0">
<figure
v-if="file.cover"
class="card__images pdf-cover"
style="aspect-ratio: unset"
>
2024-12-19 19:27:38 +01:00
<img :src="file.cover" alt="" />
</figure>
<div v-else class="card__images" data-icon="document"></div>
</template>
2024-12-19 19:27:38 +01:00
<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>
2024-11-21 18:10:24 +01:00
</template>
2024-11-18 16:21:07 +01:00
</template>
2024-12-11 14:37:06 +01:00
2024-12-16 17:52:49 +01:00
<template v-if="step.id === 'physicalSample' && step.files[0]">
<div class="card | physical-sample">
2024-12-16 17:52:49 +01:00
<header
class="text-center rounded-lg py-32"
:style="'--cover: url(' + step.cover + ')'"
>
<h3 class="text-lg font-serif">
2024-12-16 17:52:49 +01:00
<router-link :to="'/' + step.uri" class="link-full">{{
step.title
}}</router-link>
</h3>
2024-12-16 17:52:49 +01:00
<time class="font-medium text-sm py-8" :datetime="step.date">{{
step.date
}}</time>
<p>{{ step.description }}</p>
</header>
2024-12-16 17:52:49 +01:00
<img
:src="step.files[0].url"
alt=""
loading="lazy"
class="rounded-lg mt-16"
/>
</div>
2024-12-11 15:05:40 +01:00
</template>
2024-11-21 18:11:30 +01:00
<template v-else></template>
2024-11-18 16:21:07 +01:00
</div>
</section>
</template>
2024-09-26 19:14:20 +02:00
<script setup>
import dayjs from "dayjs";
import "dayjs/locale/fr";
2024-10-16 15:32:24 +02:00
import { usePageStore } from "../../stores/page";
import { computed } from "vue";
2024-11-21 11:27:14 +01:00
import { useProjectStore } from "../../stores/project";
2024-12-19 19:27:38 +01:00
import { useRouter } from "vue-router";
import { useBriefStore } from "../../stores/brief";
2024-09-26 19:14:20 +02:00
const { step } = defineProps({
step: Object,
});
2024-10-16 15:32:24 +02:00
2024-10-23 11:32:51 +02:00
const emit = defineEmits(["update:file"]);
2024-12-19 19:27:38 +01:00
const router = useRouter();
2024-10-16 15:32:24 +02:00
dayjs.locale("fr");
const { page } = usePageStore();
2024-12-19 19:27:38 +01:00
const { addPdf } = useBriefStore();
2024-11-21 11:27:14 +01:00
const { setStatus } = useProjectStore();
2024-10-16 15:32:24 +02:00
2024-10-16 17:32:15 +02:00
const steps = page.steps.map((item) => {
return item.value;
});
2024-10-16 15:32:24 +02:00
const mergedFiles = computed(() => {
if (step.id !== "virtualSample") return false;
const staticFiles = step.files?.static ?? [];
const dynamicFiles = step.files?.dynamic ?? [];
return [...staticFiles, ...dynamicFiles];
});
function getFrontView(track) {
if (track.files.length === 1) return track.files[0];
const xMax = parseInt(
track.files[track.files.length - 1].name.split("_")[1].split(".")[0]
);
const xFrontView = (xMax + 1) / 2;
const extension = track.files[0].name.split(".")[1];
const frontViewName = "0_" + xFrontView + "." + extension;
const frontView = track.files.find((file) => file.name === frontViewName);
return frontView;
}
2024-12-19 19:27:38 +01:00
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");
}
2024-09-26 19:14:20 +02:00
</script>
<style scoped>
.physical-sample header {
color: var(--color-white);
2024-12-16 17:52:49 +01:00
background: linear-gradient(
90deg,
hsla(0, 0%, 10%, 0.5) 0%,
hsla(0, 0%, 10%, 0.9) 50%,
hsla(0, 0%, 10%, 0.9) 100%
),
var(--cover), var(--color-black);
background-repeat: no-repeat;
background-size: cover;
}
.physical-sample header > * {
padding-inline: var(--space-16);
}
.physical-sample header h3 {
position: initial;
}
</style>