mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #2908 from cpradio/pr-dismiss-posts-topics-on-category
FEATURE: Show dismiss posts/topics buttons on category filtered lists
This commit is contained in:
commit
bd78fca121
3 changed files with 15 additions and 7 deletions
|
@ -85,7 +85,7 @@ var controllerOpts = {
|
|||
if (selected.length > 0) {
|
||||
promise = Discourse.Topic.bulkOperation(selected, operation);
|
||||
} else {
|
||||
promise = Discourse.Topic.bulkOperationByFilter(this.get('filter'), operation);
|
||||
promise = Discourse.Topic.bulkOperationByFilter('unread', operation, this.get('category.id'));
|
||||
}
|
||||
promise.then(function(result) {
|
||||
if (result && result.topic_ids) {
|
||||
|
@ -105,8 +105,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 +118,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'),
|
||||
|
||||
|
|
|
@ -471,10 +471,12 @@ Discourse.Topic.reopenClass({
|
|||
});
|
||||
},
|
||||
|
||||
bulkOperationByFilter: function(filter, operation) {
|
||||
bulkOperationByFilter: function(filter, operation, categoryId) {
|
||||
var data = { filter: filter, operation: operation };
|
||||
if (categoryId) data['category_id'] = categoryId;
|
||||
return Discourse.ajax("/topics/bulk", {
|
||||
type: 'PUT',
|
||||
data: { filter: filter, operation: operation }
|
||||
data: data
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -364,7 +364,9 @@ 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)
|
||||
topics = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics
|
||||
topics = topics.where('category_id = ?', params[:category_id]) if params[:category_id]
|
||||
topic_ids = topics.pluck(:id)
|
||||
else
|
||||
raise ActionController::ParameterMissing.new(:topic_ids)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue