forked from misterGF/CoPilot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotificationsMenu.vue
More file actions
115 lines (110 loc) · 3.63 KB
/
Copy pathNotificationsMenu.vue
File metadata and controls
115 lines (110 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
<li class="dropdown notifications-menu">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">{{ newNotifications | count }}</span>
</a>
<ul class="dropdown-menu">
<li class="header">
<div class="row no-margin">
<span class="col-xs-12 col-md-6 tab-link" :class="{active: tab === 'new'}" @click="switchTab($event, 'new')">
<a href="javascript:;">New</a>
</span>
<span class="col-xs-12 col-md-6 tab-link" :class="{active: tab === 'old'}" @click="switchTab($event, 'old')">
<a href="javascript:;">Old</a>
</span>
</div>
</li>
<li>
<ul v-if="tab === 'new'" class="menu">
<notification-item v-for="notification in newNotifications" :key="notification.id" :notification="notification"></notification-item>
<li v-if="!newNotifications.length">
<span class="center-block text-center">There are no new notifications</span>
</li>
</ul>
<ul v-if="tab === 'old'" class="menu">
<notification-item v-for="notification in oldNotifications" :key="notification.id" :notification="notification"></notification-item>
<li v-if="!oldNotifications.length">
<span class="center-block text-center">There are no old notifications</span>
</li>
</ul>
</li>
<li v-if="newNotifications.length && tab === 'new'" class="footer">
<a href="javascript:;" @click="markAllAsRead">
<i class="fa fa-check"></i>
<span>Mark all as read</span>
</a>
</li>
</ul>
</li>
</template>
<script>
import { mapState } from 'vuex'
import NotificationItem from './NotificationItem'
export default {
name: 'NotificationsMenu',
components: {
NotificationItem
},
data() {
return {
tab: 'new'
}
},
computed: {
...mapState([
'userInfo'
]),
newNotifications() {
return this.userInfo.notifications.filter(n => !n.readAt)
},
oldNotifications() {
return this.userInfo.notifications.filter(n => n.readAt)
}
},
methods: {
markAllAsRead() {
event.stopPropagation()
this.userInfo.notifications.filter(n => !n.readAt).forEach(function(notification) {
notification.readAt = new Date().toUTCString
})
},
switchTab(event, tab) {
event.stopPropagation()
this.tab = tab
}
}
}
</script>
<style scoped>
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu {
width: 400px;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li.header {
padding: 0;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li.header span.tab-link {
padding: 4px;
text-align: center;
cursor: pointer;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li.header span.tab-link a {
color: #444;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li.header span.tab-link.active {
font-weight: bold;
border-bottom: 2px solid #3c8dbc;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li.header span:hover.tab-link > a {
color: #3c8dbc !important;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li > ul.menu {
max-height: 300px;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li > ul.menu li > span {
padding: 10px;
}
.navbar-custom-menu > .navbar-nav > li.notifications-menu > .dropdown-menu li:hover.footer > a {
color: #3c8dbc !important;
}
</style>