forked from verdnatura/salix-front
changed the boss or user check to the backend
This commit is contained in:
parent
f98c82185f
commit
3824ea62c9
|
@ -3,7 +3,6 @@ import { onMounted, computed, ref, onUpdated } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
@ -22,7 +21,6 @@ const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { getToken } = useSession();
|
const { getToken } = useSession();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const state = useState();
|
|
||||||
|
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
|
@ -52,7 +50,6 @@ const workerFilter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const notificationAcls = ref([]);
|
const notificationAcls = ref([]);
|
||||||
const allowedEditing = ref(false);
|
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
const { data } = await axios.get(`Workers/${entityId.value}`, {
|
const { data } = await axios.get(`Workers/${entityId.value}`, {
|
||||||
|
@ -170,10 +167,6 @@ async function fetch() {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.getUser().value.id == data.user.id) {
|
|
||||||
allowedEditing.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
worker.value = data;
|
worker.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,13 +210,24 @@ async function toggleNotif(notif, chip) {
|
||||||
message: t('worker.notificationsManager.subscribed'),
|
message: t('worker.notificationsManager.subscribed'),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await axios.post(`NotificationSubscriptions/deleteSubscription`, {
|
const token = await getToken();
|
||||||
notificationId: notif.id + '',
|
|
||||||
userId: entityId.value,
|
const tokenUser = await axios.get(`AccessTokens/${token}/user`);
|
||||||
headers: {
|
console.log(tokenUser);
|
||||||
Authorization: getToken(),
|
|
||||||
|
await axios.post(
|
||||||
|
`NotificationSubscriptions/deleteNotification`,
|
||||||
|
{
|
||||||
|
userId: entityId.value,
|
||||||
|
notificationId: notif.id,
|
||||||
|
authorId: tokenUser.data.id,
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: getToken(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
quasar.notify({
|
quasar.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
message: t('worker.notificationsManager.unsubscribed'),
|
message: t('worker.notificationsManager.unsubscribed'),
|
||||||
|
@ -243,7 +247,6 @@ 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"
|
||||||
|
@ -272,7 +275,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 || !allowedEditing"
|
:disable="!notif.allowed"
|
||||||
checked-icon="check"
|
checked-icon="check"
|
||||||
unchecked-icon="close"
|
unchecked-icon="close"
|
||||||
indeterminate-icon="block"
|
indeterminate-icon="block"
|
||||||
|
|
Loading…
Reference in New Issue