2015-02-13 05:22:32 +01:00
|
|
|
import Ember from 'ember';
|
2014-03-22 13:08:15 +01:00
|
|
|
var NotificationsComponent = Ember.Component.extend({
|
|
|
|
tagName: 'aside',
|
|
|
|
classNames: 'notifications',
|
2014-07-09 06:17:30 +02:00
|
|
|
classNameBindings: ['location'],
|
|
|
|
|
|
|
|
messages: Ember.computed.filter('notifications', function (notification) {
|
|
|
|
// If this instance of the notifications component has no location affinity
|
|
|
|
// then it gets all notifications
|
|
|
|
if (!this.get('location')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var displayLocation = (typeof notification.toJSON === 'function') ?
|
|
|
|
notification.get('location') : notification.location;
|
|
|
|
|
|
|
|
return this.get('location') === displayLocation;
|
2014-07-17 19:28:53 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
messageCountObserver: function () {
|
|
|
|
this.sendAction('notify', this.get('messages').length);
|
|
|
|
}.observes('messages.[]')
|
2014-03-22 13:08:15 +01:00
|
|
|
});
|
|
|
|
|
2014-07-17 19:28:53 +02:00
|
|
|
export default NotificationsComponent;
|