#68 - reply working + remove marker on comment delete
This commit is contained in:
parent
cf83edc1e6
commit
231bb21a4f
9 changed files with 64 additions and 95 deletions
|
|
@ -1,62 +1,5 @@
|
||||||
Comments:
|
Comments:
|
||||||
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/proposal
|
|
||||||
title: Offre commerciale
|
|
||||||
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: >
|
|
||||||
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-12-18T16:20:04+01:00
|
|
||||||
id: 6dbb6d56-a6b7-467b-8341-3d8112a73684
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "73.3181571571"
|
|
||||||
y: "27.272727272727"
|
|
||||||
type: comment
|
|
||||||
replies: [ ]
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/proposal
|
|
||||||
title: Offre commerciale
|
|
||||||
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: >
|
|
||||||
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: '43.56742057598'
|
|
||||||
y: '65.340909090909'
|
|
||||||
type: comment
|
|
||||||
replies: [ ]
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Cover: - file://wS6ILTHIDQb1DHJN
|
Cover: - file://wS6ILTHIDQb1DHJN
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,28 @@ namespace adrienpayet\D2P\data;
|
||||||
class Position
|
class Position
|
||||||
{
|
{
|
||||||
public int $pageIndex;
|
public int $pageIndex;
|
||||||
public float $x;
|
public ?float $x = null;
|
||||||
public float $y;
|
public ?float $y = null;
|
||||||
|
|
||||||
public function __construct(array $data)
|
public function __construct(array $data)
|
||||||
{
|
{
|
||||||
$this->pageIndex = $data['pageIndex'];
|
$this->pageIndex = $data['pageIndex'];
|
||||||
$this->x = (float) $data['x'];
|
if (isset($data["x"])) {
|
||||||
$this->y = (float) $data['y'];
|
$this->x = (float) $data['x'];
|
||||||
|
$this->y = (float) $data['y'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
return [
|
$array = [
|
||||||
"pageIndex" => $this->pageIndex,
|
"pageIndex" => $this->pageIndex,
|
||||||
"x" => $this->x,
|
|
||||||
"y" => $this->y,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($this->x) {
|
||||||
|
$array["x"] = $this->x;
|
||||||
|
$array["y"] = $this->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ class Location
|
||||||
protected ?string $dialogUri = null;
|
protected ?string $dialogUri = null;
|
||||||
protected ProjectDetails $project;
|
protected ProjectDetails $project;
|
||||||
protected ?FileDetails $file = null;
|
protected ?FileDetails $file = null;
|
||||||
|
protected ?string $parentCommentId = null;
|
||||||
|
|
||||||
public function __construct(array $data)
|
public function __construct(array $data)
|
||||||
{
|
{
|
||||||
|
|
@ -18,6 +19,17 @@ class Location
|
||||||
if (isset($data['file'])) {
|
if (isset($data['file'])) {
|
||||||
$this->file = new FileDetails($data["file"]);
|
$this->file = new FileDetails($data["file"]);
|
||||||
}
|
}
|
||||||
|
if (isset($data["parentCommentId"])) {
|
||||||
|
$this->parentCommentId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParentCommentId($id) {
|
||||||
|
$this->parentCommentId = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parentId() {
|
||||||
|
return $this->parentCommentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
|
|
@ -28,6 +40,9 @@ class Location
|
||||||
|
|
||||||
if ($this->dialogUri) {
|
if ($this->dialogUri) {
|
||||||
$array["dialogUri"] = $this->dialogUri;
|
$array["dialogUri"] = $this->dialogUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->file) {
|
||||||
$array["file"] = $this->file;
|
$array["file"] = $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@ return [
|
||||||
"type" => "comment",
|
"type" => "comment",
|
||||||
];
|
];
|
||||||
|
|
||||||
$user->sendNotification($project, $commentData);
|
|
||||||
|
|
||||||
$newComment = new Comment($commentData);
|
$newComment = new Comment($commentData);
|
||||||
|
|
||||||
$comments[] = $newComment->toArray();
|
$comments[] = $newComment->toArray();
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@ return [
|
||||||
$json = file_get_contents('php://input');
|
$json = file_get_contents('php://input');
|
||||||
$data = json_decode($json);
|
$data = json_decode($json);
|
||||||
|
|
||||||
$parsedUrl = parse_url($data->path);
|
$parsedUrl = parse_url($data->dialogUri);
|
||||||
$query = $parsedUrl['query'] ?? null;
|
$query = $parsedUrl['query'] ?? null;
|
||||||
parse_str($query, $queryParams);
|
parse_str($query, $queryParams);
|
||||||
$stepSlug = $queryParams['dialog'] ?? null;
|
$stepSlug = $queryParams['dialog'] ?? null;
|
||||||
|
|
||||||
$targetPageUri = $stepSlug ? $parsedUrl['path'] . '/' . $stepSlug : $parsedUrl['path'];
|
$targetPageUri = $stepSlug ? $parsedUrl['path'] . '/' . $stepSlug : $parsedUrl['path'];
|
||||||
|
|
||||||
|
$project = page($parsedUrl['path']);
|
||||||
$page = page($targetPageUri);
|
$page = page($targetPageUri);
|
||||||
$file = $page->file($data->fileName);
|
$file = $page->file($data->fileName);
|
||||||
$user = kirby()->user($data->userUuid);
|
$user = kirby()->user($data->userUuid);
|
||||||
|
|
@ -23,22 +24,25 @@ return [
|
||||||
|
|
||||||
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||||
|
|
||||||
$data = [
|
$replyData = [
|
||||||
'href' => $data->path,
|
"location" => [
|
||||||
'page' => $page,
|
"page" => $page,
|
||||||
'parentId' => $data->parentId,
|
"project" => $project,
|
||||||
'file' => $file,
|
"dialogUri" => $data->dialogUri,
|
||||||
'position' => [
|
"file" => $file,
|
||||||
'pageIndex' => $data->position->pageIndex,
|
|
||||||
],
|
],
|
||||||
'text' => $data->text,
|
"parentId" => $data->parentId,
|
||||||
'author' => $user,
|
"position" => [
|
||||||
'date' => (string) $data->date,
|
"pageIndex" => $data->position->pageIndex,
|
||||||
'id' => $data->id,
|
],
|
||||||
'type' => 'comment'
|
"date" => (string) $data->date,
|
||||||
|
"text" => $data->text,
|
||||||
|
"author" => kirby()->user(),
|
||||||
|
"id" => Str::uuid(),
|
||||||
|
"type" => "comment",
|
||||||
];
|
];
|
||||||
|
|
||||||
$newReply = new Reply($data);
|
$newReply = new Reply($replyData);
|
||||||
|
|
||||||
foreach ($comments as &$comment) {
|
foreach ($comments as &$comment) {
|
||||||
if ($comment['id'] === $newReply->parentId()) {
|
if ($comment['id'] === $newReply->parentId()) {
|
||||||
|
|
@ -50,7 +54,7 @@ return [
|
||||||
'comments' => $comments
|
'comments' => $comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->sendNotification($page->parent(), $newReply->toArray());
|
$user->sendNotification($project, $replyData);
|
||||||
|
|
||||||
return getFileData($newFile);
|
return getFileData($newFile);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,16 @@
|
||||||
namespace adrienpayet\comments;
|
namespace adrienpayet\comments;
|
||||||
use adrienpayet\D2P\data\location\Location;
|
use adrienpayet\D2P\data\location\Location;
|
||||||
use adrienpayet\D2P\data\Author;
|
use adrienpayet\D2P\data\Author;
|
||||||
|
use adrienpayet\D2P\data\Position;
|
||||||
|
|
||||||
class BaseComment {
|
class BaseComment {
|
||||||
protected string $type;
|
protected string $type;
|
||||||
protected Location $location;
|
protected Location $location;
|
||||||
protected string $text;
|
|
||||||
protected Author $author;
|
protected Author $author;
|
||||||
|
protected string $text;
|
||||||
protected string $date;
|
protected string $date;
|
||||||
protected string $id;
|
protected string $id;
|
||||||
|
protected Position $position;
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
$this->location = new Location($data["location"]);
|
$this->location = new Location($data["location"]);
|
||||||
|
|
@ -18,11 +20,13 @@ class BaseComment {
|
||||||
$this->author = new Author($data["author"]);
|
$this->author = new Author($data["author"]);
|
||||||
$this->date = $data["date"];
|
$this->date = $data["date"];
|
||||||
$this->id = $data["id"];
|
$this->id = $data["id"];
|
||||||
|
$this->position = new Position($data['position']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
return [
|
return [
|
||||||
"location" => $this->location->toArray(),
|
"location" => $this->location->toArray(),
|
||||||
|
"position" => $this->position->toArray(),
|
||||||
"text" => $this->text,
|
"text" => $this->text,
|
||||||
"author" => $this->author->toArray(),
|
"author" => $this->author->toArray(),
|
||||||
"date" => $this->date,
|
"date" => $this->date,
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\comments;
|
namespace adrienpayet\comments;
|
||||||
use adrienpayet\D2P\data\Position;
|
|
||||||
|
|
||||||
class Comment extends BaseComment
|
class Comment extends BaseComment
|
||||||
{
|
{
|
||||||
protected ?Position $position = null;
|
|
||||||
protected string $type = "comment";
|
protected string $type = "comment";
|
||||||
protected array $replies = [];
|
protected array $replies = [];
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
if (isset($data["position"])) {
|
|
||||||
$this->position = new Position($data['position']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
$array = parent::toArray();
|
$array = parent::toArray();
|
||||||
$array['position'] = $this->position;
|
|
||||||
$array['type'] = $this->type;
|
$array['type'] = $this->type;
|
||||||
$array['replies'] = $this->replies;
|
$array['replies'] = $this->replies;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,20 @@ namespace adrienpayet\comments;
|
||||||
|
|
||||||
class Reply extends BaseComment {
|
class Reply extends BaseComment {
|
||||||
|
|
||||||
protected $parentId;
|
protected string $type = "comment-reply";
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
$this->parentId = $data['parentId'];
|
$this->location->setParentCommentId($data["parentId"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function parentId() {
|
public function parentId() {
|
||||||
return $this->parentId;
|
return $this->location->parentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
$array = parent::toArray();
|
$array = parent::toArray();
|
||||||
$array['parentId'] = $this->parentId;
|
$array['type'] = $this->type;
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ const draftComment = ref(null);
|
||||||
|
|
||||||
const isViewerDisabled = ref(false);
|
const isViewerDisabled = ref(false);
|
||||||
|
|
||||||
|
watch(openedFile, () => {
|
||||||
|
removeCommentMarkers();
|
||||||
|
setCommentMarkers();
|
||||||
|
});
|
||||||
|
|
||||||
watch(isCommentsOpen, (newVal) => {
|
watch(isCommentsOpen, (newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
setCommentMarkers();
|
setCommentMarkers();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue