1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

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 0693aafef6
commit 9b40fae66b
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}}