Progression vue brief client

- l'étape courante est déterminée en fonction des données de la page
- les images sont ajoutées au champ
- les images déjà ajoutées sont affichées directement
- changement donnée briefClient -> clientBrief (cohérence avec le nommage front)
This commit is contained in:
isUnknown 2024-10-02 15:29:31 +02:00
parent 3d93905983
commit 13b6b371d7
18 changed files with 245 additions and 66 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View file

@ -0,0 +1,9 @@
Date: 2024-10-02 01:10
----
Uuid: 1NmPGSM9FKgiyOwH
----
Template: default

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View file

@ -0,0 +1,9 @@
Date: 2024-10-02 01:10
----
Uuid: ump9516TWbjrIo7T
----
Template: default

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

View file

@ -0,0 +1,9 @@
Date: 2024-10-02 01:10
----
Uuid: RaQyVfBK6c8gv8pW
----
Template: default

View file

@ -6,7 +6,7 @@ Stepname: clientBrief
---- ----
Briefclientpdf: Clientbriefpdf:
---- ----
@ -14,7 +14,11 @@ Description: Sed congue magna magna lorem aliquam diam dolor arcu fusce adipisci
---- ----
Briefclientimages: Clientbriefimages:
- file://ump9516TWbjrIo7T
- file://RaQyVfBK6c8gv8pW
- file://1NmPGSM9FKgiyOwH
---- ----

View file

@ -2,7 +2,7 @@ Title: Miss Dior Blooming Bouquet
---- ----
Currentstep: Currentstep: clientBrief
---- ----

View file

@ -14,7 +14,7 @@ Uuid: 5NGq8baScF9pCeK9
---- ----
Briefclientpdf: Clientbriefpdf:
---- ----
@ -22,4 +22,4 @@ Description:
---- ----
Briefclientimages: Clientbriefimages:

View file

@ -2,4 +2,4 @@ Title: Nom du service
---- ----
Briefclientimagestags: Parachèvements, Forme & design, Matériaux & textures, Coloris & nuances, Bouchon, Bouton poussoir, DA globale Clientbriefimagestags: Parachèvements, Forme & design, Matériaux & textures, Coloris & nuances, Bouchon, Bouton poussoir, DA globale

View file

@ -24,7 +24,7 @@ tabs:
stepName: stepName:
type: hidden type: hidden
value: test value: test
briefClientPdf: clientBriefPdf:
label: PDF label: PDF
type: files type: files
multiple: false multiple: false
@ -34,7 +34,7 @@ tabs:
size: tiny size: tiny
buttons: false buttons: false
maxlength: 700 maxlength: 700
briefClientImages: clientBriefImages:
label: Images label: Images
type: files type: files
uploads: image uploads: image

View file

@ -35,7 +35,7 @@ tabs:
label: Paramètres label: Paramètres
type: fields type: fields
fields: fields:
briefClientImagesTags: clientBriefImagesTags:
label: Tags des images de Brief client label: Tags des images de Brief client
help: Ensemble des tags dimages disponibles lors de la création du Brief client help: Ensemble des tags dimages disponibles lors de la création du Brief client
type: tags type: tags

View file

