mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 13:17:20 -05:00
FEATURE: Bulk reset read status.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.BulkNotificationLevelController = Em.Controller.extend({
|
||||
needs: ['topicBulkActions', 'discoveryTopics'],
|
||||
needs: ['topicBulkActions'],
|
||||
|
||||
notificationLevelId: null,
|
||||
|
||||
@@ -27,17 +27,9 @@ Discourse.BulkNotificationLevelController = Em.Controller.extend({
|
||||
|
||||
actions: {
|
||||
changeNotificationLevel: function() {
|
||||
var self = this;
|
||||
|
||||
this.get('controllers.topicBulkActions').perform({
|
||||
this.get('controllers.topicBulkActions').performAndRefresh({
|
||||
type: 'change_notification_level',
|
||||
notification_level_id: this.get('notificationLevelId')
|
||||
}).then(function(topics) {
|
||||
if (topics) {
|
||||
// Tell current route to reload
|
||||
self.get('controllers.discoveryTopics').send('refresh');
|
||||
self.send('closeModal');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
||||
needs: ['discoveryTopics'],
|
||||
|
||||
onShow: function() {
|
||||
this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small');
|
||||
},
|
||||
@@ -40,6 +42,14 @@ Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.Mo
|
||||
});
|
||||
},
|
||||
|
||||
performAndRefresh: function(operation) {
|
||||
var self = this;
|
||||
return this.perform(operation).then(function() {
|
||||
self.get('controllers.discoveryTopics').send('refresh');
|
||||
self.send('closeModal');
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
showChangeCategory: function() {
|
||||
this.send('changeBulkTemplate', 'modal/bulk_change_category');
|
||||
@@ -66,6 +76,10 @@ Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.Mo
|
||||
});
|
||||
self.send('closeModal');
|
||||
});
|
||||
},
|
||||
|
||||
resetRead: function() {
|
||||
this.performAndRefresh({ type: 'reset_read' });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<button class='btn' {{action showChangeCategory}}>{{i18n topics.bulk.change_category}}</button>
|
||||
<button class='btn' {{action closeTopics}}>{{i18n topics.bulk.close_topics}}</button>
|
||||
<button class='btn' {{action showNotificationLevel}}>{{i18n topics.bulk.notification_level}}</button>
|
||||
<button class='btn' {{action resetRead}}>{{i18n topics.bulk.reset_read}}</button>
|
||||
|
||||
@@ -88,7 +88,7 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy_timings
|
||||
PostTiming.destroy_for(current_user.id, params[:topic_id].to_i)
|
||||
PostTiming.destroy_for(current_user.id, [params[:topic_id].to_i])
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ class PostTiming < ActiveRecord::Base
|
||||
end
|
||||
|
||||
|
||||
def self.destroy_for(user_id, topic_id)
|
||||
def self.destroy_for(user_id, topic_ids)
|
||||
PostTiming.transaction do
|
||||
PostTiming.delete_all(['user_id = ? and topic_id = ?', user_id, topic_id])
|
||||
TopicUser.delete_all(['user_id = ? and topic_id = ?', user_id, topic_id])
|
||||
PostTiming.delete_all(['user_id = ? and topic_id in (?)', user_id, topic_ids])
|
||||
TopicUser.delete_all(['user_id = ? and topic_id in (?)', user_id, topic_ids])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user