diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index 47257d8286..bbefac6929 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -107,6 +107,7 @@ const action = { post: null, post_builder: null, post_template: null, + tags: null, skip_redirect: null, custom_fields: null, required: null, diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 80152674ae..da642d9f76 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -84,6 +84,28 @@ +
+
+ +
+ +
+ {{wizard-mapper + inputs=this.action.tags + property="tags" + onUpdate=(action "mappedFieldUpdated") + options=(hash + tagSelection="output" + outputDefaultSelection="tag" + listSelection="output" + wizardFieldSelection=true + userFieldSelection="key,value" + context="action" + ) + }} +
+
+ {{#if this.action.post_builder}}
@@ -124,28 +146,6 @@
-
-
- -
- -
- {{wizard-mapper - inputs=this.action.tags - property="tags" - onUpdate=(action "mappedFieldUpdated") - options=(hash - tagSelection="output" - outputDefaultSelection="tag" - listSelection="output" - wizardFieldSelection=true - userFieldSelection="key,value" - context="action" - ) - }} -
-
-
diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb index ac0799f34d..e0d969c61a 100644 --- a/lib/custom_wizard/action.rb +++ b/lib/custom_wizard/action.rb @@ -104,6 +104,7 @@ def send_message end params = basic_topic_params + params.delete(:tags) unless user_can_tag targets = CustomWizard::Mapper.new( inputs: action['recipient'], @@ -610,6 +611,10 @@ def basic_topic_params user: user ).perform + if tags = action_tags + params[:tags] = tags + end + params[:raw] = action['post_builder'] ? mapper.interpolate( action['post_template'], @@ -632,10 +637,6 @@ def public_topic_params params[:category] = category end - if tags = action_tags - params[:tags] = tags - end - if public_topic_fields.any? public_topic_fields.each do |field| unless action[field].nil? || action[field] == "" @@ -837,4 +838,9 @@ def save_log @log.join('; ') ) end + def user_can_tag + allowed_groups = + SiteSetting.pm_tags_allowed_for_groups.split('|').map(&:to_i) + user.groups.pluck(:id).any? { |group| allowed_groups.include?(group) } + end end