2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2014-03-22 16:08:15 +04:00
|
|
|
var NotificationsComponent = Ember.Component.extend({
|
|
|
|
tagName: 'aside',
|
|
|
|
classNames: 'notifications',
|
2014-07-09 08:17:30 +04: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 21:28:53 +04:00
|
|
|
}),
|
|
|
|
|
|
|
|
messageCountObserver: function () {
|
|
|
|
this.sendAction('notify', this.get('messages').length);
|
|
|
|
}.observes('messages.[]')
|
2014-03-22 16:08:15 +04:00
|
|
|
});
|
|
|
|
|
2014-07-17 21:28:53 +04:00
|
|
|
export default NotificationsComponent;
|