refs #4797 @30min disable modifications if user is not the one editing
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Pau 2022-11-24 10:05:46 +01:00
parent cbeeea8f88
commit b155547702
1 changed files with 11 additions and 4 deletions

View File

@ -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) {
<q-item>
<div v-for="notif in notificationAcls" :key="notif.id">
<q-chip
:disable="!allowedEditing"
v-if="notif.active"
:key="notif.id"
:label="notif.name"
@ -266,7 +273,7 @@ async function toggleNotif(notif, chip) {
</q-item-section>
<q-item-section side top>
<q-toggle
:disable="!notif.allowed"
:disable="!notif.allowed || !allowedEditing"
checked-icon="check"
unchecked-icon="close"
indeterminate-icon="block"