comment 360 working
This commit is contained in:
parent
bc0ae8861f
commit
4daaa3dc88
8 changed files with 134 additions and 91 deletions
|
|
@ -1 +1,34 @@
|
|||
Comments:
|
||||
|
||||
-
|
||||
location:
|
||||
page:
|
||||
uri: >
|
||||
projects/miss-dior-blooming-bouquet/virtual-sample/piste-1
|
||||
title: Piste 1
|
||||
project:
|
||||
title: Miss Dior Blooming Bouquet
|
||||
uri: projects/miss-dior-blooming-bouquet
|
||||
dialogUri: >
|
||||
/projects/miss-dior-blooming-bouquet?dialog=virtual-sample
|
||||
file:
|
||||
uuid: file://J9q2ceZL2aW19oEU
|
||||
url: >
|
||||
http://localhost:8888/media/pages/projects/miss-dior-blooming-bouquet/virtual-sample/piste-1/f26b2c223b-1733765560/0_6.png
|
||||
position:
|
||||
x: '50.119047619048'
|
||||
y: '42.563482466747'
|
||||
text: test
|
||||
author:
|
||||
name: Adrien Payet
|
||||
email: adrien.payet@outlook.com
|
||||
uuid: user://WWjXgPWk
|
||||
role: admin
|
||||
date: 2024-12-19T16:49:15+01:00
|
||||
id: 4b311fe6-a6e4-486f-a9ce-b8820a234e2e
|
||||
type: comment
|
||||
replies: [ ]
|
||||
|
||||
----
|
||||
|
||||
Uuid: J9q2ceZL2aW19oEU
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Uuid: WrFkfiMVZuxwdYad
|
||||
Comments:
|
||||
|
||||
----
|
||||
|
||||
Comments:
|
||||
Uuid: WrFkfiMVZuxwdYad
|
||||
3
public/site/blueprints/files/default.yml
Normal file
3
public/site/blueprints/files/default.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fields:
|
||||
comments:
|
||||
type: hidden
|
||||
|
|
@ -9,17 +9,11 @@ return [
|
|||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$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);
|
||||
$page = page($data->fileParentUri);
|
||||
$project = $page->parent()->template() == "project" ? $page->parent() : $page->parent()->parent();
|
||||
$file = $page->file($data->fileName);
|
||||
$user = kirby()->user($data->userUuid);
|
||||
|
||||
|
||||
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||
|
||||
|
|
@ -41,13 +35,13 @@ return [
|
|||
"type" => "comment",
|
||||
];
|
||||
|
||||
if ($data->position->pageIndex) {
|
||||
if (isset($data->position->pageIndex)) {
|
||||
$commentData["position"]["pageIndex"] = $data->position->pageIndex;
|
||||
}
|
||||
|
||||
$newComment = new Comment($commentData);
|
||||
|
||||
$comments[] = $newComment->toArray();
|
||||
$comments[] = $newComment->toArray();
|
||||
|
||||
$newFile = $file->update([
|
||||
'comments' => $comments
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function getFileData($file) {
|
|||
$data['tags'] = $file->tags()->split();
|
||||
};
|
||||
|
||||
if($file->extension() == "pdf") {
|
||||
if($file->comments()->exists()) {
|
||||
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
|
||||
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue