extended-brief working
This commit is contained in:
parent
984c8b7737
commit
b99c05062f
20 changed files with 38 additions and 13 deletions
105
src/components/project/brief/Header.vue
Normal file
105
src/components/project/brief/Header.vue
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<template>
|
||||
<header
|
||||
class="project-details | flex items-start | bg-white | rounded-2xl | p-16 | w-full"
|
||||
>
|
||||
<div class="project-details__description | flex-1">
|
||||
<label
|
||||
for="project-description"
|
||||
class="flex | text-sm text-grey-700 | mb-8"
|
||||
>Description du projet</label
|
||||
>
|
||||
<textarea
|
||||
name="project-description"
|
||||
id="project-description"
|
||||
placeholder="Ajoutez une description générale de votre projet…"
|
||||
rows="3"
|
||||
class="border border-grey-200 | rounded-xl | p-16 | w-full"
|
||||
v-model="page.content.description"
|
||||
@input="saveDescription()"
|
||||
></textarea>
|
||||
</div>
|
||||
<fieldset class="project-details__filters | flex-1">
|
||||
<legend class="text-sm text-grey-700 | mb-8">Filtrer par tags</legend>
|
||||
<div class="flex" style="gap: var(--space-8)">
|
||||
<button
|
||||
class="btn btn--sm btn--grey"
|
||||
id="all"
|
||||
:aria-pressed="selectedTags.length === 0"
|
||||
role="switch"
|
||||
@click="clearTags()"
|
||||
>
|
||||
Voir tout
|
||||
</button>
|
||||
<template v-for="tag in page.tags" :key="tag">
|
||||
<input
|
||||
class="sr-only"
|
||||
type="checkbox"
|
||||
:id="`${tag}`"
|
||||
:name="`${tag}`"
|
||||
:value="`${tag}`"
|
||||
v-model="localSelectedTags"
|
||||
/>
|
||||
<label class="btn btn--sm btn--primary" :for="`${tag}`">{{
|
||||
StringUtils.toPascalCase(tag)
|
||||
}}</label>
|
||||
</template>
|
||||
</div>
|
||||
</fieldset>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from "vue";
|
||||
import { usePageStore } from "../../../stores/page";
|
||||
import StringUtils from "../../../utils/string";
|
||||
import debounce from "lodash/debounce";
|
||||
|
||||
const { selectedTags } = defineProps({
|
||||
selectedTags: Array,
|
||||
});
|
||||
|
||||
const { page } = usePageStore();
|
||||
const emit = defineEmits(["update:selectedTags"]);
|
||||
|
||||
const localSelectedTags = ref([...selectedTags]);
|
||||
|
||||
watch(localSelectedTags, updateSelectedTags);
|
||||
|
||||
function updateSelectedTags(tags) {
|
||||
emit("update:selectedTags", tags);
|
||||
}
|
||||
|
||||
const isWaitingForSave = ref(false);
|
||||
|
||||
const saveDescription = debounce(() => {
|
||||
if (!isWaitingForSave.value) {
|
||||
isWaitingForSave.value = true;
|
||||
const headers = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
pageUri: page.uri,
|
||||
properties: [
|
||||
{
|
||||
name: "description",
|
||||
value: page.content.description,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
fetch("/save-page.json", headers)
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
isWaitingForSave.value = false;
|
||||
console.log(json);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Erreur lors de la sauvegarde :", error);
|
||||
isWaitingForSave.value = false;
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
function clearTags() {
|
||||
localSelectedTags.value = [];
|
||||
}
|
||||
</script>
|
||||
170
src/components/project/brief/ImageDetailsModal.vue
Normal file
170
src/components/project/brief/ImageDetailsModal.vue
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
<template>
|
||||
<Dialog
|
||||
v-model:visible="isOpen"
|
||||
id="image-details"
|
||||
modal
|
||||
header="Détails de l’image"
|
||||
class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden"
|
||||
>
|
||||
<img :src="image.url" alt="" class="bg-grey-200" loading="lazy" />
|
||||
<div class="flex flex-col | p-32" style="--row-gap: var(--space-32)">
|
||||
<fieldset class="image__tags">
|
||||
<legend class="text-sm text-grey-700 | mb-8">Tags</legend>
|
||||
<div class="flex" style="gap: var(--space-8)">
|
||||
<template v-for="(pageTag, index) in page.tags" :key="index">
|
||||
<input
|
||||
class="sr-only"
|
||||
type="checkbox"
|
||||
:id="pageTag + '-image'"
|
||||
:name="pageTag + '-image'"
|
||||
:value="pageTag"
|
||||
@change="saveTags()"
|
||||
v-model="image.tags"
|
||||
/>
|
||||
<label class="btn btn--sm btn--primary" :for="pageTag + '-image'">{{
|
||||
StringUtils.toPascalCase(pageTag)
|
||||
}}</label>
|
||||
</template>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="image__description | w-full">
|
||||
<label
|
||||
for="image-description"
|
||||
class="flex | text-sm text-grey-700 | mb-8"
|
||||
>Description de l’image</label
|
||||
>
|
||||
<textarea
|
||||
name="image-description"
|
||||
id="image-description"
|
||||
placeholder="Ajoutez une description à l’image…"
|
||||
class="border border-grey-200 | rounded-xl | p-16 | w-full"
|
||||
v-model="image.description"
|
||||
@input="saveDescription()"
|
||||
></textarea>
|
||||
</div>
|
||||
<button
|
||||
data-icon="delete"
|
||||
class="btn btn--black-10 | ml-auto mt-auto"
|
||||
@click="remove()"
|
||||
>
|
||||
Supprimer cette image
|
||||
</button>
|
||||
</div>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from "vue";
|
||||
import { usePageStore } from "../../../stores/page";
|
||||
import StringUtils from "../../../utils/string";
|
||||
import Dialog from "primevue/dialog";
|
||||
import debounce from "lodash/debounce";
|
||||
|
||||
const { imageDetails } = defineProps({
|
||||
imageDetails: Object,
|
||||
});
|
||||
|
||||
const emit = defineEmits(["close", "remove"]);
|
||||
|
||||
const isOpen = ref(true);
|
||||
watch(isOpen, () => {
|
||||
emit("close");
|
||||
});
|
||||
|
||||
const { page } = usePageStore();
|
||||
|
||||
const image = ref(imageDetails);
|
||||
|
||||
function saveTags() {
|
||||
const headers = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
pageUri: page.uri,
|
||||
fileName: image.value.name,
|
||||
properties: [
|
||||
{
|
||||
name: "tags",
|
||||
value: image.value.tags,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
fetch("/save-file.json", headers)
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
console.log(json);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Erreur lors de la sauvegarde :", error);
|
||||
});
|
||||
}
|
||||
|
||||
const saveDescription = debounce(() => {
|
||||
const headers = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
pageUri: page.uri,
|
||||
fileName: image.value.name,
|
||||
properties: [
|
||||
{
|
||||
name: "description",
|
||||
value: image.value.description,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
fetch("/save-file.json", headers)
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
console.log(json);
|
||||
emit("");
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Erreur lors de la sauvegarde :", error);
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
function remove() {
|
||||
const headers = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
pageUri: page.uri,
|
||||
fileName: image.value.name,
|
||||
}),
|
||||
};
|
||||
fetch("/remove-file.json", headers)
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
console.log(json);
|
||||
emit("remove", image.value);
|
||||
isOpen.value = false;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Erreur lors de la suppression :", error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#image-details {
|
||||
width: min(100vw - var(--gutter) * 2, 62.5rem);
|
||||
height: min(100vh - var(--gutter) * 2, 50rem);
|
||||
flex-direction: row !important;
|
||||
}
|
||||
#image-details [data-pc-section="header"] {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
right: 0;
|
||||
z-index: 1102;
|
||||
padding: 1.5rem var(--space-32);
|
||||
}
|
||||
#image-details [data-pc-section="content"] {
|
||||
display: flex;
|
||||
}
|
||||
#image-details [data-pc-section="content"] > * {
|
||||
width: 50%;
|
||||
}
|
||||
#image-details [data-pc-section="content"] > div {
|
||||
padding-top: 5rem;
|
||||
}
|
||||
</style>
|
||||
127
src/components/project/brief/Images.vue
Normal file
127
src/components/project/brief/Images.vue
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<template>
|
||||
<section class="h-full | flex flex-col" style="--row-gap: var(--space-32)">
|
||||
<Header
|
||||
:selectedTags="selectedTags"
|
||||
@update:selectedTags="changeSelectedTags"
|
||||
/>
|
||||
<div class="h-full | masonry">
|
||||
<button
|
||||
data-icon="upload"
|
||||
class="flex flex-col | bg-white | border border-grey-200 | text-grey-800 | font-medium | rounded-2xl"
|
||||
@click="isAddImagesModalOpen = true"
|
||||
>
|
||||
Ajouter une ou plusieurs images
|
||||
</button>
|
||||
<template v-for="image in page.moodboard" :key="image.uri">
|
||||
<figure
|
||||
v-if="
|
||||
selectedTags.length === 0 ||
|
||||
selectedTags.some((pageSelectedTag) =>
|
||||
image.tags.includes(pageSelectedTag)
|
||||
)
|
||||
"
|
||||
class="image"
|
||||
:class="{ 'has-description': image.description.length > 0 }"
|
||||
@click="imageDetails = image"
|
||||
>
|
||||
<span v-for="tag in image.tags" class="tag | btn btn--sm">{{
|
||||
tag
|
||||
}}</span>
|
||||
<img :src="image.url" alt="" />
|
||||
</figure>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<AddImagesModal
|
||||
v-if="isAddImagesModalOpen"
|
||||
:isAddImagesModalOpen="isAddImagesModalOpen"
|
||||
@close="isAddImagesModalOpen = false"
|
||||
/>
|
||||
<ImageDetailsModal
|
||||
v-if="imageDetails"
|
||||
:imageDetails="imageDetails"
|
||||
@close="imageDetails = null"
|
||||
@remove="removeImage"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Header from "./Header.vue";
|
||||
import { usePageStore } from "../../../stores/page";
|
||||
import { ref } from "vue";
|
||||
import ImageDetailsModal from "./ImageDetailsModal.vue";
|
||||
import AddImagesModal from "./add-images-modal/AddImagesModal.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
|
||||
const selectedTags = ref([]);
|
||||
const imageDetails = ref(null);
|
||||
const isAddImagesModalOpen = ref(false);
|
||||
|
||||
function changeSelectedTags(newTags) {
|
||||
selectedTags.value = newTags;
|
||||
}
|
||||
|
||||
function removeImage(target) {
|
||||
console.log("remove", target);
|
||||
page.value.moodboard = page.value.moodboard.filter(
|
||||
(image) => image.uuid !== target.uuid
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
fieldset {
|
||||
appearance: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
button[data-icon="upload"] {
|
||||
padding: 6.875rem 4.875rem;
|
||||
}
|
||||
[data-pc-name="fileupload"] button:hover {
|
||||
background: var(--color-primary-10);
|
||||
border-color: var(--color-primary-20);
|
||||
color: var(--color-primary-100);
|
||||
}
|
||||
input[type="file"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[role="dialog"] {
|
||||
position: relative;
|
||||
}
|
||||
[data-pc-section="mask"] {
|
||||
background-color: var(--color-black-50);
|
||||
}
|
||||
[data-pc-section="header"] {
|
||||
height: var(--space-40);
|
||||
}
|
||||
[data-pc-section="title"] {
|
||||
font-weight: 500;
|
||||
font-size: var(--text-lg);
|
||||
}
|
||||
[data-pc-name="pcclosebutton"] {
|
||||
position: absolute;
|
||||
top: var(--space-16);
|
||||
right: var(--space-16);
|
||||
padding: 0.625rem;
|
||||
width: var(--space-40);
|
||||
height: var(--space-40);
|
||||
}
|
||||
[data-pc-name="pcclosebutton"] svg {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
}
|
||||
[data-pc-name="pcclosebutton"] span {
|
||||
display: none;
|
||||
}
|
||||
[data-pc-section="content"] {
|
||||
flex-grow: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
23
src/components/project/brief/Intro.vue
Normal file
23
src/components/project/brief/Intro.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<template>
|
||||
<section class="h-full | grid-center">
|
||||
<div
|
||||
class="card | items-center | text-center | w-full max-w"
|
||||
style="--row-gap: var(--space-32); --max-w: 27.5rem"
|
||||
>
|
||||
<h2 class="font-serif text-lg">Créez votre premier brief de projet !</h2>
|
||||
<p class="text-grey-700">
|
||||
Bienvenu à votre nouvel espace de projet. <br />Commencez par consulter
|
||||
les inspirations <br />et partagez vos intentions !
|
||||
</p>
|
||||
<button
|
||||
class="btn | w-full"
|
||||
@click="emit('update:step', 'ModeSelection')"
|
||||
>
|
||||
Commencer
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
<script setup>
|
||||
const emit = defineEmits(["update:step"]);
|
||||
</script>
|
||||
131
src/components/project/brief/ModeSelection.vue
Normal file
131
src/components/project/brief/ModeSelection.vue
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
<template>
|
||||
<section
|
||||
class="h-full | flex flex-col justify-center items-center | mx-auto | max-w"
|
||||
style="--max-w: 42rem; --row-gap: var(--space-32)"
|
||||
>
|
||||
<div class="flex items-baseline">
|
||||
<div
|
||||
@click="emit('update:step', 'Images')"
|
||||
class="card card--cta | flex-1 | h-full"
|
||||
style="--padding: var(--space-32); --row-gap: var(--space-32)"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="100"
|
||||
height="100"
|
||||
viewBox="0 0 100 100"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
stroke="currentColor"
|
||||
stroke-width="5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M92.8571 46.4292H64.2857C62.3133 46.4292 60.7143 48.0282 60.7143 50.0006V92.8577C60.7143 94.8302 62.3133 96.4292 64.2857 96.4292H92.8571C94.8296 96.4292 96.4286 94.8302 96.4286 92.8577V50.0006C96.4286 48.0282 94.8296 46.4292 92.8571 46.4292Z"/>
|
||||
<path d="M92.8571 3.57202H64.2857C62.3133 3.57202 60.7143 5.171 60.7143 7.14345V21.5006C60.7143 23.473 62.3133 25.072 64.2857 25.072H92.8571C94.8296 25.072 96.4286 23.473 96.4286 21.5006V7.14345C96.4286 5.171 94.8296 3.57202 92.8571 3.57202Z"/>
|
||||
<path d="M35.7143 3.57202H7.14284C5.17039 3.57202 3.57141 5.171 3.57141 7.14345V50.0006C3.57141 51.973 5.17039 53.572 7.14284 53.572H35.7143C37.6867 53.572 39.2857 51.973 39.2857 50.0006V7.14345C39.2857 5.171 37.6867 3.57202 35.7143 3.57202Z"/>
|
||||
<path d="M35.7143 74.9291H7.14284C5.17039 74.9291 3.57141 76.5281 3.57141 78.5005V92.8577C3.57141 94.8301 5.17039 96.4291 7.14284 96.4291H35.7143C37.6867 96.4291 39.2857 94.8301 39.2857 92.8577V78.5005C39.2857 76.5281 37.6867 74.9291 35.7143 74.9291Z"/>
|
||||
</svg>
|
||||
<h2 class="font-serif text-lg">Créer via la plateforme</h2>
|
||||
<p class="text-sm text-grey-700">Ajouter différents éléments tels que des images et du texte sur la plateforme afin de créer votre brief.</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="card card--cta | flex-1 | h-full"
|
||||
style="--padding: var(--space-32); --row-gap: var(--space-32)"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="100"
|
||||
height="100"
|
||||
viewBox="0 0 100 100"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
stroke="currentColor"
|
||||
stroke-width="5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M3.57153 75.0001V82.143C3.57153 85.9318 5.07663 89.5654 7.75572 92.2445C10.4348 94.9236 14.0684 96.4287 17.8572 96.4287H82.143C85.9318 96.4287 89.5654 94.9236 92.2445 92.2445C94.9236 89.5654 96.4287 85.9318 96.4287 82.143V75.0001M28.5715 28.5715L50.0001 3.57153M50.0001 3.57153L71.4287 28.5715M50.0001 3.57153V67.8573"/>
|
||||
</svg>
|
||||
<label class="font-serif text-lg" for="upload-pdf">
|
||||
Ajouter un PDF
|
||||
<input
|
||||
id="upload-pdf"
|
||||
type="file"
|
||||
@change="addPdf($event)"
|
||||
accept="application/pdf"
|
||||
ref="pdfInput"
|
||||
hidden
|
||||
/>
|
||||
</label>
|
||||
<p class="text-sm text-grey-700">Vous avez déjà constitué votre brief en amont et souhaitez directement l’importer.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="card | bg-grey-200 | items-center | text-center | w-full"
|
||||
style="--padding: var(--space-32); --row-gap: var(--space-16)"
|
||||
>
|
||||
<h2 class="font-serif text-lg">Qu’est ce que le brief ?</h2>
|
||||
<p class="text-sm text-grey-700">
|
||||
Le brief est un outil créatif qui permet de définir les perspectives
|
||||
esthétiques de votre projet.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { usePageStore } from "../../../stores/page";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const emit = defineEmits("update:step");
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
const pdfInput = ref(null);
|
||||
|
||||
async function addPdf(event) {
|
||||
const file = event.target.files[0];
|
||||
|
||||
if (file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
"/upload-pdf.json?pageUri=" + page.value.uri,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
console.log("File uploaded successfully.");
|
||||
page.value = result;
|
||||
location.href = location.origin + "/" + page.value.parent;
|
||||
} else {
|
||||
console.error("Error uploading file:", result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Request failed:", error);
|
||||
}
|
||||
} else {
|
||||
console.error("No file selected.");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
label[for="upload-pdf"]::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
300
src/components/project/brief/PdfViewer.vue
Normal file
300
src/components/project/brief/PdfViewer.vue
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
<template>
|
||||
<Dialog
|
||||
id="add-pdf"
|
||||
v-model:visible="isOpen"
|
||||
modal
|
||||
:draggable="false"
|
||||
header="Titre du PDF"
|
||||
class="dialog"
|
||||
:class="{ 'with-comments': isCommentsOpen }"
|
||||
:closeOnEscape="true"
|
||||
>
|
||||
<template #header>
|
||||
<a class="btn">Valider et envoyer le brief</a>
|
||||
<h2 class="font-serif text-lg">Titre du PDF</h2>
|
||||
</template>
|
||||
<div id="vpv-container">
|
||||
<VPdfViewer
|
||||
:darkMode="true"
|
||||
:initialThumbnailsVisible="true"
|
||||
:src="openedFile.url"
|
||||
local="fr_FR"
|
||||
@loaded="onPdfLoaded"
|
||||
/>
|
||||
<button
|
||||
id="toggle-comments"
|
||||
:aria-pressed="isCommentsOpen"
|
||||
class="btn btn--transparent btn--outline"
|
||||
data-icon="comment"
|
||||
@click="isCommentsOpen = !isCommentsOpen"
|
||||
>
|
||||
<span class="sr-only">Afficher les commentaires</span>
|
||||
</button>
|
||||
<Comments v-if="isCommentsOpen" />
|
||||
</div>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Dialog from "primevue/dialog";
|
||||
import Comments from "../../comments/Comments.vue";
|
||||
import { VPdfViewer, useLicense } from "@vue-pdf-viewer/viewer";
|
||||
import { ref, watch } from "vue";
|
||||
import { useDialogStore } from "../../../stores/dialog";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const dialog = useDialogStore();
|
||||
const { openedFile, comments } = storeToRefs(useDialogStore());
|
||||
|
||||
openedFile.value = route.query.fileIndex
|
||||
? dialog.content.files[route.query.fileIndex]
|
||||
: dialog.content.files[0];
|
||||
|
||||
const licenseKey = import.meta.env.VITE_VPV_LICENSE;
|
||||
useLicense({ licenseKey });
|
||||
|
||||
// Variables
|
||||
const isOpen = ref(true);
|
||||
watch(isOpen, (newValue) => {
|
||||
router.push({ name: route.name });
|
||||
});
|
||||
const isCommentsOpen = ref(false);
|
||||
const currentPageIndex = ref(1);
|
||||
|
||||
watch(isCommentsOpen, (newVal) => {
|
||||
if (newVal) {
|
||||
setCommentBubbles();
|
||||
} else {
|
||||
removeCommentBubbles();
|
||||
}
|
||||
});
|
||||
|
||||
watch(openedFile, (newVal) => {
|
||||
removeCommentBubbles();
|
||||
if (newVal.comments) {
|
||||
setCommentBubbles();
|
||||
}
|
||||
});
|
||||
|
||||
// Functions
|
||||
const onPdfLoaded = () => {
|
||||
const wrapper = document.querySelector(".vpv-pages-inner-container");
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry, index) => {
|
||||
if (entry.intersectionRatio > 0.5) {
|
||||
currentPageIndex.value = parseInt(
|
||||
entry.target.getAttribute("aria-label").split(" ")[1]
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
{
|
||||
root: wrapper,
|
||||
threshold: [0.5],
|
||||
}
|
||||
);
|
||||
|
||||
const observePages = () => {
|
||||
const pages = document.querySelectorAll(".vpv-page-inner-container");
|
||||
pages.forEach((page) => {
|
||||
if (!page.__observed__) {
|
||||
observer.observe(page);
|
||||
page.__observed__ = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const mutationObserver = new MutationObserver(() => {
|
||||
observePages();
|
||||
});
|
||||
|
||||
if (wrapper) {
|
||||
mutationObserver.observe(wrapper, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
observePages();
|
||||
};
|
||||
|
||||
function setCommentBubbles() {
|
||||
if (!comments.value) return;
|
||||
comments.value.forEach((comment) => {
|
||||
const bubble = document.createElement("a");
|
||||
|
||||
bubble.classList.add("comment-bubble");
|
||||
bubble.style.left = comment.position.x + "%";
|
||||
bubble.style.top = comment.position.y + "%";
|
||||
bubble.href = "#comment-" + comment.id;
|
||||
|
||||
const container = document.querySelector(
|
||||
`.vpv-page-inner-container[aria-label="page ${comment.position.pageIndex}"] .page-inner-container`
|
||||
);
|
||||
|
||||
container.appendChild(bubble);
|
||||
|
||||
setTimeout(() => {
|
||||
bubble.addEventListener("mouseenter", () => highlight(comment));
|
||||
bubble.addEventListener("mouseleave", () => unhighlight(comment));
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function highlight(comment) {
|
||||
const target = document.querySelector("#comment-" + comment.id);
|
||||
target.classList.add("highlight");
|
||||
}
|
||||
function unhighlight(comment) {
|
||||
const target = document.querySelector("#comment-" + comment.id);
|
||||
target.classList.remove("highlight");
|
||||
}
|
||||
|
||||
function removeCommentBubbles() {
|
||||
document.querySelectorAll(".comment-bubble").forEach((bubble) => {
|
||||
bubble.parentNode.removeChild(bubble);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.comment-bubble {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
background: url("/assets/svg/comment-bubble.svg") no-repeat !important;
|
||||
cursor: pointer !important;
|
||||
z-index: 999;
|
||||
}
|
||||
#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>
|
||||
|
||||
<style scoped>
|
||||
:deep(.vpv-variables) {
|
||||
/* Base styles */
|
||||
--vpv-base-radius: var(--rounded-xl);
|
||||
/* Viewer container */
|
||||
--vpv-container-width-sm: 48rem;
|
||||
/* Toolbar */
|
||||
--vpv-toolbar-size: 4.5rem;
|
||||
}
|
||||
:deep(.vpv-variables.vpv-variables__dark) {
|
||||
/* Base styles */
|
||||
--vpv-base-border-color: var(--color-grey-700);
|
||||
/* Viewer container */
|
||||
--vpv-container-border-color: var(--vpv-base-border-color);
|
||||
/* Loader */
|
||||
--vpv-loader-backdrop-color: rgba(0, 0, 0, 0.8);
|
||||
/* Toolbar */
|
||||
--vpv-toolbar-background-color: var(--color-white-10);
|
||||
--vpv-toolbar-color: white;
|
||||
--vpv-toolbar-border-color: var(--vpv-base-border-color);
|
||||
/* Sidebar */
|
||||
--vpv-sidebar-content-background-color: var(--color-white-10);
|
||||
--vpv-sidebar-content_thumbnail-focused-border-color: var(--color-white-20);
|
||||
/* Drop file mask */
|
||||
--vpv-drop-zone-background: #1c2024;
|
||||
--vpv-drop-zone-border: #434c56;
|
||||
/* PDF Pages Content*/
|
||||
--vpv-pages-container-background: black;
|
||||
/* Popover */
|
||||
--vpv-popover-background-color: black;
|
||||
--vpv-popover-color: var(--color-white);
|
||||
--vpv-popover-border-color: transparent;
|
||||
/* Menu Dropdown */
|
||||
--vpv-dropdown-menu-content-background: #181818;
|
||||
--vpv-dropdown-menu-content-menu-hover-background: var(--color-white-10);
|
||||
--vpv-dropdown-menu-content-separator-background: var(--color-white-10);
|
||||
--vpv-dropdown-menu-content-border-color: var(--color-white-10);
|
||||
--vpv-dropdown-separator: var(--color-white-10);
|
||||
/* Search Input */
|
||||
--vpv-input-background-color: transparent;
|
||||
--vpv-input-border-color: var(--color-white);
|
||||
--vpv-input-placeholder-color: #596673;
|
||||
/* Modal of PDF Properties */
|
||||
--vpv-properties-content-background: var(
|
||||
--vpv-dropdown-menu-content-background
|
||||
);
|
||||
--vpv-properties-content-secondary-color: #c6ccd2;
|
||||
--vpv-properties-content-color: var(--vpv-toolbar-color);
|
||||
--vpv-properties-separator: var(--vpv-dropdown-separator);
|
||||
--vpv-properties-header: white;
|
||||
/* Modal of Print Progress */
|
||||
--vpv-print-progress-background: var(--vpv-dropdown-menu-content-background);
|
||||
/* Tooltip */
|
||||
--vpv-tooltip-background: #181818;
|
||||
--vpv-tooltip-color: white;
|
||||
--vpv-tooltip-border-color: var(--color-black);
|
||||
/* Outline */
|
||||
--vpv-outline-color: var(--color-white-10);
|
||||
}
|
||||
|
||||
:deep(.vpv-container) {
|
||||
border-top-left-radius: 0 !important;
|
||||
border-top-right-radius: 0 !important;
|
||||
}
|
||||
:deep(.vpv-body-wrapper),
|
||||
:deep(.vpv-container .vpv-sidebar-wrapper) {
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: var(--vpv-toolbar-size) !important;
|
||||
}
|
||||
:deep(.vpv-splitter) {
|
||||
max-width: 0;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
:deep(.vpv-container .vpv-sidebar-wrapper__opened) {
|
||||
max-width: 9rem;
|
||||
}
|
||||
:deep(.vpv-sidebar-features) {
|
||||
display: none;
|
||||
}
|
||||
:deep(.pdf-thumbnail-wrapper .pdf-thumbnail img),
|
||||
:deep(.pdf-thumbnail-wrapper .pdf-thumbnail .placeholder) {
|
||||
border-radius: var(--rounded-md);
|
||||
}
|
||||
|
||||
/* Toolbar */
|
||||
:deep(.vpv-container .vpv-toolbar-wrapper) {
|
||||
border-bottom-width: 0;
|
||||
border-top-width: 1px;
|
||||
padding-left: 1rem !important;
|
||||
}
|
||||
:deep(.vpv-toolbar-wrapper) {
|
||||
top: unset !important;
|
||||
bottom: 0 !important;
|
||||
}
|
||||
:deep(.vpv-toolbar-start .vpv-toolbar-btn) {
|
||||
display: none;
|
||||
}
|
||||
:deep(.vpv-toolbar-start::before) {
|
||||
content: "Page";
|
||||
}
|
||||
:deep(.vpv-input) {
|
||||
border-radius: var(--rounded-sm) !important;
|
||||
max-width: 1.5rem !important;
|
||||
}
|
||||
:deep(.vpv-input ~ span) {
|
||||
color: var(--color-grey-400);
|
||||
}
|
||||
:deep(.vpv-toolbar-end) {
|
||||
padding-right: 4rem;
|
||||
}
|
||||
:deep(.vpv-toolbar-end > button:nth-child(1)),
|
||||
:deep(.vpv-toolbar-end > button:nth-child(3)),
|
||||
:deep(.vpv-toolbar-end > button:nth-child(4)) {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
147
src/components/project/brief/add-images-modal/AddImagesModal.vue
Normal file
147
src/components/project/brief/add-images-modal/AddImagesModal.vue
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<template>
|
||||
<Dialog
|
||||
id="add-images"
|
||||
v-model:visible="isOpen"
|
||||
modal
|
||||
header="Ajouter des images"
|
||||
class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden | p-32"
|
||||
>
|
||||
<div class="with-sidebar | h-full">
|
||||
<nav>
|
||||
<ul>
|
||||
<li
|
||||
v-for="tab in tabs"
|
||||
:class="{ active: activeTabId === tab.id }"
|
||||
@click="activeTabId = tab.id"
|
||||
>
|
||||
{{ tab.name }}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div
|
||||
class="with-sidebar | h-full"
|
||||
data-side="right"
|
||||
style="--sidebar-width: 26rem; gap: var(--gap)"
|
||||
>
|
||||
<div class="bg-grey-50 | rounded-2xl | p-8 | overflow-y">
|
||||
<template v-for="tab in tabs" :key="tab.name">
|
||||
<component
|
||||
@add-images="addImages"
|
||||
:is="tab.component"
|
||||
:id="tab.id"
|
||||
:class="{ hidden: activeTab.name !== tab.name }"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
<ImagesEditPanel :images="images" />
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
<Dialog
|
||||
id="delete-image"
|
||||
v-model:visible="deleteIsOpen"
|
||||
modal
|
||||
header="Êtes-vous sûr de vouloir supprimer cette image ?"
|
||||
class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden | text-center | w-full max-w | p-16 pt-32"
|
||||
style="--row-gap: var(--space-32); --max-w: 40rem"
|
||||
>
|
||||
<p class="text-grey-700 | px-16">
|
||||
Si vous supprimez cette image, celle-ci disparaîtra de votre brief ainsi
|
||||
que toutes les informations qui lui sont attribuées.
|
||||
</p>
|
||||
<template #footer>
|
||||
<button class="btn btn--secondary | flex-1" @click="deleteIsOpen = false">
|
||||
Annuler
|
||||
</button>
|
||||
<button class="btn | flex-1" @click="">Supprimer</button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Dialog from "primevue/dialog";
|
||||
import ImagesEditPanel from "./ImagesEditPanel.vue";
|
||||
import { ref, watch } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useAddImagesModalStore } from "../../../../stores/addImagesModal";
|
||||
|
||||
const { isAddImagesModalOpen } = defineProps({
|
||||
isAddImagesModalOpen: Boolean,
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:isAddImagesModalOpen"]);
|
||||
const { activeTab, activeTabId, tabs } = storeToRefs(useAddImagesModalStore());
|
||||
|
||||
const isOpen = ref(isAddImagesModalOpen);
|
||||
watch(isOpen, () => {
|
||||
emit("close");
|
||||
});
|
||||
|
||||
const deleteIsOpen = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#add-images {
|
||||
--sidebar-width: 12.5rem;
|
||||
width: min(100vw - var(--gutter) * 2, 100rem);
|
||||
height: min(100vh - var(--gutter) * 2, 60rem);
|
||||
padding-top: var(--space-16);
|
||||
row-gap: var(--space-32);
|
||||
}
|
||||
#add-images [data-pc-section="content"] {
|
||||
height: calc(100% - 3.75rem);
|
||||
}
|
||||
#add-images nav li {
|
||||
position: relative;
|
||||
height: var(--space-48);
|
||||
border-left: 1px solid var(--color-grey-400);
|
||||
padding: var(--space-12) var(--space-16);
|
||||
color: var(--color-grey-400);
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
#add-images nav li:hover,
|
||||
#add-images nav li.active {
|
||||
color: var(--color-grey-800);
|
||||
border-left-color: var(--color-grey-800);
|
||||
}
|
||||
#add-images nav li.active::before {
|
||||
content: "";
|
||||
width: 2px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -1px;
|
||||
bottom: 0;
|
||||
background: var(--color-grey-800);
|
||||
}
|
||||
#add-images [data-pc-name="fileupload"] button {
|
||||
padding: 3rem;
|
||||
aspect-ratio: 1/1;
|
||||
}
|
||||
#add-images .image {
|
||||
aspect-ratio: 1/1;
|
||||
border-radius: var(--rounded-xl);
|
||||
}
|
||||
#add-images .image img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#delete-image [data-pc-section="footer"] {
|
||||
display: flex;
|
||||
gap: var(--space-16);
|
||||
margin-top: var(--space-32);
|
||||
}
|
||||
#delete-image [data-pc-name="pcclosebutton"] {
|
||||
display: none;
|
||||
}
|
||||
#delete-image_header {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--text-lg);
|
||||
}
|
||||
|
||||
.with-sidebar[data-side="right"] > * {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
<template>
|
||||
<div
|
||||
class="flex flex-col items-start | bg-grey-50 | rounded-2xl | w-full | p-8"
|
||||
>
|
||||
<Accordion
|
||||
value="0"
|
||||
class="flex flex-col | w-full"
|
||||
style="--row-gap: var(--space-8)"
|
||||
>
|
||||
<AccordionPanel
|
||||
v-for="(image, index) in images"
|
||||
:key="index + 1"
|
||||
:value="index"
|
||||
class="w-full | bg-white | rounded-xl | p-12 pt-8"
|
||||
>
|
||||
<AccordionHeader>
|
||||
<span class="badge">{{ index + 1 }}</span>
|
||||
</AccordionHeader>
|
||||
<AccordionContent>
|
||||
<div class="image-details__description | my-16">
|
||||
<label
|
||||
for="image-description"
|
||||
class="flex | text-sm text-grey-700 | mb-8"
|
||||
>Description</label
|
||||
>
|
||||
<textarea
|
||||
name="image-description"
|
||||
id="image-description"
|
||||
placeholder="Ajoutez une description à cette image…"
|
||||
rows="3"
|
||||
class="border border-grey-200 | rounded-xl | p-16 | w-full"
|
||||
v-model="image.description"
|
||||
></textarea>
|
||||
</div>
|
||||
<fieldset class="image-details__filters | flex-1">
|
||||
<legend class="text-sm text-grey-700 | mb-8">
|
||||
Sélectionner un ou plusieurs tags
|
||||
</legend>
|
||||
<div class="flex" style="gap: var(--space-8)">
|
||||
<template v-for="tag in page.tags" :key="tag">
|
||||
<input
|
||||
class="sr-only"
|
||||
type="checkbox"
|
||||
:id="`${tag}-image-edit`"
|
||||
:name="`${tag}-image-edit`"
|
||||
:value="`${tag}`"
|
||||
v-model="image.tags"
|
||||
/>
|
||||
<label
|
||||
class="btn btn--sm btn--primary"
|
||||
:for="`${tag}-image-edit`"
|
||||
>{{ StringUtils.toPascalCase(tag) }}</label
|
||||
>
|
||||
</template>
|
||||
</div>
|
||||
</fieldset>
|
||||
</AccordionContent>
|
||||
</AccordionPanel>
|
||||
<template #collapseicon>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
style="transform: rotate(180deg)"
|
||||
>
|
||||
<path
|
||||
d="M1.875 6.0625L9.5625 13.75C9.61861 13.8098 9.68638 13.8574 9.76163 13.89C9.83688 13.9226 9.918 13.9394 10 13.9394C10.082 13.9394 10.1631 13.9226 10.2384 13.89C10.3136 13.8574 10.3814 13.8098 10.4375 13.75L18.125 6.0625"
|
||||
stroke="#5E6060"
|
||||
stroke-width="1.25"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
<template #expandicon>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M1.875 6.0625L9.5625 13.75C9.61861 13.8098 9.68638 13.8574 9.76163 13.89C9.83688 13.9226 9.918 13.9394 10 13.9394C10.082 13.9394 10.1631 13.9226 10.2384 13.89C10.3136 13.8574 10.3814 13.8098 10.4375 13.75L18.125 6.0625"
|
||||
stroke="#5E6060"
|
||||
stroke-width="1.25"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
</Accordion>
|
||||
<button class="btn | w-full | mt-auto" @click="addImagesToBrief()">
|
||||
Ajouter les images sélectionnées
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import Accordion from "primevue/accordion";
|
||||
import AccordionPanel from "primevue/accordionpanel";
|
||||
import AccordionHeader from "primevue/accordionheader";
|
||||
import AccordionContent from "primevue/accordioncontent";
|
||||
import { usePageStore } from "../../../../stores/page";
|
||||
import StringUtils from "../../../../utils/string";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useAddImagesModalStore } from "../../../../stores/addImagesModal";
|
||||
import { computed } from "vue";
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
|
||||
const { activeTab } = storeToRefs(useAddImagesModalStore());
|
||||
|
||||
const images = computed(() => {
|
||||
return activeTab.value.selectedImages;
|
||||
});
|
||||
|
||||
// function saveTags(image) {
|
||||
// const headers = {
|
||||
// method: "POST",
|
||||
// body: JSON.stringify({
|
||||
// pageUri: page.value.uri,
|
||||
// fileName: image.name,
|
||||
// properties: [
|
||||
// {
|
||||
// name: "tags",
|
||||
// value: image.tags,
|
||||
// },
|
||||
// ],
|
||||
// }),
|
||||
// };
|
||||
// fetch("/save-file.json", headers)
|
||||
// .then((res) => res.json())
|
||||
// .then((json) => {
|
||||
// console.log(json);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error("Erreur lors de la sauvegarde :", error);
|
||||
// });
|
||||
// }
|
||||
|
||||
// const saveDescription = debounce((image) => {
|
||||
// const headers = {
|
||||
// method: "POST",
|
||||
// body: JSON.stringify({
|
||||
// pageUri: page.value.uri,
|
||||
// fileName: image.name,
|
||||
// properties: [
|
||||
// {
|
||||
// name: "description",
|
||||
// value: image.description,
|
||||
// },
|
||||
// ],
|
||||
// }),
|
||||
// };
|
||||
// fetch("/save-file.json", headers)
|
||||
// .then((res) => res.json())
|
||||
// .then((json) => {
|
||||
// console.log(json);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error("Erreur lors de la sauvegarde :", error);
|
||||
// });
|
||||
// }, 1000);
|
||||
|
||||
function addImagesToBrief() {
|
||||
const formData = new FormData();
|
||||
|
||||
const blobPromises = images.value.map((item, index) => {
|
||||
console.log(item);
|
||||
if (item.url.startsWith("blob:")) {
|
||||
return fetch(item.url)
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => {
|
||||
formData.append("images[]", blob, item.name);
|
||||
formData.append(
|
||||
`imagesMeta[${index}][description]`,
|
||||
item.description
|
||||
);
|
||||
formData.append(
|
||||
`imagesMeta[${index}][tags]`,
|
||||
JSON.stringify(item.tags)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
formData.append("imageUris[]", JSON.stringify(item));
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(blobPromises).then(() => {
|
||||
fetch("/upload-images.json?pageUri=" + page.value.uri, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
page.value.moodboard = json.images;
|
||||
console.log(json);
|
||||
})
|
||||
.catch((error) => console.error("Error:", error));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Accordion */
|
||||
[data-pc-name="accordionheader"] {
|
||||
height: var(--space-40);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<template>
|
||||
<div
|
||||
class="auto-grid"
|
||||
role="grid"
|
||||
multiselectable="true"
|
||||
style="--min: 15rem; --gap: 0.5rem"
|
||||
>
|
||||
<figure
|
||||
v-for="image in tab.images"
|
||||
class="image"
|
||||
role="gridcell"
|
||||
:aria-selected="isSelected(image)"
|
||||
:data-count="
|
||||
tab.selectedImages.includes(image)
|
||||
? tab.selectedImages.indexOf(image) + 1
|
||||
: undefined
|
||||
"
|
||||
@click="ArrayUtils.toggle(tab.selectedImages, image)"
|
||||
>
|
||||
<img :src="image.url" :alt="image.alt" />
|
||||
</figure>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useAddImagesModalStore } from "../../../../stores/addImagesModal";
|
||||
import { computed } from "vue";
|
||||
import ArrayUtils from "../../../../utils/array";
|
||||
|
||||
const { id } = defineProps({
|
||||
id: String,
|
||||
});
|
||||
const { tabs } = storeToRefs(useAddImagesModalStore());
|
||||
|
||||
const tab = computed(() => {
|
||||
return tabs.value.find((tab) => tab.id === id);
|
||||
});
|
||||
|
||||
function isSelected(image) {
|
||||
return tab.value.selectedImages.includes(image);
|
||||
}
|
||||
</script>
|
||||
103
src/components/project/brief/add-images-modal/MyImages.vue
Normal file
103
src/components/project/brief/add-images-modal/MyImages.vue
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<template>
|
||||
<div class="auto-grid" role="grid" multiselectable="true" style="--min: 15rem; --gap: 0.5rem">
|
||||
<FileUpload
|
||||
mode="basic"
|
||||
name="images[]"
|
||||
@change="addImages($event)"
|
||||
:auto="true"
|
||||
:multiple="true"
|
||||
accept="image/*"
|
||||
:maxFileSize="1000000"
|
||||
invalidFileSizeMessage="Fichier trop lourd"
|
||||
chooseLabel="Ajouter une ou plusieurs images"
|
||||
class="flex flex-col justify-center | bg-white | border border-grey-200 | text-grey-800 | font-medium | rounded-xl"
|
||||
ref="uploadBtn"
|
||||
>
|
||||
<template #chooseicon>
|
||||
<svg
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M0.714355 15.0001V16.4286C0.714355 17.1864 1.01538 17.9131 1.55119 18.4489C2.08701 18.9848 2.81374 19.2858 3.5715 19.2858H16.4286C17.1864 19.2858 17.9131 18.9848 18.4489 18.4489C18.9848 17.9131 19.2858 17.1864 19.2858 16.4286V15.0001M5.71436 5.71436L10.0001 0.714355M10.0001 0.714355L14.2858 5.71436M10.0001 0.714355V13.5715"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.25"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
<template
|
||||
#content="{
|
||||
files,
|
||||
uploadedFiles,
|
||||
removeUploadedFileCallback,
|
||||
removeFileCallback,
|
||||
}"
|
||||
>
|
||||
<div v-if="files.length > 0">Fichiers importés</div>
|
||||
</template>
|
||||
</FileUpload>
|
||||
<figure
|
||||
v-for="image in tab.images"
|
||||
class="image"
|
||||
role="gridcell"
|
||||
:aria-selected="isSelected(image)"
|
||||
:data-count="
|
||||
tab.selectedImages.includes(image)
|
||||
? tab.selectedImages.indexOf(image) + 1
|
||||
: undefined
|
||||
"
|
||||
>
|
||||
<img
|
||||
:src="image.url"
|
||||
alt=""
|
||||
@click="ArrayUtils.toggle(tab.selectedImages, image)"
|
||||
/>
|
||||
</figure>
|
||||
<Toast />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { usePageStore } from "../../../../stores/page";
|
||||
import Toast from "primevue/toast";
|
||||
import { useToast } from "primevue/usetoast";
|
||||
import FileUpload from "primevue/fileupload";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
import { useAddImagesModalStore } from "../../../../stores/addImagesModal";
|
||||
import ArrayUtils from "../../../../utils/array";
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
const toast = useToast();
|
||||
|
||||
const emit = defineEmits(["add-images"]);
|
||||
const uploadBtn = ref(null);
|
||||
|
||||
const { tabs } = storeToRefs(useAddImagesModalStore());
|
||||
|
||||
const tab = computed(() => {
|
||||
return tabs.value.find((tab) => tab.id === "my-images");
|
||||
});
|
||||
|
||||
function addImages() {
|
||||
const newImages = uploadBtn.value.files.map((file) => {
|
||||
return {
|
||||
url: URL.createObjectURL(file),
|
||||
description: "",
|
||||
tags: [],
|
||||
name: file.name,
|
||||
};
|
||||
});
|
||||
tab.value.images = [...tab.value.images, ...newImages];
|
||||
tab.value.selectedImages = [...tab.value.selectedImages, ...newImages];
|
||||
}
|
||||
|
||||
function isSelected(image) {
|
||||
return tab.value.selectedImages.includes(image);
|
||||
}
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue