diff --git a/public/content/projects/1_miss-dior-blooming-bouquet/2_proposal/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf.txt b/public/content/projects/1_miss-dior-blooming-bouquet/2_proposal/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf.txt
index 800de37..ded5934 100644
--- a/public/content/projects/1_miss-dior-blooming-bouquet/2_proposal/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf.txt
+++ b/public/content/projects/1_miss-dior-blooming-bouquet/2_proposal/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf.txt
@@ -6,112 +6,56 @@ Comments:
uri: >
projects/miss-dior-blooming-bouquet/proposal
title: Offre commerciale
- href: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
project:
title: Miss Dior Blooming Bouquet
uri: projects/miss-dior-blooming-bouquet
+ dialogUri: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
file:
uuid: file://3vTh1tMFeFM2JxaN
- url: file://3vTh1tMFeFM2JxaN
- position:
- pageIndex: 1
- x: "60.110185093015"
- y: "44.594594594595"
- replies: [ ]
+ url: >
+ http://localhost:8888/media/pages/projects/miss-dior-blooming-bouquet/proposal/788ddebfe3-1731941917/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf
text: test
author:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
- date: 2024-11-28T16:30:56+01:00
- id: m41h238q
+ date: 2024-12-18T16:20:04+01:00
+ id: 6dbb6d56-a6b7-467b-8341-3d8112a73684
+ position:
+ pageIndex: 1
+ x: "73.3181571571"
+ y: "27.272727272727"
type: comment
- isRead: false
+ replies: [ ]
-
location:
page:
uri: >
projects/miss-dior-blooming-bouquet/proposal
title: Offre commerciale
- href: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
project:
title: Miss Dior Blooming Bouquet
uri: projects/miss-dior-blooming-bouquet
+ dialogUri: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
file:
uuid: file://3vTh1tMFeFM2JxaN
- url: file://3vTh1tMFeFM2JxaN
+ url: >
+ http://localhost:8888/media/pages/projects/miss-dior-blooming-bouquet/proposal/788ddebfe3-1731941917/des-textos-revelent-comment-bfm-sest-mise-au-service-de-sarkozy-le-boss.pdf
+ text: est
+ author:
+ name: Adrien Payet
+ email: adrien.payet@outlook.com
+ uuid: user://WWjXgPWk
+ role: admin
+ date: 2024-12-18T16:23:42+01:00
+ id: 5b2d93f9-fc44-4a69-955a-bf282fba8966
position:
pageIndex: 1
- x: "26.098441098196"
- y: "64.864864864865"
- replies: [ ]
- text: Nouveau commentaire
- author:
- name: Utilisateur Dior
- email: utilisateur@dior.com
- uuid: user://HfuumN8s
- role: client
- date: 2024-12-04T15:00:15+01:00
- id: m49ygks2
+ x: '43.56742057598'
+ y: '65.340909090909'
type: comment
- isRead: false
--
- location:
- page:
- uri: >
- projects/miss-dior-blooming-bouquet/proposal
- title: Offre commerciale
- href: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
- project:
- title: Miss Dior Blooming Bouquet
- uri: projects/miss-dior-blooming-bouquet
- file:
- uuid: file://3vTh1tMFeFM2JxaN
- url: file://3vTh1tMFeFM2JxaN
- position:
- pageIndex: 1
- x: "64.481172808783"
- y: "76.447876447876"
replies: [ ]
- text: encore un commentaire
- author:
- name: Utilisateur Dior
- email: utilisateur@dior.com
- uuid: user://HfuumN8s
- role: client
- date: 2024-12-04T15:03:53+01:00
- id: m49yl8zc
- type: comment
- isRead: false
--
- location:
- page:
- uri: >
- projects/miss-dior-blooming-bouquet/proposal
- title: Offre commerciale
- href: '/projects/miss-dior-blooming-bouquet?dialog=proposal&fileIndex=0'
- project:
- title: Miss Dior Blooming Bouquet
- uri: projects/miss-dior-blooming-bouquet
- file:
- uuid: file://3vTh1tMFeFM2JxaN
- url: file://3vTh1tMFeFM2JxaN
- position:
- pageIndex: 1
- x: '29.786457814876'
- y: '83.397683397683'
- replies: [ ]
- text: et encore un
- author:
- name: Utilisateur Dior
- email: utilisateur@dior.com
- uuid: user://HfuumN8s
- role: client
- date: 2024-12-04T15:05:10+01:00
- id: m49ymwuw
- type: comment
- isRead: false
----
diff --git a/public/site/plugins/classes/location/FileDetails.php b/public/site/plugins/classes/location/FileDetails.php
index 212bc09..ec2fa68 100644
--- a/public/site/plugins/classes/location/FileDetails.php
+++ b/public/site/plugins/classes/location/FileDetails.php
@@ -1,13 +1,14 @@
uuid = (string) $data->uuid();
$this->url = (string) $data->url();
diff --git a/public/site/plugins/comments/index.php b/public/site/plugins/comments/index.php
index 703fd41..92cf431 100644
--- a/public/site/plugins/comments/index.php
+++ b/public/site/plugins/comments/index.php
@@ -3,7 +3,14 @@
F::loadClasses([
'adrienpayet\\comments\\BaseComment' => __DIR__ . '/src/BaseComment.php',
'adrienpayet\\comments\\Comment' => __DIR__ . '/src/Comment.php',
- 'adrienpayet\\comments\\Reply' => __DIR__ . '/src/Reply.php'
+ 'adrienpayet\\comments\\Reply' => __DIR__ . '/src/Reply.php',
+
+ 'adrienpayet\\D2P\\data\\Position' => __DIR__ . '/../classes/Position.php',
+ 'adrienpayet\\D2P\data\Author' => __DIR__ . '/../classes/Author.php',
+ 'adrienpayet\\D2P\\data\\location\\Location' => __DIR__ . '/../classes/location/Location.php',
+ 'adrienpayet\\D2P\\data\\location\\PageDetails' => __DIR__ . '/../classes/location/PageDetails.php',
+ 'adrienpayet\\D2P\\data\\location\\ProjectDetails' => __DIR__ . '/../classes/location/ProjectDetails.php',
+ 'adrienpayet\\D2P\\data\\location\\FileDetails' => __DIR__ . '/../classes/location/FileDetails.php',
]);
Kirby::plugin('adrienpayet/kirby4-comments', [
diff --git a/public/site/plugins/comments/routes/create.php b/public/site/plugins/comments/routes/create.php
index b4f84b9..cd1d26c 100644
--- a/public/site/plugins/comments/routes/create.php
+++ b/public/site/plugins/comments/routes/create.php
@@ -9,49 +9,53 @@ return [
$json = file_get_contents('php://input');
$data = json_decode($json);
- $parsedUrl = parse_url($data->path);
+ $parsedUrl = parse_url($data->dialogUri);
$query = $parsedUrl['query'] ?? null;
parse_str($query, $queryParams);
$stepSlug = $queryParams['dialog'] ?? null;
$targetPageUri = $stepSlug ? $parsedUrl['path'] . '/' . $stepSlug : $parsedUrl['path'];
+ $project = page($parsedUrl['path']);
$page = page($targetPageUri);
$file = $page->file($data->fileName);
- $user = kirby()->user($data->userUuid);
-
+ $user = kirby()->user($data->userUuid);
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
- $data = [
- 'href' => $data->path,
- 'page' => $page,
- 'file' => $file,
- 'position' => [
- 'pageIndex' => $data->position->pageIndex,
- 'x' => $data->position->x,
- 'y' => $data->position->y
+ $commentData = [
+ "location" => [
+ "page" => $page,
+ "project" => $project,
+ "dialogUri" => $data->dialogUri,
+ "file" => $file
],
- 'replies' => [],
- 'text' => $data->text,
- 'author' => $user,
- 'date' => (string) $data->date,
- 'id' => $data->id,
- 'type' => 'comment'
+ "position" => [
+ "pageIndex" => $data->position->pageIndex,
+ "x" => $data->position->x,
+ "y" => $data->position->y
+ ],
+ "date" => (string) $data->date,
+ "text" => $data->text,
+ "author" => kirby()->user(),
+ "id" => Str::uuid(),
+ "type" => "comment",
];
- $newComment = new Comment($data);
+ $user->sendNotification($project, $commentData);
+
+ $newComment = new Comment($commentData);
$comments[] = $newComment->toArray();
$newFile = $file->update([
'comments' => $comments
- ]);
+ ]);
echo json_encode(getFileData($newFile));
try {
- $user->sendNotification($page->parent(), $newComment->toArray());
+ $user->sendNotification($project, $commentData);
} catch (\Throwable $th) {
echo json_encode([
"error" => $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine(),
diff --git a/public/site/plugins/comments/src/BaseComment.php b/public/site/plugins/comments/src/BaseComment.php
index e9d55c2..67c89ed 100644
--- a/public/site/plugins/comments/src/BaseComment.php
+++ b/public/site/plugins/comments/src/BaseComment.php
@@ -1,40 +1,32 @@
type = $data["type"];
$this->location = new Location($data["location"]);
$this->text = $data["text"];
$this->author = new Author($data["author"]);
$this->date = $data["date"];
$this->id = $data["id"];
- $this->isRead = "false";
}
public function toArray() {
return [
- 'location' => $this->location,
- 'position' => $this->position,
- 'replies' => $this->replies,
- 'text' => $this->text,
- 'author' => $this->author,
- 'date' => $this->date,
- 'id' => $this->id,
- 'type' => $this->type,
- 'isRead' => $this->isRead
+ "location" => $this->location->toArray(),
+ "text" => $this->text,
+ "author" => $this->author->toArray(),
+ "date" => $this->date,
+ "id" => $this->id,
];
}
}
diff --git a/public/site/plugins/comments/src/Comment.php b/public/site/plugins/comments/src/Comment.php
index 64cfb61..223223b 100644
--- a/public/site/plugins/comments/src/Comment.php
+++ b/public/site/plugins/comments/src/Comment.php
@@ -1,23 +1,26 @@
position = $data['position'] ?? null;
- }
-
- public function position() {
- return $this->position;
+ if (isset($data["position"])) {
+ $this->position = new Position($data['position']);
+ }
}
public function toArray() {
$array = parent::toArray();
$array['position'] = $this->position;
+ $array['type'] = $this->type;
+ $array['replies'] = $this->replies;
return $array;
}
diff --git a/public/site/plugins/notifications/src/Notification.php b/public/site/plugins/notifications/src/Notification.php
index 6f2dc69..614413a 100644
--- a/public/site/plugins/notifications/src/Notification.php
+++ b/public/site/plugins/notifications/src/Notification.php
@@ -12,7 +12,7 @@ class Notification
protected Author $author;
protected string $date;
protected string $id;
- protected string $isRead;
+ protected string $isRead = "false";
protected ?Position $position = null;
@@ -23,11 +23,6 @@ class Notification
$this->author = new Author($data["author"]);
$this->date = $data["date"];
$this->id = $data["id"];
- $this->isRead = "false";
-
- if ($data["type"] === "comment") {
- $this->position = new Position($data["position"]);
- }
}
public function toArray() {
@@ -40,9 +35,6 @@ class Notification
"id" => $this->id,
"isRead" => $this->isRead,
];
- if ($this->type === "comment") {
- $array["position"] = $this->position->toArray();
- }
return $array;
}
diff --git a/public/site/plugins/notifications/user-methods/send.php b/public/site/plugins/notifications/user-methods/send.php
index 28f145f..b6cd062 100644
--- a/public/site/plugins/notifications/user-methods/send.php
+++ b/public/site/plugins/notifications/user-methods/send.php
@@ -16,27 +16,26 @@ use adrienpayet\notifications\Notification;
*/
return function ($project, $notificationData) {
- $recipients = $project->managers()->without($this);
+ $recipients = $project->managers()->without($this);
- if ($recipients->isEmpty()) return;
+ if ($recipients->isEmpty()) return;
- $notificationData['isRead'] = false;
+ $newNotification = new Notification($notificationData);
- foreach ($recipients as $otherUser) {
- try {
- $notifications = $otherUser->notifications()->isNotEmpty()
- ? Yaml::decode($otherUser->notifications()->value())
- : [];
-
- $newNotification = new Notification($notificationData);
- $notifications[] = $newNotification->toArray();
+ foreach ($recipients as $otherUser) {
+ try {
+ $notifications = $otherUser->notifications()->isNotEmpty()
+ ? Yaml::decode($otherUser->notifications()->value())
+ : [];
+
+ $notifications[] = $newNotification->toArray();
- $otherUser->update([
- 'notifications' => $notifications
- ]);
- } catch (\Throwable $th) {
- error_log("Notification error for user " . $otherUser->email() . ": " . $th->getMessage());
- throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
- }
- }
+ $otherUser->update([
+ 'notifications' => $notifications
+ ]);
+ } catch (\Throwable $th) {
+ error_log("Notification error for user " . $otherUser->email() . ": " . $th->getMessage());
+ throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
+ }
+ }
};
diff --git a/src/components/comments/Comments.vue b/src/components/comments/Comments.vue
index d2f366f..7fb7d5f 100644
--- a/src/components/comments/Comments.vue
+++ b/src/components/comments/Comments.vue
@@ -178,7 +178,7 @@ function handleSubmit(event = null) {
}
const date = dayjs().format();
const newComment = {
- path: route.fullPath,
+ dialogUri: route.fullPath,
fileName: openedFile ? openedFile.value.name : false,
userUuid: user.uuid,
text: draftComment.value.text,
diff --git a/src/components/project/PdfViewer.vue b/src/components/project/PdfViewer.vue
index 5aa8b56..834e16e 100644
--- a/src/components/project/PdfViewer.vue
+++ b/src/components/project/PdfViewer.vue
@@ -45,6 +45,8 @@ watch(isCommentsOpen, (newVal) => {
});
watch(openedFile, (newVal) => {
+ if (!location.href.includes("virtual-sample")) return;
+
isViewerDisabled.value = true;
setTimeout(() => {
diff --git a/src/views/Brief.vue b/src/views/Brief.vue
index dd5cbc9..1b30267 100644
--- a/src/views/Brief.vue
+++ b/src/views/Brief.vue
@@ -9,7 +9,11 @@
>
Retour au projet
-