add isloading
gitea/salix-front/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pau 2023-01-25 08:27:45 +01:00
parent 9e0adce4f1
commit 88e8530b43
1 changed files with 6 additions and 3 deletions

View File

@ -50,8 +50,10 @@ const workerFilter = {
}; };
const notificationAcls = ref([]); const notificationAcls = ref([]);
const isLoading = ref(false);
async function fetch() { async function fetch() {
isLoading.value = true;
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),
@ -168,6 +170,7 @@ async function fetch() {
} }
worker.value = data; worker.value = data;
isLoading.value = false;
} }
function sortNotifs() { function sortNotifs() {
@ -193,7 +196,7 @@ async function toggleNotif(notif, chip) {
notif.active = !notif.active; notif.active = !notif.active;
} }
if (notif.active) { if (notif.active) {
let notificationSubscription = await axios.post( await axios.post(
`NotificationSubscriptions`, `NotificationSubscriptions`,
{ {
notificationFk: notif.id, notificationFk: notif.id,
@ -205,7 +208,6 @@ async function toggleNotif(notif, chip) {
}, },
} }
); );
worker.value.subscribedNotifs.push(notificationSubscription.data);
quasar.notify({ quasar.notify({
type: 'positive', type: 'positive',
message: t('worker.notificationsManager.subscribed'), message: t('worker.notificationsManager.subscribed'),
@ -227,6 +229,7 @@ async function toggleNotif(notif, chip) {
message: t('worker.notificationsManager.unsubscribed'), message: t('worker.notificationsManager.unsubscribed'),
}); });
} }
await fetch();
} }
</script> </script>
<template> <template>
@ -269,7 +272,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 || isLoading"
checked-icon="check" checked-icon="check"
unchecked-icon="close" unchecked-icon="close"
indeterminate-icon="block" indeterminate-icon="block"