comment 360 working
This commit is contained in:
parent
bc0ae8861f
commit
4daaa3dc88
8 changed files with 134 additions and 91 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue