From b155547702236bb278da006f504c4a0c603434a0 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 24 Nov 2022 10:05:46 +0100 Subject: [PATCH] refs #4797 @30min disable modifications if user is not the one editing --- .../Worker/Card/WorkerNotificationsManager.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index eca1c38de..6d302717c 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -49,8 +49,13 @@ const workerFilter = { }; const notificationAcls = ref([]); +const allowedEditing = ref(false); async function fetch() { + const token = await getToken(); + + const tokenUser = await axios.get(`AccessTokens/${token}/user`); + const { data } = await axios.get(`Workers/${entityId.value}`, { params: { filter: JSON.stringify(workerFilter), @@ -137,7 +142,6 @@ async function fetch() { }); } - // Check if notification is already in the array let found = false; notifications.forEach((notif) => { if (notif.id == notification.id) { @@ -151,8 +155,6 @@ async function fetch() { } notifications.push(notification); } else { - // Check if current notification is allowed and the other one is not - // If so, replace the existing one with the current one notifications.forEach((notif) => { if (notif.id == notification.id) { if (notification.allowed && !notif.allowed) { @@ -169,6 +171,10 @@ async function fetch() { console.log(e); } + if (tokenUser.data.id == data.user.id) { + allowedEditing.value = true; + } + worker.value = data; } @@ -238,6 +244,7 @@ async function toggleNotif(notif, chip) {