232201_dev_to_test #59

Merged
alexm merged 48 commits from dev into test 2023-06-01 07:18:41 +00:00
1 changed files with 11 additions and 4 deletions
Showing only changes of commit b155547702 - Show all commits

View File

@ -49,8 +49,13 @@ const workerFilter = {
}; };
const notificationAcls = ref([]); const notificationAcls = ref([]);
const allowedEditing = ref(false);
async function fetch() { async function fetch() {
const token = await getToken();
const tokenUser = await axios.get(`AccessTokens/${token}/user`);
const { data } = await axios.get(`Workers/${entityId.value}`, { const { data } = await axios.get(`Workers/${entityId.value}`, {
params: { params: {
filter: JSON.stringify(workerFilter), filter: JSON.stringify(workerFilter),
@ -137,7 +142,6 @@ async function fetch() {
}); });
} }
// Check if notification is already in the array
let found = false; let found = false;
notifications.forEach((notif) => { notifications.forEach((notif) => {
if (notif.id == notification.id) { if (notif.id == notification.id) {
@ -151,8 +155,6 @@ async function fetch() {
} }
notifications.push(notification); notifications.push(notification);
} else { } 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) => { notifications.forEach((notif) => {
if (notif.id == notification.id) { if (notif.id == notification.id) {
if (notification.allowed && !notif.allowed) { if (notification.allowed && !notif.allowed) {
@ -169,6 +171,10 @@ async function fetch() {
console.log(e); console.log(e);
} }
if (tokenUser.data.id == data.user.id) {
allowedEditing.value = true;
}
worker.value = data; worker.value = data;
} }
@ -238,6 +244,7 @@ async function toggleNotif(notif, chip) {
<q-item> <q-item>
<div v-for="notif in notificationAcls" :key="notif.id"> <div v-for="notif in notificationAcls" :key="notif.id">
<q-chip <q-chip
:disable="!allowedEditing"
v-if="notif.active" v-if="notif.active"
:key="notif.id" :key="notif.id"
:label="notif.name" :label="notif.name"
@ -266,7 +273,7 @@ async function toggleNotif(notif, chip) {
</q-item-section> </q-item-section>
<q-item-section side top> <q-item-section side top>
<q-toggle <q-toggle
:disable="!notif.allowed" :disable="!notif.allowed || !allowedEditing"
checked-icon="check" checked-icon="check"
unchecked-icon="close" unchecked-icon="close"
indeterminate-icon="block" indeterminate-icon="block"