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 4c0ddcfdeb..3d5285017e 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -1,11 +1,39 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; +const _buttons = []; + +function addBulkButton(action, key) { + _buttons.push({ action: action, label: "topics.bulk." + key }); +} + +// Default buttons +addBulkButton('showChangeCategory', 'change_category'); +addBulkButton('deleteTopics', 'delete'); +addBulkButton('closeTopics', 'close_topics'); +addBulkButton('archiveTopics', 'archive_topics'); +addBulkButton('showNotificationLevel', 'notification_level'); +addBulkButton('resetRead', 'reset_read'); + // Modal for performing bulk actions on topics export default Ember.ArrayController.extend(ModalFunctionality, { needs: ['discovery/topics'], + buttonRows: null, onShow: function() { this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small'); + + const buttonRows = []; + let row = []; + _buttons.forEach(function(b) { + row.push(b); + if (row.length === 4) { + buttonRows.push(row); + row = []; + } + }); + if (row.length) { buttonRows.push(row); } + + this.set('buttonRows', buttonRows); }, perform: function(operation) { @@ -89,3 +117,5 @@ export default Ember.ArrayController.extend(ModalFunctionality, { } } }); + +export { addBulkButton }; diff --git a/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs b/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs index 40ace4bc37..6cd4580a53 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs +++ b/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs @@ -1,10 +1,7 @@ -
- - - - -
-- - -
+{{#each row in buttonRows}} ++ {{#each button in row}} + {{d-button action=button.action label=button.label}} + {{/each}} +
+{{/each}} diff --git a/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs b/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs index e67173ff70..6239773fd9 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs +++ b/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs @@ -1,10 +1,7 @@ -Choose the new category for the topics:
+{{i18n "topics.bulk.choose_new_category"}}
{{category-chooser value=newCategoryId}}
-{{#if loading}} -