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.
This commit is contained in:
Jason Williams 2014-07-17 17:28:53 +00:00
parent 1181c18f20
commit 73be0780b9
3 changed files with 15 additions and 5 deletions

View File

@ -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;
export default NotificationsComponent;

View File

@ -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;
export default ApplicationController;

View File

@ -2,8 +2,8 @@
{{partial "navbar"}}
{{/unless}}
<main role="main" id="main">
{{gh-notifications location="top"}}
<main role="main" id="main" {{bind-attr data-notification-count=topNotificationCount}}>
{{gh-notifications location="top" notify="topNotificationChange"}}
{{gh-notifications location="bottom"}}
{{outlet}}