2024-10-08 18:29:28 +02:00
|
|
|
|
<template>
|
|
|
|
|
|
<Dialog
|
2024-10-08 18:38:23 +02:00
|
|
|
|
v-model:visible="isOpen"
|
2024-10-08 18:29:28 +02:00
|
|
|
|
id="image-details"
|
|
|
|
|
|
modal
|
|
|
|
|
|
header="Détails de l’image"
|
|
|
|
|
|
class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden"
|
|
|
|
|
|
>
|
2024-10-08 18:38:23 +02:00
|
|
|
|
<img :src="image.url" alt="" class="bg-grey-200" loading="lazy" />
|
2024-10-08 18:29:28 +02:00
|
|
|
|
<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"
|
2024-10-08 18:38:23 +02:00
|
|
|
|
@change="saveTags()"
|
|
|
|
|
|
v-model="image.tags"
|
2024-10-08 18:29:28 +02:00
|
|
|
|
/>
|
|
|
|
|
|
<label class="btn btn--sm btn--primary" :for="pageTag + '-image'">{{
|
|
|
|
|
|
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"
|
2024-10-08 18:38:23 +02:00
|
|
|
|
v-model="image.description"
|
|
|
|
|
|
@input="saveDescription()"
|
2024-10-08 18:29:28 +02:00
|
|
|
|
></textarea>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
|
|
|
|
|
data-icon="delete"
|
|
|
|
|
|
class="btn btn--black-10 | ml-auto mt-auto"
|
2024-10-08 18:38:23 +02:00
|
|
|
|
@click="image = false"
|
2024-10-08 18:29:28 +02:00
|
|
|
|
>
|
|
|
|
|
|
Supprimer cette image
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-10-08 18:38:23 +02:00
|
|
|
|
import { ref, watch } from "vue";
|
2024-10-08 18:29:28 +02:00
|
|
|
|
import { usePageStore } from "../../../stores/page";
|
|
|
|
|
|
import { toPascalCase } from "../../../helpers";
|
|
|
|
|
|
import Dialog from "primevue/dialog";
|
2024-10-08 18:38:23 +02:00
|
|
|
|
import debounce from "lodash/debounce";
|
2024-10-08 18:29:28 +02:00
|
|
|
|
|
|
|
|
|
|
const { imageDetails } = defineProps({
|
|
|
|
|
|
imageDetails: Object,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-10-08 18:38:23 +02:00
|
|
|
|
const emit = defineEmits(["close"]);
|
|
|
|
|
|
|
|
|
|
|
|
const isOpen = ref(true);
|
|
|
|
|
|
watch(isOpen, () => {
|
|
|
|
|
|
emit("close");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-10-08 18:29:28 +02:00
|
|
|
|
const { page } = usePageStore();
|
|
|
|
|
|
|
2024-10-08 18:38:23 +02:00
|
|
|
|
const image = ref(imageDetails);
|
2024-10-08 18:29:28 +02:00
|
|
|
|
|
2024-10-08 18:38:23 +02:00
|
|
|
|
function saveTags() {
|
2024-10-08 18:29:28 +02:00
|
|
|
|
const headers = {
|
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
|
pageUri: page.uri,
|
2024-10-08 18:38:23 +02:00
|
|
|
|
fileName: image.value.name,
|
2024-10-08 18:29:28 +02:00
|
|
|
|
properties: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "tags",
|
2024-10-08 18:38:23 +02:00
|
|
|
|
value: image.value.tags,
|
2024-10-08 18:29:28 +02:00
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
}),
|
|
|
|
|
|
};
|
|
|
|
|
|
fetch("/save-file.json", headers)
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
.then((json) => {
|
|
|
|
|
|
console.log(json);
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
|
console.error("Erreur lors de la sauvegarde :", error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-10-08 18:38:23 +02:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
|
console.error("Erreur lors de la sauvegarde :", error);
|
|
|
|
|
|
});
|
|
|
|
|
|
}, 1000);
|
2024-10-08 18:29:28 +02:00
|
|
|
|
</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>
|