diff --git a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/2846277834_perfume-1042715_1280.jpg.txt b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/2846277834_perfume-1042715_1280.jpg.txt index 43e0d6e..645bf08 100644 --- a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/2846277834_perfume-1042715_1280.jpg.txt +++ b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/2846277834_perfume-1042715_1280.jpg.txt @@ -1,12 +1,12 @@ -Date: 2024-10-02 02:10 - ----- - Description: ---- -Tags: +Tags: bouton poussoir, coloris & nuances + +---- + +Date: 2024-10-02 02:10 ---- diff --git a/public/site/config/config.php b/public/site/config/config.php index 6cd3d2d..e2c3dd1 100644 --- a/public/site/config/config.php +++ b/public/site/config/config.php @@ -23,6 +23,7 @@ return [ require(__DIR__ . '/routes/toggle-favorite.php'), require(__DIR__ . '/routes/upload-images.php'), require(__DIR__ . '/routes/save-page.php'), + require(__DIR__ . '/routes/save-file.php'), ], 'hooks' => [ 'page.create:after' => require_once(__DIR__ . '/hooks/create-steps.php'), diff --git a/public/site/config/routes/save-file.php b/public/site/config/routes/save-file.php new file mode 100644 index 0000000..a34b8ff --- /dev/null +++ b/public/site/config/routes/save-file.php @@ -0,0 +1,25 @@ + '(:all)save-file.json', + 'method' => 'POST', + 'action' => function () { + $json = file_get_contents('php://input'); + $data = json_decode($json); + + $page = page($data->pageUri); + $file = $page->file($data->fileName); + + + + $newProperties = []; + + foreach ($data->properties as $incomingProperty) { + $newProperties[$incomingProperty->name] = $incomingProperty->value; + } + + $newFile = $file->update($newProperties); + + return json_encode($newProperties); + } +]; \ No newline at end of file diff --git a/public/site/templates/client-brief.json.php b/public/site/templates/client-brief.json.php index 61c66d5..d1b4736 100644 --- a/public/site/templates/client-brief.json.php +++ b/public/site/templates/client-brief.json.php @@ -6,8 +6,8 @@ foreach ($page->clientBriefImages()->toFiles() as $image) { $images[] = [ 'url' => $image->url(), 'uuid' => (string) $image->uuid(), - 'tags' => page('projects')->clientBriefImageTags()->split(), - 'selectedTags' => $image->tags()->split() + 'tags' => $image->tags()->split(), + 'name' => $image->filename() ]; } diff --git a/src/components/project/ClientBrief/Header.vue b/src/components/project/ClientBrief/Header.vue index 80d48ac..147da7e 100644 --- a/src/components/project/ClientBrief/Header.vue +++ b/src/components/project/ClientBrief/Header.vue @@ -15,7 +15,7 @@ rows="3" class="border border-grey-200 | rounded-xl | p-16 | w-full" v-model="page.content.description" - @input="savePage()" + @input="saveDescription()" >
@@ -172,27 +227,16 @@ import Toast from "primevue/toast"; import FileUpload from "primevue/fileupload"; import Dialog from "primevue/dialog"; import Header from "./Header.vue"; +import { toPascalCase } from "../../../helpers"; import { useToast } from "primevue/usetoast"; import { usePageStore } from "../../../stores/page"; -import { ref, watch } from "vue"; +import { ref } from "vue"; const { page } = usePageStore(); const toast = useToast(); + const selectedTags = ref([]); - const modal = ref(null); -watch(modal, (newValue) => { - if (newValue) { - newValue.selectedTags = newValue.selectedTags.map((tag) => { - if (!tag.includes("image")) { - return tag + "-image"; - } else { - return tag; - } - }); - } -}); - const images = ref(page.images); function onAdvancedUpload(event) { @@ -224,6 +268,34 @@ function beforeSend(event) { "projects/miss-dior-blooming-bouquet/client-brief" ); } + +function changeSelectedTags(newTags) { + selectedTags.value = newTags; +} + +function saveTags(image) { + const headers = { + method: "POST", + body: JSON.stringify({ + pageUri: page.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); + }); +}