sort notifications
This commit is contained in:
parent
9752fffae6
commit
a1fa535123
1 changed files with 17 additions and 9 deletions
|
|
@ -4,13 +4,13 @@
|
||||||
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
|
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
|
||||||
<button
|
<button
|
||||||
class="btn | absolute top-0 right-gutter"
|
class="btn | absolute top-0 right-gutter"
|
||||||
:disabled="!notifications.length"
|
:disabled="!sortedNotifications.length"
|
||||||
>
|
>
|
||||||
Marquer tout come lu
|
Marquer tout come lu
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="notifications.length === 0"
|
v-if="sortedNotifications.length === 0"
|
||||||
class="flex flex-col justify-center | text-grey-700 | absolute inset-0 -z-1"
|
class="flex flex-col justify-center | text-grey-700 | absolute inset-0 -z-1"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
|
|
@ -32,7 +32,10 @@
|
||||||
<p>Vous n’avez pas de nouvelles notifications</p>
|
<p>Vous n’avez pas de nouvelles notifications</p>
|
||||||
</div>
|
</div>
|
||||||
<section v-else class="notifications | flow">
|
<section v-else class="notifications | flow">
|
||||||
<template v-for="notification in notifications" :key="notification.id">
|
<template
|
||||||
|
v-for="notification in sortedNotifications"
|
||||||
|
:key="notification.id"
|
||||||
|
>
|
||||||
<router-link
|
<router-link
|
||||||
v-if="currentTab === 'all' || !notification.isRead"
|
v-if="currentTab === 'all' || !notification.isRead"
|
||||||
:to="notification.page.uri + '?fileUuid=' + notification.file.uuid"
|
:to="notification.page.uri + '?fileUuid=' + notification.file.uuid"
|
||||||
|
|
@ -132,17 +135,22 @@ const tabs = computed(() => {
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
const allNotifications = computed(() => {
|
const sortedNotifications = computed(() => {
|
||||||
return Object.values(notifications.value);
|
const allNotifications = [
|
||||||
|
...Object.values(notifications.value.comments || {}),
|
||||||
|
...Object.values(notifications.value.content || {}),
|
||||||
|
];
|
||||||
|
|
||||||
|
const sortedNotifications = allNotifications.sort((a, b) => {
|
||||||
|
dayjs(b.date).diff(dayjs(a.date));
|
||||||
|
});
|
||||||
|
|
||||||
|
return sortedNotifications;
|
||||||
});
|
});
|
||||||
|
|
||||||
function changeTab(newValue) {
|
function changeTab(newValue) {
|
||||||
currentTab.value = newValue;
|
currentTab.value = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isEmpty = computed(() => {
|
|
||||||
return notifications.value.length === 0;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue