From b7be74907fe13fbd301e643ed55210b449b810f0 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Thu, 17 Jul 2014 17:28:53 +0000 Subject: [PATCH] Add a notify action to the notifications component Refs #3160 - gh-notifications component now takes an optional notify parameter. If present it will be invoked as an action when a notification is added or removed. - Add a data-notification-count attribute to the main container that tracks the number of "top" notification messages that are currently being shown. --- core/client/components/gh-notifications.js | 8 ++++++-- core/client/controllers/application.js | 8 +++++++- core/client/templates/application.hbs | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/client/components/gh-notifications.js b/core/client/components/gh-notifications.js index 734e9ed660..273cccbcf7 100644 --- a/core/client/components/gh-notifications.js +++ b/core/client/components/gh-notifications.js @@ -14,7 +14,11 @@ var NotificationsComponent = Ember.Component.extend({ notification.get('location') : notification.location; return this.get('location') === displayLocation; - }) + }), + + messageCountObserver: function () { + this.sendAction('notify', this.get('messages').length); + }.observes('messages.[]') }); -export default NotificationsComponent; \ No newline at end of file +export default NotificationsComponent; diff --git a/core/client/controllers/application.js b/core/client/controllers/application.js index bb214cd6a1..d81587ba98 100644 --- a/core/client/controllers/application.js +++ b/core/client/controllers/application.js @@ -1,11 +1,17 @@ var ApplicationController = Ember.Controller.extend({ hideNav: Ember.computed.match('currentPath', /(signin|signup|setup|forgotten|reset)/), + topNotificationCount: 0, + actions: { toggleMenu: function () { this.toggleProperty('showMenu'); + }, + + topNotificationChange: function (count) { + this.set('topNotificationCount', count); } } }); -export default ApplicationController; \ No newline at end of file +export default ApplicationController; diff --git a/core/client/templates/application.hbs b/core/client/templates/application.hbs index 5ec96ff50e..a9295d0c15 100644 --- a/core/client/templates/application.hbs +++ b/core/client/templates/application.hbs @@ -2,8 +2,8 @@ {{partial "navbar"}} {{/unless}} -
- {{gh-notifications location="top"}} +
+ {{gh-notifications location="top" notify="topNotificationChange"}} {{gh-notifications location="bottom"}} {{outlet}}