From 12919f72facf0ffa3c15a3721033af5695339d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sat, 7 Mar 2015 02:30:53 +0100 Subject: [PATCH] Revert "Support for plugins to add bulk operations" This reverts commit 7a508b201aa464de33bbd57cd027f63d57303cd5. --- .../controllers/topic-bulk-actions.js.es6 | 30 ------------------- .../templates/modal/bulk_actions_buttons.hbs | 17 ++++++----- .../templates/modal/bulk_change_category.hbs | 11 ++++--- .../discourse/views/topic-bulk-actions.js.es6 | 4 --- .../views/topic_bulk_actions_view.js | 12 ++++++++ config/locales/client.en.yml | 1 - lib/topics_bulk_action.rb | 7 +---- 7 files changed, 30 insertions(+), 52 deletions(-) delete mode 100644 app/assets/javascripts/discourse/views/topic-bulk-actions.js.es6 create mode 100644 app/assets/javascripts/discourse/views/topic_bulk_actions_view.js 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 3d5285017eb..4c0ddcfdebb 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -1,39 +1,11 @@ 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) { @@ -117,5 +89,3 @@ 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 6cd4580a538..40ace4bc376 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs +++ b/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.hbs @@ -1,7 +1,10 @@ -{{#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 6239773fd9f..e67173ff701 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs +++ b/app/assets/javascripts/discourse/templates/modal/bulk_change_category.hbs @@ -1,7 +1,10 @@ -

{{i18n "topics.bulk.choose_new_category"}}

+

Choose the new category for the topics:

{{category-chooser value=newCategoryId}}

-{{#loading-spinner condition=loading}} - {{d-button action="changeCategory" label="topics.bulk.change_category"}} -{{/loading-spinner}} +{{#if loading}} +
{{i18n 'loading'}}
+{{else}} + +{{/if}} + diff --git a/app/assets/javascripts/discourse/views/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/views/topic-bulk-actions.js.es6 deleted file mode 100644 index dd6490a71f8..00000000000 --- a/app/assets/javascripts/discourse/views/topic-bulk-actions.js.es6 +++ /dev/null @@ -1,4 +0,0 @@ -export default Discourse.ModalBodyView.extend({ - templateName: 'modal/topic-bulk-actions', - title: I18n.t('topics.bulk.actions') -}); diff --git a/app/assets/javascripts/discourse/views/topic_bulk_actions_view.js b/app/assets/javascripts/discourse/views/topic_bulk_actions_view.js new file mode 100644 index 00000000000..a72348415e3 --- /dev/null +++ b/app/assets/javascripts/discourse/views/topic_bulk_actions_view.js @@ -0,0 +1,12 @@ +/** + Handles the view for the topic bulk actions modal + + @class TopicBulkActionsView + @extends Discourse.ModalBodyView + @namespace Discourse + @module Discourse +**/ +Discourse.TopicBulkActionsView = Discourse.ModalBodyView.extend({ + templateName: 'modal/topic_bulk_actions', + title: I18n.t('topics.bulk.actions') +}); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 79e67bb94a6..04b0dd324da 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -814,7 +814,6 @@ en: close_topics: "Close Topics" archive_topics: "Archive Topics" notification_level: "Change Notification Level" - choose_new_category: "Choose the new category for the topics:" selected: one: "You have selected 1 topic." other: "You have selected {{count}} topics." diff --git a/lib/topics_bulk_action.rb b/lib/topics_bulk_action.rb index 337c32eac1a..71defb0e3d7 100644 --- a/lib/topics_bulk_action.rb +++ b/lib/topics_bulk_action.rb @@ -8,12 +8,7 @@ class TopicsBulkAction end def self.operations - @operations ||= %w(change_category close archive change_notification_level reset_read dismiss_posts delete) - end - - def self.register_operation(name, &block) - operations << name - define_method(name, &block) + %w(change_category close archive change_notification_level reset_read dismiss_posts delete) end def perform!