FIX: bulk change tags works with category tag settings

This commit is contained in:
Neil Lalonde 2017-01-26 16:36:53 -05:00
parent 6e47e02738
commit 0e8808fbe8
5 changed files with 13 additions and 6 deletions

View File

@ -3,7 +3,13 @@ import showModal from 'discourse/lib/show-modal';
export default Ember.Component.extend({
actions: {
showBulkActions() {
const controller = showModal('topic-bulk-actions', { model: this.get('selected'), title: 'topics.bulk.actions' });
const controller = showModal('topic-bulk-actions', {
model: {
topics: this.get('selected'),
category: this.get('category')
},
title: 'topics.bulk.actions'
});
controller.set('refreshClosure', () => this.sendAction());
}
}

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
buttonRows: null,
emptyTags: Ember.computed.empty('tags'),
categoryId: Ember.computed.alias('model.category.id'),
onShow() {
this.set('modal.modalClass', 'topic-bulk-actions-modal small');
@ -44,8 +45,8 @@ export default Ember.Controller.extend(ModalFunctionality, {
perform(operation) {
this.set('loading', true);
const topics = this.get('model');
return Discourse.Topic.bulkOperation(this.get('model'), operation).then(result => {
const topics = this.get('model.topics');
return Discourse.Topic.bulkOperation(topics, operation).then(result => {
this.set('loading', false);
if (result && result.topic_ids) {
return result.topic_ids.map(t => topics.findBy('id', t));

View File

@ -1,5 +1,5 @@
<p>{{i18n "topics.bulk.choose_new_tags"}}</p>
<p>{{tag-chooser tags=tags}}</p>
<p>{{tag-chooser tags=tags categoryId=categoryId}}</p>
{{d-button action="changeTags" disabled=emptyTags label="topics.bulk.change_tags"}}

View File

@ -13,7 +13,7 @@
</div>
{{/if}}
{{bulk-select-button selected=selected action="refresh"}}
{{bulk-select-button selected=selected action="refresh" category=category}}
{{#discovery-topics-list model=model refresh="refresh" incomingCount=topicTrackingState.incomingCount}}
{{#if top}}

View File

@ -1,4 +1,4 @@
{{#d-modal-body}}
<p>{{{i18n 'topics.bulk.selected' count=model.length}}}</p>
<p>{{{i18n 'topics.bulk.selected' count=model.topics.length}}}</p>
{{outlet "bulkOutlet"}}
{{/d-modal-body}}