diff --git a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt index 302ddac..654c483 100644 --- a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt +++ b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt @@ -28,8 +28,8 @@ Comments: url: file://s0lNtRA0Z7ybTCWG position: pageIndex: 1 - x: "32.518325137231" - y: "20.46332046332" + x: "64.481176977282" + y: "14.478764478764" replies: [ ] text: test author: @@ -37,8 +37,8 @@ Comments: email: adrien.payet@outlook.com uuid: user://WWjXgPWk role: admin - date: 2024-11-18T11:59:06+01:00 - id: m3mwxzuo + date: 2024-11-21T19:18:40+01:00 + id: m3rmytqk type: comment isRead: false - @@ -57,66 +57,8 @@ Comments: url: file://s0lNtRA0Z7ybTCWG position: pageIndex: 1 - x: "60.383371825251" - y: "50.772200772201" - replies: [ ] - text: Test 2 - author: - name: Adrien Payet - email: adrien.payet@outlook.com - uuid: user://WWjXgPWk - role: admin - date: 2024-11-18T14:05:32+01:00 - id: m3n1gl8u - type: comment - isRead: false -- - location: - page: - uri: > - projects/miss-dior-blooming-bouquet/client-brief - title: Brief client - href: > - /projects/miss-dior-blooming-bouquet?dialog=client-brief - project: - title: Miss Dior Blooming Bouquet - uri: projects/miss-dior-blooming-bouquet - file: - uuid: file://s0lNtRA0Z7ybTCWG - url: file://s0lNtRA0Z7ybTCWG - position: - pageIndex: 1 - x: "20.771295651105" - y: "66.409266409266" - replies: [ ] - text: Test 3 - author: - name: Adrien Payet - email: adrien.payet@outlook.com - uuid: user://WWjXgPWk - role: admin - date: 2024-11-18T14:05:45+01:00 - id: m3n1gupx - type: comment - isRead: false -- - location: - page: - uri: > - projects/miss-dior-blooming-bouquet/client-brief - title: Brief client - href: > - /projects/miss-dior-blooming-bouquet?dialog=client-brief - project: - title: Miss Dior Blooming Bouquet - uri: projects/miss-dior-blooming-bouquet - file: - uuid: file://s0lNtRA0Z7ybTCWG - url: file://s0lNtRA0Z7ybTCWG - position: - pageIndex: 1 - x: '79.506443081734' - y: '74.131274131274' + x: "64.481176977282" + y: "14.478764478764" replies: [ ] text: test author: @@ -124,7 +66,152 @@ Comments: email: adrien.payet@outlook.com uuid: user://WWjXgPWk role: admin - date: 2024-11-20T08:49:31+01:00 - id: m3pl1vn7 + date: 2024-11-21T19:19:27+01:00 + id: m3rmzu2u + type: comment + isRead: false +- + location: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + href: > + /projects/miss-dior-blooming-bouquet?dialog=client-brief + project: + title: Miss Dior Blooming Bouquet + uri: projects/miss-dior-blooming-bouquet + file: + uuid: file://s0lNtRA0Z7ybTCWG + url: file://s0lNtRA0Z7ybTCWG + position: + pageIndex: 1 + x: "64.481176977282" + y: "14.478764478764" + replies: [ ] + text: test + author: + name: Adrien Payet + email: adrien.payet@outlook.com + uuid: user://WWjXgPWk + role: admin + date: 2024-11-21T19:19:33+01:00 + id: m3rmzyl9 + type: comment + isRead: false +- + location: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + href: > + /projects/miss-dior-blooming-bouquet?dialog=client-brief + project: + title: Miss Dior Blooming Bouquet + uri: projects/miss-dior-blooming-bouquet + file: + uuid: file://s0lNtRA0Z7ybTCWG + url: file://s0lNtRA0Z7ybTCWG + position: + pageIndex: 1 + x: "64.481176977282" + y: "14.478764478764" + replies: [ ] + text: test + author: + name: Adrien Payet + email: adrien.payet@outlook.com + uuid: user://WWjXgPWk + role: admin + date: 2024-11-21T19:19:44+01:00 + id: m3rn07nl + type: comment + isRead: false +- + location: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + href: > + /projects/miss-dior-blooming-bouquet?dialog=client-brief + project: + title: Miss Dior Blooming Bouquet + uri: projects/miss-dior-blooming-bouquet + file: + uuid: file://s0lNtRA0Z7ybTCWG + url: file://s0lNtRA0Z7ybTCWG + position: + pageIndex: 1 + x: "64.481176977282" + y: "14.478764478764" + replies: [ ] + text: test + author: + name: Adrien Payet + email: adrien.payet@outlook.com + uuid: user://WWjXgPWk + role: admin + date: 2024-11-21T19:20:04+01:00 + id: m3rn0mf4 + type: comment + isRead: false +- + location: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + href: > + /projects/miss-dior-blooming-bouquet?dialog=client-brief + project: + title: Miss Dior Blooming Bouquet + uri: projects/miss-dior-blooming-bouquet + file: + uuid: file://s0lNtRA0Z7ybTCWG + url: file://s0lNtRA0Z7ybTCWG + position: + pageIndex: 1 + x: "60.383375993749" + y: "31.660231660232" + replies: [ ] + text: test + author: + name: Adrien Payet + email: adrien.payet@outlook.com + uuid: user://WWjXgPWk + role: admin + date: 2024-11-21T19:35:48+01:00 + id: m3rnkvcn + type: comment + isRead: false +- + location: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + href: > + /projects/miss-dior-blooming-bouquet?dialog=client-brief + project: + title: Miss Dior Blooming Bouquet + uri: projects/miss-dior-blooming-bouquet + file: + uuid: file://s0lNtRA0Z7ybTCWG + url: file://s0lNtRA0Z7ybTCWG + position: + pageIndex: 1 + x: '64.481176977282' + y: '50.772200772201' + replies: [ ] + text: test + author: + name: Adrien Payet + email: adrien.payet@outlook.com + uuid: user://WWjXgPWk + role: admin + date: 2024-11-21T19:36:11+01:00 + id: m3rnld52 type: comment isRead: false \ No newline at end of file diff --git a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/client-brief.txt b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/client-brief.txt index 1ff1bb8..d749bb7 100644 --- a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/client-brief.txt +++ b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/client-brief.txt @@ -22,4 +22,8 @@ Stepindex: 1 ---- -Uuid: glE28vWGearnAmxw \ No newline at end of file +Uuid: glE28vWGearnAmxw + +---- + +Isvalidated: true \ No newline at end of file diff --git a/public/site/blueprints/pages/client-brief.yml b/public/site/blueprints/pages/client-brief.yml index e538e0a..3670695 100644 --- a/public/site/blueprints/pages/client-brief.yml +++ b/public/site/blueprints/pages/client-brief.yml @@ -23,7 +23,8 @@ tabs: fields: stepName: type: hidden - value: test + isSent: + type: hidden pdf: label: PDF type: files diff --git a/public/site/blueprints/pages/projects.yml b/public/site/blueprints/pages/projects.yml index 6a05ce1..1d0435d 100644 --- a/public/site/blueprints/pages/projects.yml +++ b/public/site/blueprints/pages/projects.yml @@ -5,13 +5,6 @@ tabs: label: Contenu columns: - width: 1/1 - sections: - listed: - extends: sections/projects - headline: En cours - status: listed - sortBy: modified desc - - width: 1/2 sections: drafts: extends: sections/projects @@ -23,17 +16,24 @@ tabs: extends: sections/projects headline: Archivés status: unlisted - - width: 1/1 + - width: 1/2 sections: - yourProjects: - label: Tous vos projets - type: pages - query: user.projects + listed: + extends: sections/projects + headline: En cours + status: listed sortBy: modified desc - create: false - search: true - image: - query: page.client.toPage.logo.toFile + # - width: 1/1 + # sections: + # yourProjects: + # label: Tous vos projets + # type: pages + # query: user.projects + # sortBy: modified desc + # create: false + # search: true + # image: + # query: page.client.toPage.logo.toFile settings: label: Réglages diff --git a/public/site/blueprints/site.yml b/public/site/blueprints/site.yml index 481e425..2f6d0dd 100644 --- a/public/site/blueprints/site.yml +++ b/public/site/blueprints/site.yml @@ -11,7 +11,6 @@ tabs: yourProjects: label: Vos projets type: pages - query: user.projects help: Projets pour lesquels vous êtes nommé chef de projet. image: query: page.client.toPage.logo.toFile diff --git a/public/site/config/config.php b/public/site/config/config.php index a8f0ee4..fea1168 100644 --- a/public/site/config/config.php +++ b/public/site/config/config.php @@ -26,6 +26,7 @@ return [ require(__DIR__ . '/routes/save-file.php'), require(__DIR__ . '/routes/remove-file.php'), require(__DIR__ . '/routes/upload-pdf.php'), + require(__DIR__ . '/routes/validate-brief.php'), ], 'hooks' => [ 'page.create:after' => require_once(__DIR__ . '/hooks/create-steps.php'), diff --git a/public/site/config/routes/validate-brief.php b/public/site/config/routes/validate-brief.php new file mode 100644 index 0000000..54a7faa --- /dev/null +++ b/public/site/config/routes/validate-brief.php @@ -0,0 +1,32 @@ + '(:all)validate-brief.json', + 'method' => 'POST', + 'action' => function () { + $json = file_get_contents('php://input'); + $data = json_decode($json); + + $page = page($data->pageUri); + try { + $newPage = $page->update([ + 'isValidated' => 'true' + ]); + echo json_encode([ + "success" => "'" . $newPage->title()->value() . "' brief validated." + ]); + + kirby()->user()->sendNotification($newPage->parent(), [ + 'date' => $newPage->modified('YYYY-MM-DD'), + 'author' => kirby()->user()->name()->isNotEmpty() ? kirby()->user()->name() : kirby()->user()->email(), + 'url' => $newPage->url(), + 'type' => 'content' + ]); + } catch (\Throwable $th) { + return [ + "error" => "Can't validate '" . $page->title()->value() . "' brief.", + 'details' => $th->getMessage() + ]; + } + } +]; \ No newline at end of file diff --git a/public/site/models/project.php b/public/site/models/project.php index 729d805..b199edc 100644 --- a/public/site/models/project.php +++ b/public/site/models/project.php @@ -35,6 +35,7 @@ class ProjectPage extends Page { 'slug' => $child->slug(), 'index' => intval($child->stepIndex()->value()), 'modified' => $child->modified('Y-MM-dd'), + 'isValidated' => $child->isValidated()->value() ?? false, 'uri' => $uri, 'files' => $files, ]; diff --git a/public/site/plugins/comments/routes/create.php b/public/site/plugins/comments/routes/create.php index 2291da7..9098823 100644 --- a/public/site/plugins/comments/routes/create.php +++ b/public/site/plugins/comments/routes/create.php @@ -51,9 +51,9 @@ return [ echo json_encode(getFileData($newFile)); try { - $user->sendNotification($page->parent()->uri(), $newComment->toArray()); + $user->sendNotification($page->parent(), $newComment->toArray()); } catch (\Throwable $th) { - throw new Exception($th->getMessage(), 1); + return $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine(); } exit; diff --git a/public/site/plugins/comments/routes/reply.php b/public/site/plugins/comments/routes/reply.php index cb9384b..cac1a8a 100644 --- a/public/site/plugins/comments/routes/reply.php +++ b/public/site/plugins/comments/routes/reply.php @@ -42,7 +42,7 @@ return [ 'comments' => $comments ]); - $user->sendNotification($page->parent()->uri(), $newReply->toArray()); + $user->sendNotification($page->parent(), $newReply->toArray()); return getFileData($newFile); } diff --git a/public/site/plugins/notifications/user-methods/send.php b/public/site/plugins/notifications/user-methods/send.php index 72db18b..b4c3950 100644 --- a/public/site/plugins/notifications/user-methods/send.php +++ b/public/site/plugins/notifications/user-methods/send.php @@ -13,8 +13,23 @@ * @throws Exception If an error occurs while updating a user's notifications. */ -return function ($projectUri, $notificationData) { - $recipients = page($projectUri)->managers()->toUsers()->not($this); +return function ($project, $notificationData) { + $recipients = kirby()->users()->filter(function($user) use ($project) { + if ($user === $this || $user->projects()->isEmpty()) { + return false; + } + throw new Exception(json_encode($user->name()), 1); + + $projects = $user->projects(); + if ($projects && ($user->role() == 'admin' || $projects->has($project))) { + return false; + } + + return false; + }); + + + // $recipients = page($projectUri)->managers()->toUsers()->not($this); if (!$recipients) return; diff --git a/public/site/plugins/your-projects/index.php b/public/site/plugins/your-projects/index.php index 4b63b8e..e2bad00 100644 --- a/public/site/plugins/your-projects/index.php +++ b/public/site/plugins/your-projects/index.php @@ -1,15 +1,5 @@ [ - 'projects' => function() { - $allProjects = page('projects')->children(); - - $managedProjects = $allProjects->filter( - fn ($project) => $project->managers()->toUsers()->has($this) - ); - - return $managedProjects; - } - ] + 'userMethods' => [] ]); diff --git a/src/components/project/brief/ModeSelection.vue b/src/components/project/brief/ModeSelection.vue index acba2a2..5ed3841 100644 --- a/src/components/project/brief/ModeSelection.vue +++ b/src/components/project/brief/ModeSelection.vue @@ -21,13 +21,24 @@ stroke-linecap="round" stroke-linejoin="round" > - - - - + + + +

