diff --git a/app/assets/javascripts/discourse/components/radio_button.js b/app/assets/javascripts/discourse/components/radio_button.js new file mode 100644 index 00000000000..1817064c94d --- /dev/null +++ b/app/assets/javascripts/discourse/components/radio_button.js @@ -0,0 +1,13 @@ +Discourse.RadioButton = Ember.Component.extend({ + tagName : "input", + type : "radio", + attributeBindings : [ "name", "type", "value", "checked:checked" ], + click : function() { + this.set("selection", this.$().val()); + }, + checked : function() { + return this.get("value") === this.get("selection"); + }.property('selection') +}); + +Em.Handlebars.helper('radio-button', Discourse.RadioButton); diff --git a/app/assets/javascripts/discourse/controllers/bulk_notification_level_controller.js b/app/assets/javascripts/discourse/controllers/bulk_notification_level_controller.js new file mode 100644 index 00000000000..60fb2a87092 --- /dev/null +++ b/app/assets/javascripts/discourse/controllers/bulk_notification_level_controller.js @@ -0,0 +1,44 @@ +/** + Support for changing the notification level of various topics + + @class BulkNotificationLevelControler + @extends Ember.Controller + @namespace Discourse + @module Discourse +**/ +Discourse.BulkNotificationLevelController = Em.Controller.extend({ + needs: ['topicBulkActions', 'discoveryTopics'], + + notificationLevelId: null, + + notificationLevels: function() { + var result = []; + Object.keys(Discourse.Topic.NotificationLevel).forEach(function(k) { + result.push({ + id: Discourse.Topic.NotificationLevel[k].toString(), + name: I18n.t('topic.notifications.' + k.toLowerCase() + ".title"), + description: I18n.t('topic.notifications.' + k.toLowerCase() + ".description") + }); + }); + return result; + }.property(), + + disabled: Em.computed.empty("notificationLevelId"), + + actions: { + changeNotificationLevel: function() { + var self = this; + + this.get('controllers.topicBulkActions').perform({ + type: 'change_notification_level', + notification_level_id: this.get('notificationLevelId') + }).then(function(topics) { + if (topics) { + // Tell current route to reload + self.get('controllers.discoveryTopics').send('refresh'); + self.send('closeModal'); + } + }); + } + } +}); diff --git a/app/assets/javascripts/discourse/controllers/topic_bulk_actions_controller.js b/app/assets/javascripts/discourse/controllers/topic_bulk_actions_controller.js index 1b90f5831f5..8447491dd2b 100644 --- a/app/assets/javascripts/discourse/controllers/topic_bulk_actions_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_bulk_actions_controller.js @@ -46,6 +46,10 @@ Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.Mo this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal full'); }, + showNotificationLevel: function() { + this.send('changeBulkTemplate', 'modal/bulk_notification_level'); + }, + closeTopics: function() { this.forEachPerformed({type: 'close'}, function(t) { t.set('closed', true); diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index d46f1eb1d79..dbbc5d16fe0 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -313,7 +313,7 @@ Discourse.Topic.reopenClass({ WATCHING: 3, TRACKING: 2, REGULAR: 1, - MUTE: 0 + MUTED: 0 }, createActionSummary: function(result) { diff --git a/app/assets/javascripts/discourse/routes/discovery_route.js b/app/assets/javascripts/discourse/routes/discovery_route.js index f9ef0695fd9..15a1df58386 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route.js +++ b/app/assets/javascripts/discourse/routes/discovery_route.js @@ -31,7 +31,10 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.OpenComposer, { }, changeBulkTemplate: function(w) { - this.render(w, {into: 'topicBulkActions', outlet: 'bulkOutlet', controller: 'topicBulkActions'}); + var controllerName = w.replace('modal/', ''), + factory = this.container.lookupFactory('controller:' + controllerName); + + this.render(w, {into: 'topicBulkActions', outlet: 'bulkOutlet', controller: factory ? controllerName : 'topicBulkActions'}); }, showBulkActions: function() { diff --git a/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.js.handlebars b/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.js.handlebars index e17be58e3ad..0ae6fc38d1e 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/bulk_actions_buttons.js.handlebars @@ -1,2 +1,3 @@ + diff --git a/app/assets/javascripts/discourse/templates/modal/bulk_notification_level.js.handlebars b/app/assets/javascripts/discourse/templates/modal/bulk_notification_level.js.handlebars new file mode 100644 index 00000000000..2dad1a349e5 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/modal/bulk_notification_level.js.handlebars @@ -0,0 +1,10 @@ +{{#each level in notificationLevels}} +