FEATURE: Can bulk delete topics now using the modal.
This commit is contained in:
parent
0ee07ae2bb
commit
15c7e01b90
|
@ -28,6 +28,7 @@ export default Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}).catch(function() {
|
}).catch(function() {
|
||||||
|
bootbox.alert(I18n.t('generic_error'));
|
||||||
self.set('loading', false);
|
self.set('loading', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -60,6 +61,10 @@ export default Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
||||||
this.send('changeBulkTemplate', 'modal/bulk_notification_level');
|
this.send('changeBulkTemplate', 'modal/bulk_notification_level');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteTopics: function() {
|
||||||
|
this.performAndRefresh({type: 'delete'});
|
||||||
|
},
|
||||||
|
|
||||||
closeTopics: function() {
|
closeTopics: function() {
|
||||||
this.forEachPerformed({type: 'close'}, function(t) {
|
this.forEachPerformed({type: 'close'}, function(t) {
|
||||||
t.set('closed', true);
|
t.set('closed', true);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<button class='btn' {{action showChangeCategory}}>{{i18n topics.bulk.change_category}}</button>
|
<button class='btn' {{action showChangeCategory}}>{{i18n topics.bulk.change_category}}</button>
|
||||||
|
<button class='btn' {{action deleteTopics}}>{{i18n topics.bulk.delete}}</button>
|
||||||
<button class='btn' {{action closeTopics}}>{{i18n topics.bulk.close_topics}}</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 showNotificationLevel}}>{{i18n topics.bulk.notification_level}}</button>
|
||||||
<button class='btn' {{action resetRead}}>{{i18n topics.bulk.reset_read}}</button>
|
<button class='btn' {{action resetRead}}>{{i18n topics.bulk.reset_read}}</button>
|
||||||
|
|
|
@ -726,6 +726,7 @@ en:
|
||||||
topics:
|
topics:
|
||||||
bulk:
|
bulk:
|
||||||
reset_read: "Reset Read"
|
reset_read: "Reset Read"
|
||||||
|
delete: "Delete Topics"
|
||||||
dismiss_posts: "Dismiss Posts"
|
dismiss_posts: "Dismiss Posts"
|
||||||
dismiss_posts_tooltip: "Clear unread counts on these topics but continue to show them on my unread list when new posts are made"
|
dismiss_posts_tooltip: "Clear unread counts on these topics but continue to show them on my unread list when new posts are made"
|
||||||
dismiss_topics: "Dismiss Topics"
|
dismiss_topics: "Dismiss Topics"
|
||||||
|
|
|
@ -8,7 +8,7 @@ class TopicsBulkAction
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.operations
|
def self.operations
|
||||||
%w(change_category close change_notification_level reset_read dismiss_posts)
|
%w(change_category close change_notification_level reset_read dismiss_posts delete)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform!
|
def perform!
|
||||||
|
@ -61,6 +61,12 @@ class TopicsBulkAction
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete
|
||||||
|
topics.each do |t|
|
||||||
|
t.trash! if guardian.can_delete?(t)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def guardian
|
def guardian
|
||||||
@guardian ||= Guardian.new(@user)
|
@guardian ||= Guardian.new(@user)
|
||||||
end
|
end
|
||||||
|
@ -69,5 +75,6 @@ class TopicsBulkAction
|
||||||
@topics ||= Topic.where(id: @topic_ids)
|
@topics ||= Topic.where(id: @topic_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,18 @@ describe TopicsBulkAction do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "delete" do
|
||||||
|
let(:topic) { Fabricate(:topic) }
|
||||||
|
let(:moderator) { Fabricate(:moderator) }
|
||||||
|
|
||||||
|
it "deletes the topic" do
|
||||||
|
tba = TopicsBulkAction.new(moderator, [topic.id], type: 'delete')
|
||||||
|
tba.perform!
|
||||||
|
topic.reload
|
||||||
|
topic.should be_trashed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "change_notification_level" do
|
describe "change_notification_level" do
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue