diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 29685a93..3264541b 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -6,7 +6,8 @@ const ACTION_TYPES = [ { id: 'send_message', name: 'Send Message' }, { id: 'send_to_api', name: 'Send to API' }, { id: 'add_to_group', name: 'Add to Group' }, - { id: 'route_to', name: 'Route To' } + { id: 'route_to', name: 'Route To' }, + { id: 'open_composer', name: 'Open Composer' } ]; const PROFILE_FIELDS = [ @@ -35,6 +36,21 @@ export default Ember.Component.extend({ routeTo: Ember.computed.equal('action.type', 'route_to'), disableId: Ember.computed.not('action.isNew'), + @computed('action.type') + basicTopicFields(actionType) { + return ['create_topic', 'send_message', 'open_composer'].indexOf(actionType) > -1; + }, + + @computed('action.type') + publicTopicFields(actionType) { + return ['create_topic', 'open_composer'].indexOf(actionType) > -1; + }, + + @computed('action.type') + newTopicFields(actionType) { + return ['create_topic', 'send_message'].indexOf(actionType) > -1; + }, + @computed('availableFields') builderWizardFields(fields) { return fields.map((f) => ` w{${f.id}}`); diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 59fa22ab..824030bd 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -16,41 +16,7 @@ -{{#if createTopic}} -
-
-

{{i18n "admin.wizard.action.create_topic.category"}}

-
-
- {{category-chooser value=action.category_id isDisabled=action.custom_category_enabled}} -
- {{input type='checkbox' checked=action.custom_category_enabled}} - {{i18n 'admin.wizard.action.custom_category.label'}} - {{#if action.custom_category_enabled}} -
-
- {{input type='checkbox' checked=action.custom_category_wizard_field}} - {{i18n 'admin.wizard.action.custom_category.wizard_field'}} - {{#if action.custom_category_wizard_field}} - {{combo-box value=action.category_id - content=availableFields - nameProperty="label" - none='admin.wizard.select_field'}} - {{/if}} -
-
- {{input type='checkbox' checked=action.custom_category_user_field}} - {{i18n 'admin.wizard.action.custom_category.user_field'}} - {{#if action.custom_category_user_field}} - {{input value=action.custom_category_user_field_key}} - {{/if}} -
-
- {{/if}} -
-
-
- +{{#if basicTopicFields}}

{{i18n "admin.wizard.action.title"}}

@@ -92,16 +58,68 @@

{{i18n 'admin.wizard.action.post_builder.label'}}

-
- - +
{{d-editor value=action.post_template placeholder='admin.wizard.action.interpolate_fields' classNames='post-builder-editor'}} +
+ + +
{{/if}} +{{/if}} +{{#if publicTopicFields}} +
+
+

{{i18n "admin.wizard.action.create_topic.category"}}

+
+
+ {{category-chooser value=action.category_id isDisabled=action.custom_category_enabled}} +
+ {{input type='checkbox' checked=action.custom_category_enabled}} + {{i18n 'admin.wizard.action.custom_category.label'}} + {{#if action.custom_category_enabled}} +
+
+ {{input type='checkbox' checked=action.custom_category_wizard_field}} + {{i18n 'admin.wizard.action.custom_category.wizard_field'}} + {{#if action.custom_category_wizard_field}} + {{combo-box value=action.category_id + content=availableFields + nameProperty="label" + none='admin.wizard.select_field'}} + {{/if}} +
+
+ {{input type='checkbox' checked=action.custom_category_user_field}} + {{i18n 'admin.wizard.action.custom_category.user_field'}} + {{#if action.custom_category_user_field}} + {{input value=action.custom_category_user_field_key}} + {{/if}} +
+
+ {{/if}} +
+
+
+ +
+
+

{{i18n "admin.wizard.action.create_topic.tags"}}

+
+
+ {{tag-chooser tags=action.tags + filterable=true + allowCreate=true + isDisabled=action.custom_category_enabled}} +
+
+{{/if}} + +{{#if newTopicFields}}

{{i18n "admin.wizard.action.skip_redirect.label"}}

@@ -111,7 +129,9 @@ {{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}
+{{/if}} +{{#if createTopic}}
{{wizard-custom-inputs inputs=action.add_fields @@ -123,46 +143,6 @@ {{/if}} {{#if sendMessage}} -
-
-

{{i18n "admin.wizard.action.title"}}

-
-
- {{combo-box value=action.title content=availableFields nameProperty='label' none='admin.wizard.select_field'}} -
-
- -
-
-

{{i18n "admin.wizard.action.post"}}

-
-
- {{combo-box value=action.post content=availableFields - nameProperty='label' - none='admin.wizard.select_field' - isDisabled=action.post_builder}} -
- {{input type='checkbox' checked=action.post_builder}} - {{i18n 'admin.wizard.action.post_builder.checkbox'}} -
-
-
- - {{#if action.post_builder}} -
-
-

{{i18n 'admin.wizard.action.post_builder.label'}}

-
-
- - - {{d-editor value=action.post_template - placeholder='admin.wizard.action.interpolate_fields' - classNames='post-builder-editor'}} -
-
- {{/if}} -

{{i18n "admin.wizard.action.send_message.recipient"}}

@@ -175,16 +155,6 @@
-
-
-

{{i18n "admin.wizard.action.skip_redirect.label"}}

-
-
- {{input type='checkbox' checked=action.skip_redirect}} - {{i18n 'admin.wizard.action.skip_redirect.description' type='message'}} -
-
-
{{wizard-custom-inputs inputs=action.add_fields @@ -283,3 +253,7 @@
{{/if}} + +{{#if openComposer}} + +{{/if}} diff --git a/assets/stylesheets/wizard_custom_admin.scss b/assets/stylesheets/wizard_custom_admin.scss index 377a8dc5..42fa82d1 100644 --- a/assets/stylesheets/wizard_custom_admin.scss +++ b/assets/stylesheets/wizard_custom_admin.scss @@ -80,6 +80,14 @@ width: initial; float: none; display: flex; + + &.editor { + flex-flow: wrap; + + .d-editor { + margin-bottom: 5px; + } + } .custom-input .remove { margin-left: 10px; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index ce47502b..1c0bd172 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -133,6 +133,7 @@ en: create_topic: label: "Create Topic" category: "Category" + tags: "Tags" update_profile: label: "Update Profile" profile_field: "Profile Field" diff --git a/lib/builder.rb b/lib/builder.rb index df8f2e4c..856099e9 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -504,6 +504,36 @@ class CustomWizard::Builder ## add validation callback end end + + def open_composer(user, action, data) + if action['custom_title_enabled'] + title = CustomWizard::Builder.fill_placeholders(action['custom_title'], user, data) + else + title = data[action['title']] + end + + url = "/new-topic?title=#{title}" + + if action['post_builder'] + post = CustomWizard::Builder.fill_placeholders(action['post_template'], user, data) + else + post = data[action['post']] + end + + url += "&body=#{post}" + + if action['category_id'] + if category = Category.find(action['category_id']) + url += "&category=#{category.full_slug}" + end + end + + if action['tags'].present? + url += "&tags=#{action['tags'].join(',')}" + end + + data['redirect_on_complete'] = Discourse.base_uri + URI.encode(url) + end def add_to_group(user, action, data) if group_id = data[action['group_id']]