diff options
author | Jonathan Baird <jonathan@smithbox.com> | 2020-03-27 11:35:03 -0600 |
---|---|---|
committer | Jonathan Baird <jonathan@smithbox.com> | 2020-03-27 11:35:03 -0600 |
commit | 9819c9f801128d07374b0703b482bdb83a672297 (patch) | |
tree | a132421f72031a26b346a96fd9a4615b2bca70c9 /client/components/notifications/notifications.js | |
parent | 29d62440a5cf82b01de8183a384c6d7811abad81 (diff) | |
download | wekan-9819c9f801128d07374b0703b482bdb83a672297.tar.gz wekan-9819c9f801128d07374b0703b482bdb83a672297.tar.bz2 wekan-9819c9f801128d07374b0703b482bdb83a672297.zip |
add a notification drawer like trello
Diffstat (limited to 'client/components/notifications/notifications.js')
-rw-r--r-- | client/components/notifications/notifications.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/client/components/notifications/notifications.js b/client/components/notifications/notifications.js new file mode 100644 index 00000000..c0aa6cb5 --- /dev/null +++ b/client/components/notifications/notifications.js @@ -0,0 +1,32 @@ +// this hides the notifications drawer if anyone clicks off of the panel +Template.body.events({ + click(event) { + if ( + !$(event.target).is('#notifications *') && + Session.get('showNotificationsDrawer') + ) { + toggleNotificationsDrawer(); + } + }, +}); + +Template.notifications.helpers({ + unreadNotifications() { + const notifications = Users.findOne(Meteor.userId()).notifications(); + const unreadNotifications = _.filter(notifications, v => !v.read); + return unreadNotifications.length; + }, +}); + +Template.notifications.events({ + 'click .notifications-drawer-toggle'() { + toggleNotificationsDrawer(); + }, +}); + +export function toggleNotificationsDrawer() { + Session.set( + 'showNotificationsDrawer', + !Session.get('showNotificationsDrawer'), + ); +} |