2023-03-24 17:42:37 +08:00
|
|
|
<template>
|
|
|
|
<div class="sci--navigation--notificaitons-flyout">
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-title">
|
|
|
|
{{ i18n.t('nav.notifications.title') }}
|
|
|
|
<i class="fas fa-times" @click="$emit('close')"></i>
|
|
|
|
</div>
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-tabs">
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-tab"
|
2023-04-06 20:57:00 +08:00
|
|
|
@click="setActiveTab('all')"
|
2023-03-24 17:42:37 +08:00
|
|
|
:class="{'active': activeTab == 'all'}">
|
|
|
|
{{ i18n.t('nav.notifications.all') }}
|
|
|
|
</div>
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-tab"
|
2023-04-06 20:57:00 +08:00
|
|
|
@click="setActiveTab('message')"
|
2023-03-24 17:42:37 +08:00
|
|
|
:class="{'active': activeTab == 'message'}">
|
|
|
|
{{ i18n.t('nav.notifications.message') }}
|
|
|
|
</div>
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-tab"
|
2023-04-06 20:57:00 +08:00
|
|
|
@click="setActiveTab('system')"
|
2023-03-24 17:42:37 +08:00
|
|
|
:class="{'active': activeTab == 'system'}">
|
|
|
|
{{ i18n.t('nav.notifications.system') }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div class="sci--navigation--notificaitons-flyout-notifications">
|
|
|
|
<div class="sci-navigation--notificaitons-flyout-subtitle" v-if="todayNotifications.length" >
|
|
|
|
{{ i18n.t('nav.notifications.today') }}
|
|
|
|
</div>
|
2023-04-06 20:57:00 +08:00
|
|
|
<NotificationItem v-for="notification in todayNotifications" :key="notification.type_of + '-' + notification.id" :notification="notification" />
|
2023-03-24 17:42:37 +08:00
|
|
|
<div class="sci-navigation--notificaitons-flyout-subtitle" v-if="olderNotifications.length" >
|
|
|
|
{{ i18n.t('nav.notifications.older') }}
|
|
|
|
</div>
|
2023-04-06 20:57:00 +08:00
|
|
|
<NotificationItem v-for="notification in olderNotifications" :key="notification.type_of + '-' + notification.id" :notification="notification" />
|
2023-03-24 17:42:37 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2023-03-30 19:27:10 +08:00
|
|
|
import NotificationItem from './notification_item.vue'
|
2023-03-24 17:42:37 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'NotificationsFlyout',
|
|
|
|
components: {
|
|
|
|
NotificationItem
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
notificationsUrl: String
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
notifications: [],
|
|
|
|
activeTab: 'all',
|
|
|
|
nextPage: 2
|
|
|
|
}
|
|
|
|
},
|
2023-04-06 20:57:00 +08:00
|
|
|
created() {
|
|
|
|
this.loadNotifications();
|
2023-03-24 17:42:37 +08:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filteredNotifications() {
|
2023-04-06 20:57:00 +08:00
|
|
|
this.loadNotifications();
|
2023-03-24 17:42:37 +08:00
|
|
|
},
|
|
|
|
todayNotifications() {
|
|
|
|
let startOfDay = (new Date()).setUTCHours(0, 0, 0, 0);
|
2023-04-06 20:57:00 +08:00
|
|
|
return this.notifications.filter(n => moment(n.created_at) >= startOfDay);
|
2023-03-24 17:42:37 +08:00
|
|
|
},
|
|
|
|
olderNotifications() {
|
|
|
|
let startOfDay = (new Date()).setUTCHours(0, 0, 0, 0);
|
2023-04-06 20:57:00 +08:00
|
|
|
return this.notifications.filter(n => moment(n.created_at) < startOfDay);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setActiveTab(selection) {
|
|
|
|
this.activeTab = selection;
|
|
|
|
this.loadNotifications();
|
|
|
|
},
|
|
|
|
loadNotifications() {
|
|
|
|
$.getJSON(this.notificationsUrl, { type: this.activeTab }, (result) => {
|
|
|
|
this.notifications = result.notifications;
|
|
|
|
});
|
2023-03-24 17:42:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|