diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 23cd5d27..205e3580 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -5,6 +5,7 @@ import { computed } from "@ember/object"; import wizardSchema from '../lib/wizard-schema'; import UndoChanges from '../mixins/undo-changes'; import Component from "@ember/component"; +import { notificationLevels } from '../lib/wizard'; export default Component.extend(UndoChanges, { componentType: 'action', @@ -32,6 +33,12 @@ export default Component.extend(UndoChanges, { name: I18n.t(`admin.wizard.action.${type}.label`) }; }), + availableNotificationLevels: notificationLevels.map((type, index) => { + return { + id: type, + name: I18n.t(`admin.wizard.action.watch_categories.notification_level.${type}`) + }; + }), messageUrl: 'https://thepavilion.io/t/2810', diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index f3c61cd8..599f4708 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -143,6 +143,7 @@ const action = { }, watch_categories: { categories: null, + notification_level: null, mute_remainder: null }, add_to_group: { @@ -164,6 +165,7 @@ const action = { 'group', 'url', 'categories', + // 'notification_level', 'mute_remainder' ], advanced: [ @@ -186,7 +188,8 @@ const wizardSchema = { wizard, step, field, - action + action, + } export function buildFieldTypes(types) { diff --git a/assets/javascripts/discourse/lib/wizard.js.es6 b/assets/javascripts/discourse/lib/wizard.js.es6 index 668ebe6a..4351367d 100644 --- a/assets/javascripts/discourse/lib/wizard.js.es6 +++ b/assets/javascripts/discourse/lib/wizard.js.es6 @@ -49,6 +49,14 @@ const userProperties = [ 'trust_level' ]; +const notificationLevels = [ + 'regular', + 'watching', + 'tracking', + 'watching_first_post', + 'muted' +]; + function listProperties(type, opts={}) { let properties = Object.keys(wizardSchema[type].basic); @@ -106,5 +114,6 @@ export { snakeCase, userProperties, listProperties, + notificationLevels, wizardFieldList }; \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 40d6b31a..fa119d14 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -303,6 +303,23 @@ +
+
+ +
+ +
+ {{combo-box + value=action.notification_level + content=availableNotificationLevels + onChange=(action (mut action.notification_level)) + options=(hash + isDisabled=action.custom_title_enabled + none='admin.wizard.action.watch_categories.select_a_notification_level' + )}} +
+
+
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index a601fbe5..b7c3d73f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -210,8 +210,16 @@ en: key: "field" watch_categories: label: "Watch Categories" - mute_remainder: "Mute Remainder" categories: "Categories" + mute_remainder: "Mute Remainder" + notification_level: + label: "Notification Level" + regular: "Normal" + watching: "Watching" + tracking: "Tracking" + watching_first_post: "Watching First Post" + muted: "Muted" + select_a_notification_level: "Select level" post_builder: checkbox: "Post Builder" label: "Builder" diff --git a/controllers/custom_wizard/admin/wizard.rb b/controllers/custom_wizard/admin/wizard.rb index 0f155fbe..5c3ade4e 100644 --- a/controllers/custom_wizard/admin/wizard.rb +++ b/controllers/custom_wizard/admin/wizard.rb @@ -116,6 +116,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController :post, :post_builder, :post_template, + :notification_level, title: mapped_params, category: mapped_params, tags: mapped_params, diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb index e78353d9..2d539287 100644 --- a/lib/custom_wizard/action.rb +++ b/lib/custom_wizard/action.rb @@ -141,6 +141,8 @@ class CustomWizard::Action user: user ).perform + notification_level = action['notification_level'] + mute_remainder = CustomWizard::Mapper.new( inputs: action['mute_remainder'], data: data, @@ -149,7 +151,7 @@ class CustomWizard::Action Category.all.each do |category| if watched_categories.include?(category.id.to_s) - CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:watching], category.id) + CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[notification_level.to_sym], category.id) elsif mute_remainder CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id) end