diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 0142d216..65299958 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -5,7 +5,8 @@ import { import { actionTypes, generateName, - generateSelectKitContent + generateSelectKitContent, + profileFields } from '../lib/custom-wizard'; export default Ember.Component.extend({ @@ -35,11 +36,6 @@ export default Ember.Component.extend({ newTopicFields(actionType) { return ['create_topic', 'send_message'].indexOf(actionType) > -1; }, - - @computed('wizardFields') - builderWizardFields(fields) { - return fields.map((f) => ` w{${f.id}}`); - }, @computed('wizardFields') categoryFields(fields) { @@ -51,13 +47,6 @@ export default Ember.Component.extend({ return fields.filter(f => f.type == 'tag'); }, - @computed() - builderUserFields() { - const noTheme = PROFILE_FIELDS.filter((f) => f !== 'theme_id'); - const fields = noTheme.concat(['email', 'username']); - return fields.map((f) => ` u{${f}}`); - }, - @observes('action.custom_category_wizard_field') toggleCustomCategoryUserField() { const wizard = this.get('action.custom_category_wizard_field'); diff --git a/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 b/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 index abcef1fa..cc9a6b66 100644 --- a/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 @@ -2,9 +2,11 @@ import { alias, equal } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, - observes + observes, + on } from "discourse-common/utils/decorators"; import { defaultSelectionType } from '../lib/custom-wizard'; +import { getOwner } from 'discourse-common/lib/get-owner'; export default Ember.Component.extend({ classNames: 'input-selector', @@ -13,6 +15,12 @@ export default Ember.Component.extend({ return this.site.categories.map(c => ({ id: c.id, name: c.name })); }), + @discourseComputed + userFields() { + const controller = getOwner(this).lookup('controller:admin-wizard'); + return controller.get('model.userFields'); + }, + @observes('options.@each') resetActiveType() { this.set('activeType', defaultSelectionType(this.selectorType, this.options)); diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 993b75bf..e7113c17 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -1,19 +1,19 @@ import { default as computed, on, observes } from 'discourse-common/utils/decorators'; +import { notEmpty } from "@ember/object/computed"; export default Ember.Component.extend({ classNames: 'wizard-links', items: Ember.A(), + anyLinks: notEmpty('links'), @on('didInsertElement') @observes('links.@each') didInsertElement() { - Ember.run.scheduleOnce('afterRender', () => { - this.applySortable(); - }); + Ember.run.scheduleOnce('afterRender', () => (this.applySortable())); }, applySortable() { - this.$("ul").sortable({tolerance: 'pointer'}).on('sortupdate', (e, ui) => { + $(this.element).find("ul").sortable({tolerance: 'pointer'}).on('sortupdate', (e, ui) => { const itemId = ui.item.data('id'); const index = ui.item.index(); Ember.run.bind(this, this.updateItemOrder(itemId, index)); @@ -69,7 +69,6 @@ export default Ember.Component.extend({ const newItem = Ember.Object.create(params); items.pushObject(newItem); this.set('current', newItem); - this.sendAction('isNew'); }, change(itemId) { diff --git a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 new file mode 100644 index 00000000..2a24cd0b --- /dev/null +++ b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 @@ -0,0 +1,40 @@ +import { default as discourseComputed } from 'discourse-common/utils/decorators'; +import { profileFields } from '../lib/custom-wizard'; + +export default Ember.Component.extend({ + classNames: 'wizard-text-editor', + + @discourseComputed('forcePreview') + previewLabel(forcePreview) { + return I18n.t("admin.wizard.editor.preview", { + action: I18n.t(`admin.wizard.editor.${forcePreview ? 'hide' : 'show'}`) + }); + }, + + @discourseComputed('showPopover') + popoverLabel(showPopover) { + return I18n.t("admin.wizard.editor.popover", { + action: I18n.t(`admin.wizard.editor.${showPopover ? 'hide' : 'show'}`) + }); + }, + + @discourseComputed() + userFieldList() { + return profileFields.map((f) => ` u{${f}}`); + }, + + @discourseComputed('wizardFields') + wizardFieldList(wizardFields) { + return wizardFields.map((f) => ` w{${f.id}}`); + }, + + actions: { + togglePreview() { + this.toggleProperty('forcePreview'); + }, + + togglePopover() { + this.toggleProperty('showPopover'); + } + } +}); \ No newline at end of file diff --git a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 index bb659329..acd25f95 100644 --- a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 @@ -9,8 +9,9 @@ export default Ember.Controller.extend({ @computed('model.after_time_scheduled') nextSessionScheduledLabel(scheduled) { - return scheduled ? moment(scheduled).format('MMMM Do, HH:mm') : - I18n.t('admin.wizard.after_time_time_label'); + return scheduled ? + moment(scheduled).format('MMMM Do, HH:mm') : + I18n.t('admin.wizard.after_time_time_label'); }, actions: { @@ -19,7 +20,9 @@ export default Ember.Controller.extend({ saving: true, error: null }); + const wizard = this.get('model'); + wizard.save().then(() => { this.set('saving', false); if (this.get('newWizard')) { diff --git a/assets/javascripts/discourse/routes/admin-wizard.js.es6 b/assets/javascripts/discourse/routes/admin-wizard.js.es6 index f2ebefbd..7a880ded 100644 --- a/assets/javascripts/discourse/routes/admin-wizard.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizard.js.es6 @@ -22,18 +22,20 @@ export default DiscourseRoute.extend({ model(params) { const wizardId = params.wizard_id; - - if (wizardId === 'new') { - this.set('newWizard', true); + this.set('newWizard', wizardId === 'new'); + + if (this.newWizard) { return CustomWizard.create(); - }; - this.set('newWizard', false); - - const wizard = this.modelFor('admin-wizards-custom').findBy('id', wizardId.underscore()); - - if (!wizard) return this.transitionTo('adminWizard', 'new'); - - return wizard; + } else { + const wizard = this.modelFor('admin-wizards-custom') + .findBy('id', wizardId.underscore()); + + if (!wizard) { + return this.transitionTo('adminWizard', 'new'); + } else { + return wizard; + } + } }, afterModel(model) { @@ -56,9 +58,15 @@ export default DiscourseRoute.extend({ }, _getThemes(model) { - return this.store.findAll('theme').then((result) => { - model.set('themes', result.content); - }); + return ajax('/admin/themes') + .then((result) => { + model.set('themes', result.themes.map(t => { + return { + id: t.id, + name: t.name + } + })); + }); }, _getApis(model) { @@ -69,13 +77,17 @@ export default DiscourseRoute.extend({ _getUserFields(model) { return this.store.findAll('user-field').then((result) => { if (result && result.content) { - let userContent = result.content.map((f) => { - return { id: `user_field_${f.id}`, name: f.name}; - }); - let profileContent = profileFields.map((f) => { - return { id: f, name: generateName(f) }; - }); - model.set('userFields', userContent.concat(profileContent)); + model.set('userFields', + result.content.map((f) => ({ + id: `user_field_${f.id}`, + name: f.name + })).concat( + profileFields.map((f) => ({ + id: f, + name: generateName(f) + })) + ) + ); } }); }, diff --git a/assets/javascripts/discourse/templates/admin-wizard.hbs b/assets/javascripts/discourse/templates/admin-wizard.hbs index fe5d0965..87265cc2 100644 --- a/assets/javascripts/discourse/templates/admin-wizard.hbs +++ b/assets/javascripts/discourse/templates/admin-wizard.hbs @@ -1,150 +1,195 @@
- {{i18n 'admin.wizard.header'}} -
- -
-
-

{{i18n 'admin.wizard.id'}}

-
-
- {{input name="name" value=model.id placeholderKey="admin.wizard.id_placeholder" disabled=model.existingId}} + {{model.name}} + +
- -
-
-

{{i18n 'admin.wizard.name'}}

+ +
+
+
+

{{i18n 'admin.wizard.id'}}

+
+
+ {{input + name="name" + value=model.id + placeholderKey="admin.wizard.id_placeholder" + disabled=model.existingId}} +
-
- {{input name="name" value=model.name placeholderKey="admin.wizard.name_placeholder"}} + +
+
+

{{i18n 'admin.wizard.name'}}

+
+
+ {{input + name="name" + value=model.name + placeholderKey="admin.wizard.name_placeholder"}} +
- -
-
-

{{i18n 'admin.wizard.background'}}

-
-
- {{input name="background" value=model.background placeholderKey="admin.wizard.background_placeholder"}} -
+ +
+ {{i18n 'admin.wizard.label'}}
+ +
+
+
+

{{i18n 'admin.wizard.background'}}

+
+
+ {{input + name="background" + value=model.background + placeholderKey="admin.wizard.background_placeholder"}} +
+
+ +
+
+

{{i18n 'admin.wizard.save_submissions'}}

+
+
+ {{input type='checkbox' checked=model.save_submissions}} + {{i18n 'admin.wizard.save_submissions_label'}} +
+
-
-
-

{{i18n 'admin.wizard.save_submissions'}}

+
+
+

{{i18n 'admin.wizard.multiple_submissions'}}

+
+
+ {{input type='checkbox' checked=model.multiple_submissions}} + {{i18n 'admin.wizard.multiple_submissions_label'}} +
-
- {{input type='checkbox' checked=model.save_submissions}} - {{i18n 'admin.wizard.save_submissions_label'}} -
-
-
-
-

{{i18n 'admin.wizard.multiple_submissions'}}

+
+
+

{{i18n 'admin.wizard.required'}}

+
+
+ {{input type='checkbox' checked=model.required}} + {{i18n 'admin.wizard.required_label'}} +
-
- {{input type='checkbox' checked=model.multiple_submissions}} - {{i18n 'admin.wizard.multiple_submissions_label'}} -
-
-
-
-

{{i18n 'admin.wizard.required'}}

+
+
+

{{i18n 'admin.wizard.after_signup'}}

+
+
+ {{input type='checkbox' checked=model.after_signup}} + {{i18n 'admin.wizard.after_signup_label'}} +
-
- {{input type='checkbox' checked=model.required}} - {{i18n 'admin.wizard.required_label'}} -
-
-
-
-

{{i18n 'admin.wizard.after_signup'}}

+
+
+

{{i18n 'admin.wizard.after_time'}}

+
+
+ {{input type='checkbox' checked=model.after_time}} + {{i18n 'admin.wizard.after_time_label'}} + {{d-button + action='setNextSessionScheduled' + translatedLabel=nextSessionScheduledLabel + class="btn-after-time" + icon='far-calendar'}} +
-
- {{input type='checkbox' checked=model.after_signup}} - {{i18n 'admin.wizard.after_signup_label'}} -
-
-
-
-

{{i18n 'admin.wizard.after_time'}}

+
+
+

{{i18n 'admin.wizard.prompt_completion'}}

+
+
+ {{input type='checkbox' checked=model.prompt_completion}} + {{i18n 'admin.wizard.prompt_completion_label'}} +
-
- {{input type='checkbox' checked=model.after_time}} - {{i18n 'admin.wizard.after_time_label'}} - {{d-button action='setNextSessionScheduled' translatedLabel=nextSessionScheduledLabel icon='far-calendar'}} -
-
-
-
-

{{i18n 'admin.wizard.prompt_completion'}}

+
+
+

{{i18n 'admin.wizard.min_trust'}}

+
+
+ {{i18n 'admin.wizard.min_trust_label'}} + {{input type='number' value=model.min_trust class='input-small'}} +
-
- {{input type='checkbox' checked=model.prompt_completion}} - {{i18n 'admin.wizard.prompt_completion_label'}} -
-
-
-
-

{{i18n 'admin.wizard.min_trust'}}

+
+
+

{{i18n 'admin.wizard.theme_id'}}

+
+
+ {{combo-box + content=model.themes + valueProperty='id' + value=model.theme_id + onChange=(action (mut model.theme_id)) + options=(hash + none='admin.wizard.no_theme' + )}} +
-
- {{i18n 'admin.wizard.min_trust_label'}} - {{input type='number' value=model.min_trust class='input-small'}} -
-
-
-
-

{{i18n 'admin.wizard.theme_id'}}

+
+
+

{{i18n 'admin.wizard.restart_on_revisit'}}

+
+
+ {{input type='checkbox' checked=model.restart_on_revisit}} + {{i18n 'admin.wizard.restart_on_revisit_label'}} +
-
- {{combo-box - content=model.themes - valueProperty='id' - value=model.theme_id - options=(hash - none='admin.wizard.no_theme' - )}} + +
+
+

{{i18n 'admin.wizard.group'}}

+
+
+ {{wizard-field-mapper + inputs=model.group + options=(hash + hasOutput=true + enableConnectors=true + userFieldSelection='key,value' + groupSelection=true + textDisabled='output' + )}} +
-
-
-

{{i18n 'admin.wizard.restart_on_revisit'}}

-
-
- {{input type='checkbox' checked=model.restart_on_revisit}} - {{i18n 'admin.wizard.restart_on_revisit_label'}} -
-
- -
-
-

{{i18n 'admin.wizard.url'}}

-
- {{wizardUrl}} -
- {{wizard-links type="step" current=currentStep items=model.steps}} + {{#if currentStep}} {{wizard-custom-step step=currentStep wizard=model}} {{/if}}
- + + {{#unless newWizard}} - + {{/unless}} + {{conditional-loading-spinner condition=saving size='small'}} + {{#if error}} {{d-icon "times"}}{{error}} {{/if}} diff --git a/assets/javascripts/discourse/templates/admin-wizards-api.hbs b/assets/javascripts/discourse/templates/admin-wizards-api.hbs index cf4ddf9c..fce6c1fa 100644 --- a/assets/javascripts/discourse/templates/admin-wizards-api.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards-api.hbs @@ -92,6 +92,7 @@ {{combo-box value=api.authType content=authorizationTypes + onChange=(action (mut authorizationTypes)) options=(hash none='admin.wizard.api.auth.type_none' )}} @@ -248,18 +249,21 @@ {{combo-box content=endpointMethods value=endpoint.method + onChange=(action (mut endpoint.method)) options=(hash none="admin.wizard.api.endpoint.method" )}} {{combo-box content=contentTypes value=endpoint.content_type + onChange=(action (mut endpoint.content_type)) options=(hash none="admin.wizard.api.endpoint.content_type" )}} {{multi-select content=successCodes values=endpoint.success_codes + onChange=(action (mut endpoint.success_codes)) options=(hash none="admin.wizard.api.endpoint.success_codes" )}} diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 2c0261ba..5a7442be 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -2,8 +2,12 @@

{{i18n "admin.wizard.id"}}

+
- {{input value=action.id placeholderKey='admin.wizard.id_placeholder' disabled=disableId}} + {{input + value=action.id + placeholderKey='admin.wizard.id_placeholder' + disabled=disableId}}
@@ -11,10 +15,12 @@

{{i18n "admin.wizard.type"}}

+
{{combo-box value=action.type content=types + onChange=(action (mut action.type)) options=(hash none="admin.wizard.field.type" )}} @@ -26,15 +32,18 @@

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

+
{{combo-box value=action.title content=wizardFields nameProperty="label" - isDisabled=action.custom_title_enabled + onChange=(action (mut action.title)) options=(hash none='admin.wizard.select_field' + isDisabled=action.custom_title_enabled )}} +
{{input type='checkbox' checked=action.custom_title_enabled}} {{i18n 'admin.wizard.action.custom_title'}} @@ -49,15 +58,18 @@

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

+
{{combo-box value=action.post content=wizardFields nameProperty='label' - isDisabled=action.post_builder + onChange=(action (mut action.post)) options=(hash none='admin.wizard.select_field' + isDisabled=action.post_builder )}} +
{{input type='checkbox' checked=action.post_builder}} {{i18n 'admin.wizard.action.post_builder.checkbox'}} @@ -70,15 +82,12 @@

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

+
- {{d-editor + {{wizard-text-editor value=action.post_template - placeholder='admin.wizard.action.interpolate_fields' - classNames='post-builder-editor'}} -
- - -
+ fieldsEnabled=true + wizardFields=wizardFields}}
{{/if}} @@ -89,13 +98,16 @@

{{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}}
@@ -106,11 +118,13 @@ value=action.category_id content=categoryFields nameProperty="label" + onChange=(action (mut action.category_id)) options=(hash none='admin.wizard.select_field' )}} {{/if}}
+
{{input type='checkbox' checked=action.custom_category_user_field}} {{i18n 'admin.wizard.action.custom_category.user_field'}} @@ -139,12 +153,14 @@
{{input type='checkbox' checked=action.custom_tag_enabled}} {{i18n 'admin.wizard.action.custom_tag.label'}} + {{#if action.custom_tag_enabled}}
{{combo-box value=action.custom_tag_field content=tagFields nameProperty="label" + onChange=(action (mut action.custom_tag_field)) options=(hash none='admin.wizard.select_field' )}} @@ -160,23 +176,31 @@

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

+
{{input type='checkbox' checked=action.skip_redirect}} - {{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}} + + + {{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}} +
{{/if}} {{#if createTopic}} -
- - {{wizard-field-mapper - inputs=action.add_fields - userFields=userFields - wizardFields=wizardFields - options=(hash - wizardFieldSelection=true - )}} +
+
+

{{i18n 'admin.wizard.action.add_fields'}}

+
+ +
+ {{wizard-field-mapper + inputs=action.add_fields + wizardFields=wizardFields + options=(hash + wizardFieldSelection=true + )}} +
{{/if}} @@ -191,6 +215,7 @@ value=action.required content=wizardFields nameProperty='label' + onChange=(action (mut action.required)) options=(hash none='admin.wizard.select_field' )}} @@ -201,6 +226,7 @@

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

+
{{user-selector single="true" @@ -210,21 +236,25 @@
-
- +
+
+

{{i18n 'admin.wizard.action.add_fields'}}

+
+ {{wizard-field-mapper inputs=action.add_fields - userFields=userFields wizardFields=wizardFields}}
{{/if}} {{#if updateProfile}} -
- +
+
+

{{i18n 'admin.wizard.action.add_fields'}}

+
+ {{wizard-field-mapper inputs=action.profile_updates - userFields=userFields wizardFields=wizardFields options=(hash wizardFieldSelection=true @@ -238,12 +268,14 @@

{{i18n "admin.wizard.action.send_to_api.api"}}

+
{{combo-box value=action.api content=availableApis - isDisabled=action.custom_title_enabled + onChange=(action (mut action.api)) options=(hash + isDisabled=action.custom_title_enabled none='admin.wizard.action.send_to_api.select_an_api' )}}
@@ -253,12 +285,14 @@

{{i18n "admin.wizard.action.send_to_api.endpoint"}}

+
{{combo-box value=action.api_endpoint content=availableEndpoints - isDisabled=apiEmpty + onChange=(action (mut action.api_endpoint)) options=(hash + isDisabled=apiEmpty none='admin.wizard.action.send_to_api.select_an_endpoint' )}}
@@ -268,25 +302,25 @@

{{i18n "admin.wizard.action.send_to_api.body"}}

+
- - - {{textarea + {{wizard-text-editor value=action.api_body - placeholder=(i18n 'admin.wizard.action.interpolate_fields')}} + fieldsEnabled=true + wizardFields=wizardFields}}
{{/if}} {{#if addToGroup}} -
+
-

{{i18n "admin.wizard.action.add_to_group.group"}}

+

{{i18n "admin.wizard.group"}}

+
{{wizard-field-mapper inputs=action.inputs - userFields=userFields wizardFields=wizardFields outputConnectorKey='admin.wizard.action.add_to_group.output_connector' options=(hash @@ -305,14 +339,17 @@

{{i18n "admin.wizard.action.route_to.url"}}

+
{{input value=action.url}}
+

{{i18n "admin.wizard.action.route_to.code"}}

+
{{input value=action.code}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs index 32f58dd8..8c846120 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs @@ -21,7 +21,7 @@

{{i18n 'admin.wizard.field.label'}}

- {{input name="label" value=field.label placeholder=(i18n "admin.wizard.custom_text_placeholder")}} + {{input name="label" value=field.label}}
@@ -30,7 +30,7 @@

{{i18n 'admin.wizard.field.description'}}

- {{textarea name="description" value=field.description placeholder=(i18n "admin.wizard.custom_text_placeholder")}} + {{textarea name="description" value=field.description}}
@@ -51,6 +51,7 @@ {{combo-box value=field.type content=types + onChange=(action (mut field.type)) options=(hash none="admin.wizard.field.type" )}} @@ -87,6 +88,7 @@ {{combo-box value=field.choices_type content=choicesTypes + onChange=(action (mut field.choices_type)) options=(hash none="admin.wizard.field.choices_type" )}} @@ -104,7 +106,6 @@
{{wizard-field-mapper inputs=field.choices - userFields=userFields wizardFields=wizardFields}} {{/if}} @@ -144,8 +145,9 @@
{{combo-box - content=categoryPropertyTypes value=field.property + content=categoryPropertyTypes + onChange=(action (mut field.property)) options=(hash none='admin.wizard.select_property' )}} @@ -153,28 +155,26 @@
{{/if}} -
+

{{i18n 'admin.wizard.field.prefill'}}

{{wizard-field-mapper inputs=field.prefill - userFields=userFields wizardFields=wizardFields options=prefillOptions}}
{{#if canFilter}} -
+

{{i18n 'admin.wizard.field.filter'}}

{{wizard-field-mapper inputs=field.filters - userFields=userFields wizardFields=wizardFields options=filterOptions}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-input-pair.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-input-pair.hbs index 41dbd3e9..06974074 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-input-pair.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-input-pair.hbs @@ -2,7 +2,6 @@ {{wizard-custom-input-selector selectorType='key' inputType=inputType - userFields=userFields wizardFields=wizardFields value=pair.key activeType=pair.key_type @@ -15,7 +14,8 @@ {{#if options.enableConnectors}} {{combo-box value=pair.connector - content=connectors}} + content=connectors + onChange=(action (mut pair.connector))}} {{/if}} {{#if connectorKey}} @@ -30,7 +30,6 @@ {{wizard-custom-input-selector selectorType='value' inputType=inputType - userFields=userFields wizardFields=wizardFields value=pair.value activeType=pair.value_type diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-input.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-input.hbs index c49a7dd6..1ef4517b 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-input.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-input.hbs @@ -2,7 +2,8 @@
{{combo-box value=input.type - content=inputTypes}} + content=inputTypes + onChange=(action (mut input.type))}}
{{/if}} @@ -15,7 +16,6 @@ inputType=inputType keyPlaceholder=keyPlaceholder valuePlaceholder=valuePlaceholder - userFields=userFields wizardFields=wizardFields options=options removePair=(action 'removePair')}} @@ -41,7 +41,6 @@ {{wizard-custom-input-selector selectorType='output' inputType=inputType - userFields=userFields wizardFields=wizardFields value=input.output activeType=input.output_type diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs index 50af2ee8..28b3b1b1 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs @@ -3,7 +3,11 @@

{{i18n 'admin.wizard.id'}}

- {{input name="id" value=step.id placeholderKey="admin.wizard.id_placeholder" disabled=disableId}} + {{input + name="id" + value=step.id + placeholderKey="admin.wizard.id_placeholder" + disabled=disableId}}
@@ -12,7 +16,10 @@

{{i18n 'admin.wizard.key'}}

- {{input name="key" value=step.key placeholderKey="admin.wizard.key_placeholder"}} + {{input + name="key" + value=step.key + placeholderKey="admin.wizard.key_placeholder"}}
@@ -21,7 +28,9 @@

{{i18n 'admin.wizard.step.title'}}

- {{input name="title" value=step.title placeholderKey="admin.wizard.custom_text_placeholder"}} + {{input + name="title" + value=step.title}}
@@ -30,7 +39,10 @@

{{i18n 'admin.wizard.step.banner'}}

- {{input name="banner" value=step.banner placeholderKey="admin.wizard.step.banner_placeholder"}} + {{input + name="banner" + value=step.banner + placeholderKey="admin.wizard.step.banner_placeholder"}}
@@ -39,20 +51,17 @@

{{i18n 'admin.wizard.step.description'}}

- {{d-editor - value=step.raw_description - placeholder="admin.wizard.custom_text_placeholder"}} + {{wizard-text-editor value=step.raw_description}}
-
+

{{i18n 'admin.wizard.step.required_data.label'}}

{{wizard-field-mapper inputs=step.required_data - userFields=userFields wizardFields=wizardFields keyPlaceholder="admin.wizard.submission_key" options=(hash @@ -71,14 +80,13 @@
-
+

{{i18n 'admin.wizard.step.permitted_params.label'}}

{{wizard-field-mapper inputs=step.permitted_params - userFields=userFields wizardFields=wizardFields keyPlaceholder='admin.wizard.param_key' valuePlaceholder='admin.wizard.submission_key' @@ -93,7 +101,6 @@ field=currentField types=wizard.fieldTypes removeField="removeField" - userFields=wizard.userFields wizardFields=wizardFields}} {{/if}} @@ -104,8 +111,5 @@ action=currentAction wizard=wizard removeAction="removeAction" - wizardFields=wizardFields - userFields=wizard.userFields}} -{{/if}} - - + wizardFields=wizardFields}} +{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/wizard-field-mapper.hbs b/assets/javascripts/discourse/templates/components/wizard-field-mapper.hbs index 1f8103c8..a7cb5375 100644 --- a/assets/javascripts/discourse/templates/components/wizard-field-mapper.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-field-mapper.hbs @@ -1,7 +1,6 @@ {{#each inputs as |input|}} {{wizard-custom-input input=input - userFields=userFields wizardFields=wizardFields keyPlaceholder=keyPlaceholder valuePlaceholder=valuePlaceholder diff --git a/assets/javascripts/discourse/templates/components/wizard-links.hbs b/assets/javascripts/discourse/templates/components/wizard-links.hbs index f81f1605..f6af79d8 100644 --- a/assets/javascripts/discourse/templates/components/wizard-links.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-links.hbs @@ -1,12 +1,14 @@ diff --git a/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs b/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs new file mode 100644 index 00000000..2fd241ea --- /dev/null +++ b/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs @@ -0,0 +1,28 @@ +{{d-editor + value=value + forcePreview=forcePreview}} + +
+ {{d-button + action="togglePreview" + translatedLabel=previewLabel}} + + {{#if fieldsEnabled}} + {{d-button + action="togglePopover" + translatedLabel=popoverLabel}} + + {{#if showPopover}} +
+ + +
+ {{/if}} + {{/if}} +
\ No newline at end of file diff --git a/assets/javascripts/wizard/components/custom-user-selector.js.es6 b/assets/javascripts/wizard/components/custom-user-selector.js.es6 index 7cbb86e6..143b340c 100644 --- a/assets/javascripts/wizard/components/custom-user-selector.js.es6 +++ b/assets/javascripts/wizard/components/custom-user-selector.js.es6 @@ -64,7 +64,7 @@ export default Ember.TextField.extend({ return usernames; } - this.$().val(this.get('usernames')).autocomplete({ + $(this.element).val(this.get('usernames')).autocomplete({ template, disabled: this.get('disabled'), single: this.get('single'), @@ -121,7 +121,7 @@ export default Ember.TextField.extend({ willDestroyElement() { this._super(); - this.$().autocomplete('destroy'); + $(this.element).autocomplete('destroy'); }, // THIS IS A HUGE HACK TO SUPPORT CLEARING THE INPUT @@ -129,7 +129,7 @@ export default Ember.TextField.extend({ _clearInput: function() { if (arguments.length > 1) { if (Em.isEmpty(this.get("usernames"))) { - this.$().parent().find("a").click(); + $(this.element).parent().find("a").click(); } } } diff --git a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 index ee969eef..58faff14 100644 --- a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 +++ b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 @@ -10,7 +10,7 @@ export default Ember.Component.extend({ didInsertElement() { this._super(); - const $upload = this.$(); + const $upload = $(this.element); const id = this.get("field.id"); diff --git a/assets/stylesheets/wizard_custom_admin.scss b/assets/stylesheets/wizard_custom_admin.scss index 56727b1c..e8411c6d 100644 --- a/assets/stylesheets/wizard_custom_admin.scss +++ b/assets/stylesheets/wizard_custom_admin.scss @@ -1,6 +1,35 @@ +$setting-background: dark-light-diff($primary, $secondary, 96%, -65%); + .wizard-list { float: left; width: 250px; + margin-top: 10px; +} + +.wizard-settings-parent { + margin-bottom: 20px; + padding: 20px; + background-color: $setting-background; +} + +.wizard-settings-group { + display: flex; + justify-content: space-between; + flex-flow: wrap; + width: 100%; + box-sizing: border-box; +} + +.wizard-settings, +.wizard-custom-step { + @extend .wizard-settings-parent; + @extend .wizard-settings-group; +} + +.wizard-basic-details, +.wizard-custom-field, +.wizard-custom-action { + @extend .wizard-settings-group; } .new-wizard { @@ -8,11 +37,11 @@ } .wizard-header { - font-size: 1.4em; - margin-bottom: 15px; + font-size: 1.5em; + margin-bottom: 20px; &.medium { - font-size: 1.2em; + font-size: 1.3em; } &.small { @@ -23,6 +52,13 @@ &.underline { text-decoration: underline; } + + .wizard-url { + display: inline-block; + font-size: 1rem; + margin-left: 20px; + background-color: $setting-background; + } } .content-list + .content { @@ -30,18 +66,25 @@ } .admin-wizard.settings { + margin-top: 10px; margin-left: 30px; .setting { - display: inline-block; + display: inline-flex; vertical-align: top; - width: 49%; + width: 48%; .setting-label { - width: 20%; + width: 80px; } .setting-value { + flex: 1; + overflow: initial; + float: initial; + width: initial; + padding: 0; + label { font-size: 0.85em; } @@ -53,56 +96,26 @@ button { display: block; } - - .d-editor { + + input[type="text"], textarea { width: 100%; - - .d-editor-input { - height: 100px; - } - - button { - margin: 0; - } + box-sizing: border-box; + } + + input[disabled] { + background-color: $primary-low; + cursor: not-allowed; } } &.full { width: 100%; - - &.custom-inputs { - padding-bottom: 30px; - - .setting-label { - margin-top: 20px; - } - - .add-custom-input:first-child { - margin-top: 16px; - } - - .multi-select { - .multi-select-header, input { - min-height: 25px; - } - - .choices .choice { - height: 24px; - } - } - } - - .setting-label { - width: 10%; - } .setting-value { width: initial; float: none; - display: flex; &.editor { - flex-flow: wrap; .d-editor { margin-bottom: 5px; @@ -110,6 +123,14 @@ } } } + + &.field-mapper-setting { + padding-bottom: 20px; + + .setting-label { + margin-top: 20px; + } + } label { margin: 5px 0; @@ -159,8 +180,95 @@ } } +.field-mapper { + width: 100%; + display: inline-block; + + > .custom-input, > .add-custom-input { + float: left; + clear: left; + } + + .add-custom-input:first-child { + margin-top: 15px; + } + + .multi-select { + .multi-select-header, input { + min-height: 25px; + } + + .choices .choice { + height: 24px; + } + } +} + +.btn-after-time { + margin-top: 7px; +} + +.wizard-text-editor { + .d-editor { + width: 100%; + + .d-editor-input { + min-height: 120px; + } + + .d-editor-container { + display: block; + } + + .d-editor-textarea-wrapper { + display: grid; + margin-bottom: 10px; + + textarea { + resize: vertical; + } + } + + .d-editor-preview-wrapper { + display: none; + margin: 0 0 10px 0; + padding: 10px; + background-color: $secondary; + border: 1px solid $primary-medium; + max-width: 100%; + + &.force-preview { + display: block; + } + } + + button { + margin: 0; + } + } + + .wizard-editor-gutter { + position: relative; + display: flex; + + .btn { + margin-right: 10px; + } + + .wizard-editor-gutter-popover { + position: absolute; + padding: 10px; + background-color: $secondary; + box-shadow: shadow('card'); + z-index: 200; + top: 40px; + } + } +} + .wizard-links { margin-bottom: 20px; + width: 100%; ul { margin: 0; @@ -190,17 +298,11 @@ position: relative; } -.wizard-custom-step { - display: inline-block; - margin-bottom: 20px; - padding: 15px; - background-color: dark-light-diff($primary, $secondary, 96%, -65%); -} - .wizard-dropdown-choices { padding: 15px; margin-bottom: 20px; background-color: $secondary; + width: 100%; .wizard-header:not(.underline) { margin-top: 15px; @@ -208,7 +310,7 @@ } .custom-input { - display: flex; + display: inline-flex; align-items: flex-start; margin-bottom: 10px; position: relative; @@ -234,7 +336,7 @@ position: relative; .add-pair { - margin-top: 4px; + margin-top: 10px; } .remove-pair { @@ -255,7 +357,10 @@ display: flex; align-items: flex-end; position: relative; - margin-bottom: 10px; + + &:not(:first-of-type) { + margin-top: 10px; + } &.no-connector div.input-block:not(:last-of-type) { margin-right: 10px; @@ -281,7 +386,9 @@ } a.remove-input { - margin: 25px 0 0 10px; + position: absolute; + right: -25px; + top: 25px; } .connector { @@ -307,14 +414,11 @@ } } -.required-data .setting-value { - flex-flow: wrap; - - .custom-inputs { - margin-bottom: 20px; - } - - .required-data-message .label { +.required-data-message { + display: inline-block; + margin-top: 20px; + + .label { margin-bottom: 5px; } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 61103996..c2eac0af 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -19,10 +19,10 @@ en: save_submissions_label: "Save wizard submissions." multiple_submissions: "Multiple" multiple_submissions_label: "Allow multiple submissions by the same user." - after_signup: "After Signup" - after_signup_label: "Users are directed to wizard after signup." - after_time: "After Time" - after_time_label: "Users are directed to wizard after the start time until wizard is completed or skipped." + after_signup: "Signup" + after_signup_label: "Users are directed to wizard after creating an account." + after_time: "Time" + after_time_label: "Users are directed to wizard after the start time." after_time_time_label: "Start Time" after_time_modal: title: "Wizard Start Time" @@ -42,7 +42,6 @@ en: no_theme: "Select a Theme (optional)" save: "Save Changes" remove: "Delete Wizard" - header: "Wizard" add: "Add" url: "Url" key: "Key" @@ -53,7 +52,6 @@ en: id: "Id" id_placeholder: "Underscored. Cannot be changed." key_placeholder: "Translation key" - custom_text_placeholder: "Overrides translation" type: "Type" none: "Make a selection" user_field: "User Field" @@ -64,6 +62,13 @@ en: profile_field: "Profile Field" submission_key: 'submission key' param_key: 'param' + group: "Group" + + editor: + show: "Show" + hide: "Hide" + preview: "{{action}} Preview" + popover: "{{action}} Fields" input: conditional: @@ -91,10 +96,10 @@ en: banner_placeholder: "Image url" description: "Description" required_data: - label: "Required Data" + label: "Required" not_permitted_message: "Message shown when required data not present" permitted_params: - label: "Permitted Params" + label: "Params" connector: "save as" field: @@ -126,17 +131,16 @@ en: filter: "Content" action: - header: "Actions*" + header: "Actions" include: "Include Fields" title: "Title" post: "Post" - add_fields: "{{type}} Fields" - available_fields: "* If 'Save wizard submissions' is disabled, only the fields of the current step are available to the current step's actions." + add_fields: "Fields" topic_attr: "Topic Attribute" interpolate_fields: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}." skip_redirect: - label: "Skip Redirect" + label: "No Redirect" description: "Don't redirect the user to this {{type}} after the wizard completes" send_message: label: "Send Message" @@ -155,7 +159,6 @@ en: placeholder: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}." add_to_group: label: "Add to Group" - group: "Group" output_connector: "add to" route_to: label: "Route To" @@ -173,7 +176,7 @@ en: endpoint: "Endpoint" select_an_api: "Select an API" select_an_endpoint: "Select an endpoint" - body: "Request body JSON" + body: "Body" api: label: "API"