1
0
mirror of https://github.com/flarum/core.git synced 2025-08-09 09:57:06 +02:00

Implement notifications

This commit is contained in:
Toby Zerner
2015-03-24 15:07:38 +10:30
parent 1d1025dcd2
commit 4a1550215c
34 changed files with 808 additions and 38 deletions

View File

@@ -0,0 +1,12 @@
import Ember from 'ember';
import FadeIn from 'flarum/mixins/fade-in';
export default Ember.Component.extend(FadeIn, {
layoutName: 'components/application/notification-item',
tagName: 'li',
componentName: Ember.computed('notification.contentType', function() {
return 'application/notification-'+this.get('notification.contentType');
})
});

View File

@@ -0,0 +1,3 @@
import Notification from './notification';
export default Notification.extend();

View File

@@ -0,0 +1,11 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['notification'],
classNameBindings: ['notification.isRead::unread'],
click: function() {
console.log('click')
this.get('notification').set('isRead', true).save();
}
});

View File

@@ -0,0 +1,39 @@
import Ember from 'ember';
import DropdownButton from 'flarum/components/ui/dropdown-button';
var precompileTemplate = Ember.Handlebars.compile;
export default DropdownButton.extend({
layoutName: 'components/application/user-notifications',
classNames: ['notifications'],
classNameBindings: ['unread'],
buttonClass: 'btn btn-default btn-rounded btn-naked btn-icon',
menuClass: 'pull-right',
unread: Ember.computed.bool('user.unreadNotificationsCount'),
actions: {
buttonClick: function() {
if (!this.get('notifications')) {
var component = this;
this.set('notificationsLoading', true);
this.get('parentController.store').find('notification').then(function(notifications) {
component.set('user.unreadNotificationsCount', 0);
component.set('notifications', notifications);
component.set('notificationsLoading', false);
});
}
},
markAllAsRead: function() {
this.get('notifications').forEach(function(notification) {
if (!notification.get('isRead')) {
notification.set('isRead', true);
notification.save();
}
})
},
}
})