diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue
index 2a4982fce..96d52b98c 100644
--- a/src/components/CrudModel.vue
+++ b/src/components/CrudModel.vue
@@ -89,6 +89,7 @@ async function fetch(data) {
watch(formData, () => (hasChanges.value = true), { deep: true });
emit('onFetch', data);
+ return data;
}
async function reset() {
diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue
index 03948318e..1b3cf1704 100644
--- a/src/pages/Worker/Card/WorkerNotificationsManager.vue
+++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue
@@ -14,35 +14,38 @@ const $props = defineProps({
default: null,
},
});
-const entityId = computed(() => $props.id || route.params.id);
-
-onUpdated(() => console.log('updated'));
const route = useRoute();
const { t } = useI18n();
const quasar = useQuasar();
+const entityId = computed(() => $props.id || route.params.id);
+const notifications = ref();
async function toggleNotification(notification) {
+ let data = {};
if (notification.active) {
await axios.delete(`NotificationSubscriptions/${notification.id}`);
- notification.id = null;
- notification.active = false;
- return quasar.notify({
- type: 'positive',
- message: t('worker.notificationsManager.unsubscribed'),
+ } else {
+ const res = await axios.post(`NotificationSubscriptions`, {
+ notificationFk: notification.notificationFk,
+ userFk: entityId.value,
});
+ data = res.data;
}
- const { data } = await axios.post(`NotificationSubscriptions`, {
- notificationFk: notification.notificationFk,
- userFk: entityId.value,
- });
-
notification.id = data.id;
+ notification.active = !notification.active;
quasar.notify({
type: 'positive',
- message: t('worker.notificationsManager.subscribed'),
+ message: t(
+ `worker.notificationsManager.${notification.active ? 'un' : ''}subscribed`
+ ),
});
+ orderNotification(notifications.value);
+}
+
+function orderNotification(data) {
+ notifications.value = data.sort((notification) => -+notification.active);
}
@@ -51,98 +54,55 @@ async function toggleNotification(notification) {
auto-load
data-key="NotificationSubscriptions"
:url="`NotificationSubscriptions/${entityId}/getList`"
+ :default-reset="false"
:default-remove="false"
+ :default-save="false"
+ @on-fetch="orderNotification"
>
-
-
-
-
-
-
-
-
- {{ row.name }}
- {{ row.description }}
-
-
-
-
-
-
-
+
+
+
+
+
-