create store for comment draft

This commit is contained in:
isUnknown 2024-12-19 16:03:20 +01:00
parent 13cbfd8309
commit 94ae220174
7 changed files with 162 additions and 47 deletions

View file

@ -1,7 +1,76 @@
Comments:
-
location:
page:
uri: >
projects/projet-recharge-en-forme/extended-brief
title: Brief enrichi
project:
title: Projet Recharge en forme
uri: projects/projet-recharge-en-forme
dialogUri: >
/projects/projet-recharge-en-forme?dialog=extended-brief
file:
uuid: file://7Bqr3iCH8ltDrdGi
url: >
http://localhost:8888/media/pages/projects/projet-recharge-en-forme/extended-brief/d44de3da29-1733319278/wip-20240916-demonstrateurs-recharge-en-forme.pdf
position:
pageIndex: 1
x: "64.385025360981"
y: "48.295454545455"
text: test
author:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-12-19T16:02:45+01:00
id: ee0c6c8d-4d0f-4262-b4b7-d6c5230b2802
type: comment
replies:
-
location:
page:
uri: >
projects/projet-recharge-en-forme/extended-brief
title: Brief enrichi
project:
title: Projet Recharge en forme
uri: projects/projet-recharge-en-forme
dialogUri: >
/projects/projet-recharge-en-forme?dialog=extended-brief
file:
uuid: file://7Bqr3iCH8ltDrdGi
url: >
http://localhost:8888/media/pages/projects/projet-recharge-en-forme/extended-brief/d44de3da29-1733319278/wip-20240916-demonstrateurs-recharge-en-forme.pdf
parent:
author:
name: Adrien Payet
email: adrien.payet@outlook.com
id: ee0c6c8d-4d0f-4262-b4b7-d6c5230b2802
position:
pageIndex: 1
text: test
author:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-12-19T16:02:52+01:00
id: 3ddd2679-4c67-4efa-8492-a325fda425fb
type: comment-reply
----
Cover:
----
Label:
----
Uuid: 7Bqr3iCH8ltDrdGi
----

View file

@ -4,13 +4,15 @@ namespace adrienpayet\D2P\data;
class Position
{
public int $pageIndex;
public ?int $pageIndex = null;
public ?float $x = null;
public ?float $y = null;
public function __construct(array $data)
{
$this->pageIndex = $data['pageIndex'];
if (isset($data["pageIndex"])) {
$this->pageIndex = $data['pageIndex'];
}
if (isset($data["x"])) {
$this->x = (float) $data['x'];
$this->y = (float) $data['y'];
@ -18,9 +20,11 @@ class Position
}
public function toArray() {
$array = [
"pageIndex" => $this->pageIndex,
];
$array = [];
if ($this->pageIndex) {
$array["pageIndex"] = $this->pageIndex;
}
if ($this->x) {
$array["x"] = $this->x;

View file

@ -31,7 +31,6 @@ return [
"file" => $file
],
"position" => [
"pageIndex" => $data->position->pageIndex,
"x" => $data->position->x,
"y" => $data->position->y
],
@ -42,6 +41,10 @@ return [
"type" => "comment",
];
if ($data->position->pageIndex) {
$commentData["position"]["pageIndex"] = $data->position->pageIndex;
}
$newComment = new Comment($commentData);
$comments[] = $newComment->toArray();