notifications seems to work but new comments erase previous ones

This commit is contained in:
isUnknown 2024-10-28 15:55:14 +01:00
parent 44361e614d
commit 85537d3465
5 changed files with 16 additions and 130 deletions

View file

@ -13,124 +13,10 @@ Template: document
Comments:
1:
m2lyrs06:
text: nouveau commentaire
m2t543hr:
fileUuid: file://s0lNtRA0Z7ybTCWG
page: 1
text: Un autre commentaire
username: Adrien Payet
date: 2024-10-23T16:22:47+02:00
id: m2lyrs06
m2t206b6:
text: Nouveau com
username: Adrien Payet
date: 2024-10-28T14:27:41+01:00
id: m2t206b6
m2t20ei0:
text: Et ebcore
username: Adrien Payet
date: 2024-10-28T14:27:51+01:00
id: m2t20ei0
m2t213jw:
text: test2
username: Adrien Payet
date: 2024-10-28T14:28:24+01:00
id: m2t213jw
m2t21e5f:
text: autre
username: Adrien Payet
date: 2024-10-28T14:28:38+01:00
id: m2t21e5f
m2t21h7k:
text: sfgd
username: Adrien Payet
date: 2024-10-28T14:28:42+01:00
id: m2t21h7k
m2t2sgrk:
text: test3
username: Adrien Payet
date: 2024-10-28T14:49:41+01:00
id: m2t2sgrk
m2t2sn60:
text: test4
username: Adrien Payet
date: 2024-10-28T14:49:49+01:00
id: m2t2sn60
m2t2ux6u:
text: test5
username: Adrien Payet
date: 2024-10-28T14:51:35+01:00
id: m2t2ux6u
m2t2v0ba:
text: test6
username: Adrien Payet
date: 2024-10-28T14:51:39+01:00
id: m2t2v0ba
m2t2wak4:
text: test8
username: Adrien Payet
date: 2024-10-28T14:52:39+01:00
id: m2t2wak4
m2t2z30f:
text: jfhj
username: Adrien Payet
date: 2024-10-28T14:54:49+01:00
id: m2t2z30f
m2t2ze81:
text: qsvfh
username: Adrien Payet
date: 2024-10-28T14:55:04+01:00
id: m2t2ze81
m2t30udw:
text: fdgjh
username: Adrien Payet
date: 2024-10-28T14:56:12+01:00
id: m2t30udw
m2t31bxv:
text: testl
username: Adrien Payet
date: 2024-10-28T14:56:34+01:00
id: m2t31bxv
m2t32i8i:
text: dlakeja
username: Adrien Payet
date: 2024-10-28T14:57:29+01:00
id: m2t32i8i
m2t33dra:
text: hfdts
username: Adrien Payet
date: 2024-10-28T14:58:10+01:00
id: m2t33dra
m2t34im4:
text: lkqs
username: Adrien Payet
date: 2024-10-28T14:59:03+01:00
id: m2t34im4
m2t359np:
text: lqsjd
username: Adrien Payet
date: 2024-10-28T14:59:38+01:00
id: m2t359np
m2t362kx:
text: ;sjn
username: Adrien Payet
date: 2024-10-28T15:00:16+01:00
id: m2t362kx
m2t36rex:
text: jfghy
username: Adrien Payet
date: 2024-10-28T15:00:48+01:00
id: m2t36rex
m2t37dx2:
text: dkdjsfn
username: Adrien Payet
date: 2024-10-28T15:01:17+01:00
id: m2t37dx2
2:
m2lys1bs:
text: test
username: Adrien Payet
date: 2024-10-23T16:22:59+02:00
id: m2lys1bs
m2lys8xu:
text: 2e com page 2
username: Adrien Payet
date: 2024-10-23T16:23:09+02:00
id: m2lys8xu
date: 2024-10-28T15:54:43+01:00
id: m2t543hr

View file

@ -7,20 +7,20 @@ return [
$json = file_get_contents('php://input');
$data = json_decode($json);
// return json_encode($data->pageUri);
$page = page($data->pageUri);
$file = $page->file($data->fileName);
$user = kirby()->user($data->userUuid);
$comments = $file->comments()->isEmpty() == true ? [] : Data::decode($file->comments()->toArray()['comments'], 'yaml');
$comments = $file->comments()->isEmpty() == true ? [] : [];
$newComment = [
'fileUuid' => (string )$file->uuid(),
'page' => $data->targetPage,
'text' => $data->text,
'username' => $user->name()->isNotEmpty() ? (string) $user->name() : (string) $user->email(),
'date' => (string) $data->date,
'id' => $data->id
'id' => $data->id,
];
$comments[$data->targetPage][$data->id] = $newComment;

View file

@ -1,7 +1,7 @@
<?php
return [
'pattern' => '(:all)logout.php',
'pattern' => '(:all)logout',
'action' => function () {
$kirby = kirby();
$user = $kirby->user();

View file

@ -5,15 +5,15 @@ return function ($page, $kirby) {
$data['template'] = (string) $page->template();
$userData = [
"role" => $kirby->user()->role(),
"uuid" => $kirby->user()->uuid(),
"role" => (string) $kirby->user()->role(),
"uuid" => (string) $kirby->user()->uuid(),
"notifications" => Yaml::decode($kirby->user()->notifications()->value()),
];
if ($kirby->user()->role() == 'client') {
$userData['client'] = [
"name" => $kirby->user()->client()->toPage()->title(),
"uuid" => $kirby->user()->client()->toPage()->uuid()
"name" => (string) $kirby->user()->client()->toPage()->title(),
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
];
}

View file

@ -75,7 +75,7 @@
<router-link to="/profil">Profil</router-link>
</li>
<li data-icon="logout">
<router-link to="/logout">Déconnexion</router-link>
<a href="/logout">Déconnexion</a>
</li>
</ul>
</footer>