diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6
index 95ac4dd7..23cd5d27 100644
--- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6
+++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6
@@ -12,6 +12,7 @@ export default Component.extend(UndoChanges, {
visible: computed('currentActionId', function() { return this.action.id === this.currentActionId }),
createTopic: equal('action.type', 'create_topic'),
updateProfile: equal('action.type', 'update_profile'),
+ watchCategories: equal('action.type', 'watch_categories'),
sendMessage: equal('action.type', 'send_message'),
openComposer: equal('action.type', 'open_composer'),
sendToApi: equal('action.type', 'send_to_api'),
diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6
index bd99ba7b..c18913c0 100644
--- a/assets/javascripts/discourse/lib/wizard-schema.js.es6
+++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6
@@ -141,6 +141,10 @@ const action = {
profile_updates: null,
custom_fields: null
},
+ watch_categories: {
+ category: null,
+ mute_remainder: null
+ },
add_to_group: {
group: null
},
@@ -158,6 +162,7 @@ const action = {
'recipient',
'profile_updates',
'group',
+ 'mute_remainder',
'url'
],
advanced: [
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
index c27e56cd..7b9eeb2f 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
@@ -10,7 +10,7 @@
-
+
{{combo-box
value=action.type
@@ -26,7 +26,7 @@
-
+
{{combo-box
value=action.run_after
@@ -45,7 +45,7 @@
-
+
{{wizard-mapper
inputs=action.title
@@ -102,7 +102,7 @@
-
+
{{wizard-mapper
inputs=action.category
@@ -123,7 +123,7 @@
-
+
{{wizard-mapper
inputs=action.tags
@@ -146,7 +146,7 @@
-
+
{{wizard-mapper
inputs=action.recipient
@@ -170,7 +170,7 @@
-
+
{{wizard-mapper
inputs=action.profile_updates
property='profile_updates'
@@ -191,7 +191,7 @@
-
+
{{combo-box
value=action.api
@@ -208,7 +208,7 @@
-
+
{{combo-box
value=action.api_endpoint
@@ -225,7 +225,7 @@
-
+
{{wizard-text-editor
value=action.api_body
@@ -242,7 +242,7 @@
-
+
{{wizard-mapper
inputs=action.group
@@ -265,7 +265,7 @@
-
+
{{wizard-mapper
inputs=action.url
@@ -283,18 +283,41 @@
{{/if}}
+{{#if watchCategories}}
+
+
+
+
+
+
+ {{wizard-mapper
+ inputs=action.mute_remainder
+ property='mute_remainder'
+ onUpdate=(action 'mappedFieldUpdated')
+ options=(hash
+ context='action'
+ wizardFieldSelection=true
+ userFieldSelection='key,value'
+ groupSelection='key,value'
+ categorySelection='key,value'
+ userSelection='key,value'
+ )}}
+
+
+{{/if}}
+
{{#if showAdvanced}}
{{wizard-advanced-toggle showAdvanced=action.showAdvanced}}
{{#if action.showAdvanced}}
-
+
{{#if hasCustomFields}}
-
+
{{wizard-mapper
inputs=action.custom_fields
@@ -310,13 +333,13 @@
{{/if}}
-
+
{{#if sendMessage}}
-
+
{{wizard-mapper
inputs=action.required
@@ -332,23 +355,23 @@
{{/if}}
-
+
{{#if showSkipRedirect}}
-
+
{{input type='checkbox' checked=action.skip_redirect}}
-
+
{{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}
{{/if}}
-
+
{{#if routeTo}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 0a79915d..f47d7e95 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -208,6 +208,9 @@ en:
label: "Update Profile"
setting: "Fields"
key: "field"
+ watch_categories:
+ label: "Watch Categories"
+ mute_remainder: "Mute Remainder"
post_builder:
checkbox: "Post Builder"
label: "Builder"
diff --git a/controllers/custom_wizard/admin/wizard.rb b/controllers/custom_wizard/admin/wizard.rb
index d7f87f9a..b15dcf65 100644
--- a/controllers/custom_wizard/admin/wizard.rb
+++ b/controllers/custom_wizard/admin/wizard.rb
@@ -122,6 +122,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
custom_fields: mapped_params,
required: mapped_params,
recipient: mapped_params,
+ mute_remainder: mapped_params,
profile_updates: mapped_params,
group: mapped_params,
url: mapped_params
diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb
index d85067bb..e0b84257 100644
--- a/lib/custom_wizard/action.rb
+++ b/lib/custom_wizard/action.rb
@@ -133,6 +133,18 @@ class CustomWizard::Action
end
end
+ def watch_categories
+ key, watched_categories = data.first
+ mute_remainder = data.values[1]
+ 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)
+ elsif mute_remainder
+ CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
+ end
+ end
+ end
+
def send_to_api
api_body = nil
diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb
index 19b40e6b..aafc317f 100644
--- a/lib/custom_wizard/mapper.rb
+++ b/lib/custom_wizard/mapper.rb
@@ -3,6 +3,7 @@ class CustomWizard::Mapper
USER_FIELDS = ['name', 'username', 'email', 'date_of_birth', 'title', 'locale', 'trust_level']
PROFILE_FIELDS = ['location', 'website', 'bio_raw']
+ CATEGORY_NOTIFICATION_LEVELS = ['regular','watching', 'tracking', 'watching_first_post','muted']
def self.user_fields
USER_FIELDS + PROFILE_FIELDS
@@ -115,10 +116,10 @@ class CustomWizard::Mapper
end
end
end
-
+
def validation_result(key, value, operator)
result = nil
-
+
if operator.is_a?(Hash) && (operator = operator[value.to_sym]).present?
if value == "present"
result = key.public_send(operator)