Merge pull request #2874 from cpradio/clear-notifications
FEATURE: Mark All as Read button for Notifications page
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
|
||||
export default Ember.ArrayController.extend({
|
||||
needs: ['user-notifications'],
|
||||
canLoadMore: true,
|
||||
loading: false,
|
||||
showDismissButton: function() {
|
||||
return this.get('user').total_unread_notifications > 0;
|
||||
}.property('user'),
|
||||
|
||||
actions: {
|
||||
resetNew: function() {
|
||||
var self = this;
|
||||
Discourse.NotificationContainer.resetNew().then(function() {
|
||||
self.get('controllers.user-notifications').setEach('read', true);
|
||||
});
|
||||
},
|
||||
|
||||
loadMore: function() {
|
||||
if (this.get('canLoadMore') && !this.get('loading')) {
|
||||
this.set('loading', true);
|
||||
|
||||
@@ -46,5 +46,9 @@ Discourse.NotificationContainer.reopenClass({
|
||||
}).catch(function(error) {
|
||||
return Discourse.NotificationContainer.createFromError(error);
|
||||
});
|
||||
},
|
||||
|
||||
resetNew: function() {
|
||||
return Discourse.ajax("/notifications/reset-new", {type: 'PUT'});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if showDismissButton}}
|
||||
<div class='notification-buttons'>
|
||||
<button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications-top' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each itemController="notification"}}
|
||||
<div {{bind-attr class=":item :notification read::unread"}}>
|
||||
@@ -16,9 +21,15 @@
|
||||
</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
{{#if loading}}
|
||||
<div class='spinner'></div>
|
||||
{{/if}}
|
||||
{{#unless canLoadMore}}
|
||||
<div class='end-of-stream'></div>
|
||||
{{#if showDismissButton}}
|
||||
<div class='notification-buttons'>
|
||||
<button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
Reference in New Issue
Block a user