From 0e8808fbe8cea2e61621f9fdb88016090a22e4ad Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 26 Jan 2017 16:36:53 -0500 Subject: [PATCH] FIX: bulk change tags works with category tag settings --- .../discourse/components/bulk-select-button.js.es6 | 8 +++++++- .../discourse/controllers/topic-bulk-actions.js.es6 | 5 +++-- app/assets/javascripts/discourse/templates/bulk-tag.hbs | 2 +- .../javascripts/discourse/templates/discovery/topics.hbs | 2 +- .../discourse/templates/modal/topic-bulk-actions.hbs | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/bulk-select-button.js.es6 b/app/assets/javascripts/discourse/components/bulk-select-button.js.es6 index fd5d4594629..96f08fd76d4 100644 --- a/app/assets/javascripts/discourse/components/bulk-select-button.js.es6 +++ b/app/assets/javascripts/discourse/components/bulk-select-button.js.es6 @@ -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()); } } diff --git a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 index e3a7a34f217..ba5e6de1791 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -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)); diff --git a/app/assets/javascripts/discourse/templates/bulk-tag.hbs b/app/assets/javascripts/discourse/templates/bulk-tag.hbs index 1ffe345e30c..636f83cb343 100644 --- a/app/assets/javascripts/discourse/templates/bulk-tag.hbs +++ b/app/assets/javascripts/discourse/templates/bulk-tag.hbs @@ -1,5 +1,5 @@

{{i18n "topics.bulk.choose_new_tags"}}

-

{{tag-chooser tags=tags}}

+

{{tag-chooser tags=tags categoryId=categoryId}}

{{d-button action="changeTags" disabled=emptyTags label="topics.bulk.change_tags"}} diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.hbs b/app/assets/javascripts/discourse/templates/discovery/topics.hbs index 8d0ab34d9e2..22e5eb3a60f 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/topics.hbs @@ -13,7 +13,7 @@ {{/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}} diff --git a/app/assets/javascripts/discourse/templates/modal/topic-bulk-actions.hbs b/app/assets/javascripts/discourse/templates/modal/topic-bulk-actions.hbs index caa2e71d2ab..9b10ef6c297 100644 --- a/app/assets/javascripts/discourse/templates/modal/topic-bulk-actions.hbs +++ b/app/assets/javascripts/discourse/templates/modal/topic-bulk-actions.hbs @@ -1,4 +1,4 @@ {{#d-modal-body}} -

{{{i18n 'topics.bulk.selected' count=model.length}}}

+

{{{i18n 'topics.bulk.selected' count=model.topics.length}}}

{{outlet "bulkOutlet"}} {{/d-modal-body}}