FEATURE: Can select topics and hit Dismiss Read on the /unread filter

This commit is contained in:
Robin Ward 2014-02-21 12:31:54 -05:00
parent 5fd390c600
commit 7a07f14dfc
6 changed files with 40 additions and 5 deletions

View File

@ -27,7 +27,7 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
this.send('loading');
Discourse.TopicList.find(filter).then(function(list) {
self.set('model', list);
self.setProperties({ model: list, selected: [] });
self.send('loadingComplete');
});
},
@ -35,13 +35,32 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
toggleBulkSelect: function() {
this.toggleProperty('bulkSelectEnabled');
this.get('selected').clear();
},
dismissRead: function() {
var self = this,
selected = this.get('selected'),
operation = { type: 'change_notification_level',
notification_level: Discourse.Topic.NotificationLevel.REGULAR };
if (selected.length > 0) {
Discourse.Topic.bulkOperation(selected, operation).then(function() {
self.send('refresh');
});
} else {
}
}
},
topicTrackingState: function() {
return Discourse.TopicTrackingState.current();
}.property(),
showDismissRead: function() {
return this.get('filter') === 'unread' && this.get('topics.length') > 0;
}.property('filter', 'topics.length'),
canBulkSelect: Em.computed.alias('currentUser.staff'),
hasTopics: Em.computed.gt('topics.length', 0),
showTable: Em.computed.or('hasTopics', 'topicTrackingState.hasIncoming'),

View File

@ -34,7 +34,12 @@ function buildTopicRoute(filter) {
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
}
this.controllerFor('discoveryTopics').setProperties({ model: model, category: null, period: period });
this.controllerFor('discoveryTopics').setProperties({
model: model,
category: null,
period: period,
selected: [],
});
// If there's a draft, open the create topic composer
if (model.draft) {
@ -108,6 +113,7 @@ function buildCategoryRoute(filter, params) {
model: topics,
category: model,
period: period,
selected: [],
noSubcategories: params && !!params.no_subcategories
});

View File

@ -4,6 +4,10 @@
</div>
{{/if}}
{{#if showDismissRead}}
<button class='btn dismiss-read' {{action dismissRead}}>{{i18n topics.bulk.dismiss_read}}</button>
{{/if}}
<div class='contents'>
{{#if showTable}}
<table id='topic-list'>

View File

@ -546,3 +546,8 @@ ol.category-breadcrumb {
padding: 3px 0 3px 6px;
}
}
button.dismiss-read {
float: right;
margin-bottom: 5px;
}

View File

@ -2,9 +2,9 @@ require_dependency 'site_serializer'
class SiteController < ApplicationController
def index
def index
@site = Site.new(guardian)
render_serialized(@site, SiteSerializer)
end
end
end

View File

@ -628,6 +628,7 @@ en:
topics:
bulk:
dismiss_read: "Dismiss Read"
toggle: "toggle bulk selection of topics"
actions: "Bulk Actions"
change_category: "Change Category"