Créer via la plateforme

-

Ajouter différents éléments tels que des images et du texte sur la plateforme afin de créer votre brief.

+

+ Ajouter différents éléments tels que des images et du texte sur la + plateforme afin de créer votre brief. +

- + -

Vous avez déjà constitué votre brief en amont et souhaitez directement l’importer.

+

+ Vous avez déjà constitué votre brief en amont et souhaitez directement + l’importer. +

@@ -107,7 +123,8 @@ async function addPdf(event) { if (response.ok) { console.log("File uploaded successfully."); page.value = result; - location.href = location.origin + "/" + page.value.parent; + location.href = + location.origin + "/" + page.value.parent + "?dialog=client-brief"; } else { console.error("Error uploading file:", result.error); } @@ -122,7 +139,7 @@ async function addPdf(event) { diff --git a/src/stores/api.js b/src/stores/api.js index b1d7f73..b432ed8 100644 --- a/src/stores/api.js +++ b/src/stores/api.js @@ -212,6 +212,29 @@ export const useApiStore = defineStore("api", () => { } } + async function validateBrief(briefUri) { + const headers = { + method: "POST", + body: JSON.stringify({ + pageUri: briefUri, + }), + }; + try { + const response = await fetch("/validate-brief.json", headers); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + if (data.error) { + throw new Error(data); + } else { + return data; + } + } catch (error) { + throw error; + } + } + async function readAllNotifications() { try { const response = await fetch("/read-all-notifications.json"); @@ -239,5 +262,6 @@ export const useApiStore = defineStore("api", () => { replyComment, readNotification, readAllNotifications, + validateBrief, }; });