@ -21,7 +21,7 @@ return [
'routes' => [ 'routes' => [
require(__DIR__ . '/routes/logout.php'), require(__DIR__ . '/routes/logout.php'),
require(__DIR__ . '/routes/toggle-favorite.php'), require(__DIR__ . '/routes/toggle-favorite.php'),
require(__DIR__ . '/routes/upload.php') require(__DIR__ . '/routes/upload-images.php')
], ],
'hooks' => [ 'hooks' => [
'page.create:after' => require_once(__DIR__ . '/hooks/create-steps.php'), 'page.create:after' => require_once(__DIR__ . '/hooks/create-steps.php'),

View file

@ -1,7 +1,7 @@
<?php <?php
return [ return [
'pattern' => 'upload.json', 'pattern' => 'upload-images.json',
'method' => 'POST', 'method' => 'POST',
'action' => function () { 'action' => function () {
if ($uploads = kirby()->request()->files()) { if ($uploads = kirby()->request()->files()) {
@ -11,6 +11,7 @@ return [
$alerts = []; $alerts = [];
$success = ''; $success = '';
$newFiles = []; $newFiles = [];
$allFiles = [];
foreach ($uploads->get('images') as $upload) { foreach ($uploads->get('images') as $upload) {
// check for duplicate // check for duplicate
@ -26,12 +27,11 @@ return [
if ($duplicates->count() > 0) { if ($duplicates->count() > 0) {
$alerts[$upload['name']] = "The file already exists"; $alerts[$upload['name']] = "The file already exists";
continue;
} }
try { try {
$name = crc32($upload['name'].microtime()). '_' . $upload['name']; $name = crc32($upload['name'].microtime()). '_' . $upload['name'];
$newFiles[] = $page->createFile([ $newFile = $page->createFile([
'source' => $upload['tmp_name'], 'source' => $upload['tmp_name'],
'filename' => $name, 'filename' => $name,
'template' => 'default', 'template' => 'default',
@ -39,16 +39,28 @@ return [
'date' => date('Y-m-d h:m') 'date' => date('Y-m-d h:m')
] ]
]); ]);
$newFiles[] = $newFile;
$success = 'Your file upload was successful'; $success = 'Your file upload was successful';
$allFiles[] = (string) $newFile->uuid();
} catch (Exception $e) { } catch (Exception $e) {
$alerts[$upload['name']] = $e->getMessage(); $alerts[$upload['name']] = $e->getMessage();
} }
} }
$images = array_map(function ($file) { $images = array_map(function ($file) {
return $file->url(); return [
'url' => $file->url(),
'uuid' => $file->uuid()
];
}, $newFiles); }, $newFiles);
$newPage = $page->update([
'clientBriefImages' => $allFiles
]);
return compact('images', 'alerts', 'success'); return compact('images', 'alerts', 'success');
} }

View file

@ -1,7 +1,16 @@
<?php <?php
$images = [];
foreach ($page->clientBriefImages()->toFiles() as $image) {
$images[] = [
'url' => $image->url(),
'uuid' => (string) $image->uuid()
];
}
$specificData = [ $specificData = [
"exampleField" => $page->exampleField(), "images" => $images
]; ];
$data = array_merge($genericData, $specificData); $data = array_merge($genericData, $specificData);

View file

@ -4,7 +4,11 @@
class="project-details | flex items-start | bg-white | rounded-2xl | p-16 | w-full" class="project-details | flex items-start | bg-white | rounded-2xl | p-16 | w-full"
> >
<div class="project-details__description | flex-1"> <div class="project-details__description | flex-1">
<label for="project-description" class="flex | text-sm text-grey-700 | mb-8">Description du projet</label> <label
for="project-description"
class="flex | text-sm text-grey-700 | mb-8"
>Description du projet</label
>
<textarea <textarea
name="project-description" name="project-description"
id="project-description" id="project-description"
@ -16,21 +20,65 @@
<fieldset class="project-details__filters | flex-1"> <fieldset class="project-details__filters | flex-1">
<legend class="text-sm text-grey-700 | mb-8">Filtrer par tags</legend> <legend class="text-sm text-grey-700 | mb-8">Filtrer par tags</legend>
<div class="flex" style="gap: var(--space-8)"> <div class="flex" style="gap: var(--space-8)">
<button class="btn btn--sm btn--grey" id="all" aria-pressed="true">Voir tout</button> <button class="btn btn--sm btn--grey" id="all" aria-pressed="true">
<input class="sr-only" type="checkbox" id="bouchon" name="bouchon"> Voir tout
</button>
<input class="sr-only" type="checkbox" id="bouchon" name="bouchon" />
<label class="btn btn--sm btn--primary" for="bouchon">Bouchon</label> <label class="btn btn--sm btn--primary" for="bouchon">Bouchon</label>
<input class="sr-only" type="checkbox" id="bouchon-poussoir" name="bouchon-poussoir"> <input
<label class="btn btn--sm btn--primary" for="bouchon-poussoir">Bouton Poussoir</label> class="sr-only"
<input class="sr-only" type="checkbox" id="coloris-nuances" name="coloris-nuances"> type="checkbox"
<label class="btn btn--sm btn--primary" for="coloris-nuances">Coloris & Nuances</label> id="bouchon-poussoir"
<input class="sr-only" type="checkbox" id="da-globale" name="da-globale"> name="bouchon-poussoir"
<label class="btn btn--sm btn--primary" for="da-globale">DA Globale</label> />
<input class="sr-only" type="checkbox" id="forme-design" name="forme-design"> <label class="btn btn--sm btn--primary" for="bouchon-poussoir"
<label class="btn btn--sm btn--primary" for="forme-design">Forme & Design</label> >Bouton Poussoir</label
<input class="sr-only" type="checkbox" id="materiaux-textures" name="materiaux-textures"> >
<label class="btn btn--sm btn--primary" for="materiaux-textures">Matériaux & Textures</label> <input
<input class="sr-only" type="checkbox" id="parachevements" name="parachevements"> class="sr-only"
<label class="btn btn--sm btn--primary" for="parachevements">Parachèvements</label> type="checkbox"
id="coloris-nuances"
name="coloris-nuances"
/>
<label class="btn btn--sm btn--primary" for="coloris-nuances"
>Coloris & Nuances</label
>
<input
class="sr-only"
type="checkbox"
id="da-globale"
name="da-globale"
/>
<label class="btn btn--sm btn--primary" for="da-globale"
>DA Globale</label
>
<input
class="sr-only"
type="checkbox"
id="forme-design"
name="forme-design"
/>
<label class="btn btn--sm btn--primary" for="forme-design"
>Forme & Design</label
>
<input
class="sr-only"
type="checkbox"
id="materiaux-textures"
name="materiaux-textures"
/>
<label class="btn btn--sm btn--primary" for="materiaux-textures"
>Matériaux & Textures</label
>
<input
class="sr-only"
type="checkbox"
id="parachevements"
name="parachevements"
/>
<label class="btn btn--sm btn--primary" for="parachevements"
>Parachèvements</label
>
</div> </div>
</fieldset> </fieldset>
</header> </header>
@ -38,7 +86,7 @@
<FileUpload <FileUpload
mode="basic" mode="basic"
name="images[]" name="images[]"
:url="'/upload.json?pageUri=' + page.uri" :url="'/upload-images.json?pageUri=' + page.uri"
@upload="onAdvancedUpload($event)" @upload="onAdvancedUpload($event)"
:auto="true" :auto="true"
:multiple="true" :multiple="true"
@ -49,8 +97,20 @@
class="flex flex-col | bg-white | border border-grey-200 | text-grey-800 | font-medium | rounded-2xl" class="flex flex-col | bg-white | border border-grey-200 | text-grey-800 | font-medium | rounded-2xl"
> >
<template #chooseicon> <template #chooseicon>
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <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"/> 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> </svg>
</template> </template>
<template <template
@ -58,7 +118,7 @@
files, files,
uploadedFiles, uploadedFiles,
removeUploadedFileCallback, removeUploadedFileCallback,
removeFileCallback removeFileCallback,
}" }"
> >
<div v-if="files.length > 0">Fichiers importés</div> <div v-if="files.length > 0">Fichiers importés</div>
@ -67,7 +127,7 @@
<Toast /> <Toast />
<figure v-for="image in images" class="image" @click="visible = true"> <figure v-for="image in images" class="image" @click="visible = true">
<span class="tag | btn btn--sm">Tag</span> <span class="tag | btn btn--sm">Tag</span>
<img :src="image" alt="" /> <img :src="image.url" alt="" />
</figure> </figure>
</div> </div>
<Dialog <Dialog
@ -77,34 +137,82 @@
:style="{ width: '62.5rem', height: '50rem' }" :style="{ width: '62.5rem', height: '50rem' }"
class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden" class="bg-white | text-grey-800 | rounded-2xl | overflow-hidden"
> >
<img <img :src="image" alt="" class="bg-grey-200" loading="lazy" />
:src="image"
alt=""
class="bg-grey-200"
loading="lazy"
>
<div class="flex flex-col | p-32" style="--row-gap: var(--space-32)"> <div class="flex flex-col | p-32" style="--row-gap: var(--space-32)">
<fieldset class="image__tags"> <fieldset class="image__tags">
<legend class="text-sm text-grey-700 | mb-8">Tags</legend> <legend class="text-sm text-grey-700 | mb-8">Tags</legend>
<div class="flex" style="gap: var(--space-8)"> <div class="flex" style="gap: var(--space-8)">
<input class="sr-only" type="checkbox" id="bouchon" name="bouchon"> <input
<label class="btn btn--sm btn--primary" for="bouchon">Bouchon</label> class="sr-only"
<input class="sr-only" type="checkbox" id="bouchon-poussoir" name="bouchon-poussoir"> type="checkbox"
<label class="btn btn--sm btn--primary" for="bouchon-poussoir">Bouton Poussoir</label> id="bouchon"
<input class="sr-only" type="checkbox" id="coloris-nuances" name="coloris-nuances"> name="bouchon"
<label class="btn btn--sm btn--primary" for="coloris-nuances">Coloris & Nuances</label> />
<input class="sr-only" type="checkbox" id="da-globale" name="da-globale"> <label class="btn btn--sm btn--primary" for="bouchon"
<label class="btn btn--sm btn--primary" for="da-globale">DA Globale</label> >Bouchon</label
<input class="sr-only" type="checkbox" id="forme-design" name="forme-design"> >
<label class="btn btn--sm btn--primary" for="forme-design">Forme & Design</label> <input
<input class="sr-only" type="checkbox" id="materiaux-textures" name="materiaux-textures"> class="sr-only"
<label class="btn btn--sm btn--primary" for="materiaux-textures">Matériaux & Textures</label> type="checkbox"
<input class="sr-only" type="checkbox" id="parachevements" name="parachevements"> id="bouchon-poussoir"
<label class="btn btn--sm btn--primary" for="parachevements">Parachèvements</label> name="bouchon-poussoir"
/>
<label class="btn btn--sm btn--primary" for="bouchon-poussoir"
>Bouton Poussoir</label
>
<input
class="sr-only"
type="checkbox"
id="coloris-nuances"
name="coloris-nuances"
/>
<label class="btn btn--sm btn--primary" for="coloris-nuances"
>Coloris & Nuances</label
>
<input
class="sr-only"
type="checkbox"
id="da-globale"
name="da-globale"
/>
<label class="btn btn--sm btn--primary" for="da-globale"
>DA Globale</label
>
<input
class="sr-only"
type="checkbox"
id="forme-design"
name="forme-design"
/>
<label class="btn btn--sm btn--primary" for="forme-design"
>Forme & Design</label
>
<input
class="sr-only"
type="checkbox"
id="materiaux-textures"
name="materiaux-textures"
/>
<label class="btn btn--sm btn--primary" for="materiaux-textures"
>Matériaux & Textures</label
>
<input
class="sr-only"
type="checkbox"
id="parachevements"
name="parachevements"
/>
<label class="btn btn--sm btn--primary" for="parachevements"
>Parachèvements</label
>
</div> </div>
</fieldset> </fieldset>
<div class="image__description | w-full"> <div class="image__description | w-full">
<label for="image-description" class="flex | text-sm text-grey-700 | mb-8">Description de limage</label> <label
for="image-description"
class="flex | text-sm text-grey-700 | mb-8"
>Description de limage</label
>
<textarea <textarea
name="image-description" name="image-description"
id="image-description" id="image-description"
@ -112,7 +220,13 @@
class="border border-grey-200 | rounded-xl | p-16 | w-full" class="border border-grey-200 | rounded-xl | p-16 | w-full"
></textarea> ></textarea>
</div> </div>
<button data-icon="delete" class="btn btn--black-10 | ml-auto mt-auto" @click="visible = false">Supprimer cette image</button> <button
data-icon="delete"
class="btn btn--black-10 | ml-auto mt-auto"
@click="visible = false"
>
Supprimer cette image
</button>
</div> </div>
</Dialog> </Dialog>
</section> </section>
@ -121,7 +235,7 @@
<script setup> <script setup>
import Toast from "primevue/toast"; import Toast from "primevue/toast";
import FileUpload from "primevue/fileupload"; import FileUpload from "primevue/fileupload";
import Dialog from 'primevue/dialog'; import Dialog from "primevue/dialog";
import { useToast } from "primevue/usetoast"; import { useToast } from "primevue/usetoast";
import { usePageStore } from "../../../stores/page"; import { usePageStore } from "../../../stores/page";
import { ref } from "vue"; import { ref } from "vue";
@ -137,7 +251,7 @@ const beforeSend = (event) => {
); );
}; };
const images = ref([]); const images = ref(page.images);
const onAdvancedUpload = (event) => { const onAdvancedUpload = (event) => {
if (event.xhr.status === 200) { if (event.xhr.status === 200) {

View file

@ -9,17 +9,29 @@ import { ref } from "vue";
import Header from "../components/project/Header.vue"; import Header from "../components/project/Header.vue";
import Intro from "../components/project/ClientBrief/Intro.vue"; import Intro from "../components/project/ClientBrief/Intro.vue";
import ModeSelection from "../components/project/ClientBrief/ModeSelection.vue"; import ModeSelection from "../components/project/ClientBrief/ModeSelection.vue";
import AddImages from "../components/project/ClientBrief/AddImages.vue"; import Images from "../components/project/ClientBrief/Images.vue";
import { usePageStore } from "../stores/page";
const stepsComponents = { const stepsComponents = {
Intro, Intro,
ModeSelection, ModeSelection,
AddImages, Images,
}; };
const currentStep = ref("AddImages"); const { page } = usePageStore();
const currentStep = ref(setInitialStep());
function changeStep(stepName) { function changeStep(stepName) {
currentStep.value = stepName; currentStep.value = stepName;
} }
function setInitialStep() {
const hasPDF = page.content.clientbriefpdf.length !== 0;
const hasImages = page.content.clientbriefimages.length !== 0;
const isEmpty = !hasPDF && !hasImages;
if (isEmpty) return "Intro";
if (hasPDF) return "PDF";
if (hasImages) return "Images";
}
</script> </script>

View file

@ -4,7 +4,8 @@
<!-- Kanban: Status Brief Enrichi --> <!-- Kanban: Status Brief Enrichi -->
<div class="kanban"> <div class="kanban">
<ProjectStep v-for="step in page.steps" :key="step" :step="step" /> <ProjectStep v-for="step in page.steps" :key="step" :step="step">
</ProjectStep>
<!-- <section <!-- <section
class="flex-1" class="flex-1"
aria-labelledby="votre-brief-label" aria-labelledby="votre-brief-label"