mirror of
https://github.com/discourse/discourse.git
synced 2026-08-27 05:37:29 -05:00
FEATURE: If you don't select any topics to "Dissmiss Read" it does all
by filter.
This commit is contained in:
@@ -28,6 +28,12 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
||||
this.send('loading');
|
||||
Discourse.TopicList.find(filter).then(function(list) {
|
||||
self.setProperties({ model: list, selected: [] });
|
||||
|
||||
var tracking = Discourse.TopicTrackingState.current();
|
||||
if (tracking) {
|
||||
tracking.sync(list, filter);
|
||||
}
|
||||
|
||||
self.send('loadingComplete');
|
||||
});
|
||||
},
|
||||
@@ -43,12 +49,13 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
||||
operation = { type: 'change_notification_level',
|
||||
notification_level: Discourse.Topic.NotificationLevel.REGULAR };
|
||||
|
||||
var promise;
|
||||
if (selected.length > 0) {
|
||||
Discourse.Topic.bulkOperation(selected, operation).then(function() {
|
||||
self.send('refresh');
|
||||
});
|
||||
promise = Discourse.Topic.bulkOperation(selected, operation);
|
||||
} else {
|
||||
promise = Discourse.Topic.bulkOperationByFilter(this.get('filter'), operation);
|
||||
}
|
||||
promise.then(function() { self.send('refresh'); });
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -420,6 +420,13 @@ Discourse.Topic.reopenClass({
|
||||
operation: operation
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
bulkOperationByFilter: function(filter, operation) {
|
||||
return Discourse.ajax("/topics/bulk", {
|
||||
type: 'PUT',
|
||||
data: { filter: filter, operation: operation }
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -265,7 +265,15 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def bulk
|
||||
topic_ids = params.require(:topic_ids).map {|t| t.to_i}
|
||||
if params[:topic_ids].present?
|
||||
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)
|
||||
else
|
||||
raise ActionController::ParameterMissing.new(:topic_ids)
|
||||
end
|
||||
|
||||
operation = params.require(:operation).symbolize_keys
|
||||
raise ActionController::ParameterMissing.new(:operation_type) if operation[:type].blank?
|
||||
operator = TopicsBulkAction.new(current_user, topic_ids, operation)
|
||||
|
||||
Reference in New Issue
Block a user