Show dismiss posts/topics buttons on category filtered lists
This commit is contained in:
parent
d3b268cd2c
commit
439f393d89
|
@ -85,7 +85,8 @@ var controllerOpts = {
|
|||
if (selected.length > 0) {
|
||||
promise = Discourse.Topic.bulkOperation(selected, operation);
|
||||
} else {
|
||||
promise = Discourse.Topic.bulkOperationByFilter(this.get('filter'), operation);
|
||||
var category = this.get('category');
|
||||
promise = Discourse.Topic.bulkOperationByFilter('unread', operation, category ? category.id : null);
|
||||
}
|
||||
promise.then(function(result) {
|
||||
if (result && result.topic_ids) {
|
||||
|
@ -105,8 +106,12 @@ var controllerOpts = {
|
|||
return Discourse.TopicTrackingState.current();
|
||||
}.property(),
|
||||
|
||||
isFilterPage: function(filter, filterType) {
|
||||
return filter.match(new RegExp(filterType + '$', 'gi')) ? true : false;
|
||||
},
|
||||
|
||||
showDismissRead: function() {
|
||||
return this.get('filter') === 'unread' && this.get('topics.length') > 0;
|
||||
return this.isFilterPage(this.get('filter'), 'unread') && this.get('topics.length') > 0;
|
||||
}.property('filter', 'topics.length'),
|
||||
|
||||
showResetNew: function() {
|
||||
|
@ -114,8 +119,8 @@ var controllerOpts = {
|
|||
}.property('filter', 'topics.length'),
|
||||
|
||||
showDismissAtTop: function() {
|
||||
return (this.get('filter') === 'new' ||
|
||||
this.get('filter') === 'unread') &&
|
||||
return (this.isFilterPage(this.get('filter'), 'new') ||
|
||||
this.isFilterPage(this.get('filter'), 'unread')) &&
|
||||
this.get('topics.length') >= 30;
|
||||
}.property('filter', 'topics.length'),
|
||||
|
||||
|
|
|
@ -452,10 +452,12 @@ Discourse.Topic.reopenClass({
|
|||
});
|
||||
},
|
||||
|
||||
bulkOperationByFilter: function(filter, operation) {
|
||||
bulkOperationByFilter: function(filter, operation, categoryId) {
|
||||
var data = { filter: filter, operation: operation };
|
||||
if (categoryId) data['categoryId'] = categoryId;
|
||||
return Discourse.ajax("/topics/bulk", {
|
||||
type: 'PUT',
|
||||
data: { filter: filter, operation: operation }
|
||||
data: data
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -359,7 +359,11 @@ class TopicsController < ApplicationController
|
|||
topic_ids = params[:topic_ids].map {|t| t.to_i}
|
||||
elsif params[:filter] == 'unread'
|
||||
tq = TopicQuery.new(current_user)
|
||||
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.pluck(:id)
|
||||
if params[:categoryId]
|
||||
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.where('category_id = ?', params[:categoryId]).pluck(:id)
|
||||
else
|
||||
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.pluck(:id)
|
||||
end
|
||||
else
|
||||
raise ActionController::ParameterMissing.new(:topic_ids)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue