read read notification in front end working
This commit is contained in:
parent
fe56312f20
commit
583daa1759
6 changed files with 35 additions and 57 deletions
|
|
@ -27,30 +27,8 @@ Comments:
|
||||||
role: admin
|
role: admin
|
||||||
position:
|
position:
|
||||||
pageIndex: 1
|
pageIndex: 1
|
||||||
x: "34.157449699143"
|
x: '25.96184356358'
|
||||||
y: "50.965250965251"
|
y: '22.393822393822'
|
||||||
date: 2024-11-17T11:51:35+01:00
|
date: 2024-11-17T12:13:39+01:00
|
||||||
id: m3lh8h5h
|
id: m3li0uhb
|
||||||
type: comment
|
type: comment
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
replies: [ ]
|
|
||||||
text: deuxième commentaire
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: '84.696990994209'
|
|
||||||
y: '56.949806949807'
|
|
||||||
date: 2024-11-17T11:59:37+01:00
|
|
||||||
id: m3lhisy6
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
|
|
@ -43,7 +43,6 @@ class BaseComment {
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->isRead = false;
|
|
||||||
$this->position = $position;
|
$this->position = $position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,20 +78,6 @@ class BaseComment {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRead() {
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function read() {
|
|
||||||
$this->isRead = true;
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unread() {
|
|
||||||
$this->isRead = false;
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pageIndex() {
|
public function pageIndex() {
|
||||||
$this->position['pageIndex'];
|
$this->position['pageIndex'];
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +93,6 @@ class BaseComment {
|
||||||
'date' => $this->date,
|
'date' => $this->date,
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'isRead' => $this->isRead
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ return function($project, $notificationId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Réindexation et ré-encodage en YAML avant la mise à jour
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'notifications' => Yaml::encode(array_values($notifications))
|
'notifications' => Yaml::encode(array_values($notifications))
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return function ($projectUri, $notificationData) {
|
return function ($projectUri, $notificationData) {
|
||||||
|
$notificationData['isRead'] = false;
|
||||||
$recipients = page($projectUri)->managers()->toUsers()->not($this);
|
$recipients = page($projectUri)->managers()->toUsers()->not($this);
|
||||||
|
|
||||||
if (!$recipients) return;
|
if (!$recipients) return;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<article
|
<article
|
||||||
:id="`comment-${comment.id}`"
|
:id="`comment-${comment.id}`"
|
||||||
class="comment | flow"
|
class="comment | flow"
|
||||||
:data-status="setStatus(comment)"
|
:data-status="status"
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -53,6 +53,7 @@ import "dayjs/locale/fr";
|
||||||
import { useUserStore } from "../../stores/user";
|
import { useUserStore } from "../../stores/user";
|
||||||
import { useApiStore } from "../../stores/api";
|
import { useApiStore } from "../../stores/api";
|
||||||
import { useDialogStore } from "../../stores/dialog";
|
import { useDialogStore } from "../../stores/dialog";
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
dayjs.locale("fr");
|
dayjs.locale("fr");
|
||||||
|
|
||||||
|
|
@ -68,17 +69,13 @@ const api = useApiStore();
|
||||||
const dialog = useDialogStore();
|
const dialog = useDialogStore();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function setStatus(comment) {
|
const status = computed(() => {
|
||||||
try {
|
const correspondingNotification = user.notifications.find(
|
||||||
if (!user?.notifications?.comments[comment.id].isRead) {
|
(notification) => notification.id === comment.id
|
||||||
return "unread";
|
);
|
||||||
} else {
|
if (!correspondingNotification) return undefined;
|
||||||
return undefined;
|
return correspondingNotification.isRead ? undefined : "unread";
|
||||||
}
|
});
|
||||||
} catch (error) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
const todayNumber = parseInt(dayjs().format("YYMMD"));
|
const todayNumber = parseInt(dayjs().format("YYMMD"));
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@
|
||||||
:comment="comment"
|
:comment="comment"
|
||||||
:commentIndex="comments.length - commentIndex"
|
:commentIndex="comments.length - commentIndex"
|
||||||
:key="comment.id"
|
:key="comment.id"
|
||||||
@click="openedComment = comment"
|
@click="
|
||||||
|
readNotification(comment);
|
||||||
|
openComment(comment);
|
||||||
|
"
|
||||||
@update:file="changeFile"
|
@update:file="changeFile"
|
||||||
@close:comment="closeComment"
|
@close:comment="closeComment"
|
||||||
/>
|
/>
|
||||||
|
|
@ -244,6 +247,22 @@ function handleCommentPositionClick(event) {
|
||||||
isAddOpen.value = true;
|
isAddOpen.value = true;
|
||||||
toggleCommentPositionMode(false);
|
toggleCommentPositionMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readNotification(comment) {
|
||||||
|
const correspondingNotification = user.notifications.find(
|
||||||
|
(notification) => notification.id === comment.id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (correspondingNotification) {
|
||||||
|
correspondingNotification.isRead = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openComment(comment) {
|
||||||
|
if (comment.replies.length) {
|
||||||
|
openedComment.value = comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue