From 04d7fc1c59ee34625946ab519eccca29fbf030b8 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Mon, 6 Apr 2020 11:54:16 +1000 Subject: [PATCH] various --- .../components/wizard-custom-action.js.es6 | 6 +- .../components/wizard-custom-field.js.es6 | 36 ++++--- .../components/wizard-custom-step.js.es6 | 14 --- .../discourse/components/wizard-links.js.es6 | 6 +- .../components/wizard-mapper-input.js.es6 | 1 + .../wizard-mapper-selector-type.js.es6 | 11 +- .../components/wizard-mapper-selector.js.es6 | 76 +++++++++---- .../discourse/components/wizard-mapper.js.es6 | 16 +-- .../discourse/controllers/admin-wizard.js.es6 | 24 +++-- .../controllers/next-session-scheduled.js.es6 | 6 +- .../discourse/lib/wizard-mapper.js.es6 | 13 +-- .../javascripts/discourse/lib/wizard.js.es6 | 6 +- .../discourse/models/custom-wizard-api.js.es6 | 4 +- .../discourse/routes/admin-wizard.js.es6 | 2 +- .../discourse/templates/admin-wizard.hbs | 9 +- .../discourse/templates/admin-wizards.hbs | 4 +- .../components/wizard-custom-action.hbs | 8 ++ .../components/wizard-custom-field.hbs | 8 +- .../components/wizard-custom-step.hbs | 102 +++++++++--------- .../components/wizard-mapper-input.hbs | 2 +- .../wizard-mapper-selector-type.hbs | 2 +- .../components/wizard-mapper-selector.hbs | 37 +++++-- assets/stylesheets/common/wizard-admin.scss | 16 ++- assets/stylesheets/common/wizard-mapper.scss | 18 ++++ config/locales/client.en.yml | 5 +- config/locales/server.en.yml | 4 +- config/settings.yml | 8 +- 27 files changed, 283 insertions(+), 161 deletions(-) diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 6f04993b..7794b61c 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -19,8 +19,10 @@ export default Component.extend({ @on('didInsertElement') @observes('action.type') - updateId() { - if (this.action.type) this.set('action.id', generateName(this.action.type)); + setLabel() { + if (this.action.type) { + this.set('action.label', generateName(this.action.type)); + }; }, @discourseComputed('action.type') diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 609908ec..7cd2908a 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -34,14 +34,18 @@ export default Component.extend({ let options = { wizardFieldSelection: true, textSelection: 'key,value', - userFieldSelection: 'key,value' + userFieldSelection: 'key,value', + context: 'field' } if (this.isDropdown) { + options.wizardFieldSelection = 'key,value'; + options.listSelection = 'assignment'; options.inputTypes = 'pair,assignment'; - options.pairConnector = 'equal'; + options.pairConnector = 'association'; options.keyPlaceholder = 'admin.wizard.key'; options.valuePlaceholder = 'admin.wizard.value'; + options.outputDefaultSelection = 'list'; } return options; @@ -52,23 +56,29 @@ export default Component.extend({ let options = { wizardFieldSelection: true, textSelection: 'key,value', - userFieldSelection: 'key,value' + userFieldSelection: 'key,value', + context: 'field' } - if (!this.isDropdown) { - let selectionType = { - category: 'category', - tag: 'tag', - group: 'group', - dropdown: 'text' - }[fieldType]; - options[`${selectionType}Selection`] = 'output'; - options.outputDefaultSelection = selectionType; - } + let outputSelectionType = { + category: 'category', + tag: 'tag', + group: 'group', + dropdown: 'text' + }[fieldType]; + + options[`${outputSelectionType}Selection`] = 'output'; + options.outputDefaultSelection = outputSelectionType; return options; }, + @observes('field.type') + clearInputs() { + this.set('field.content', null); + this.set('field.prefill', null); + }, + actions: { imageUploadDone(upload) { this.set("field.image", upload.url); diff --git a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 index 1ddd3fca..6b4dc4a9 100644 --- a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 @@ -5,21 +5,7 @@ import Component from "@ember/component"; export default Component.extend({ classNames: 'wizard-custom-step', - currentField: null, - currentAction: null, disableId: not('step.isNew'), - - @on('didInsertElement') - @observes('step') - resetCurrentObjects() { - const fields = this.step.fields; - const actions = this.step.actions; - - this.setProperties({ - currentField: fields.length ? fields[0] : null, - currentAction: actions.length ? actions[0] : null - }); - }, @discourseComputed('wizardFields', 'wizard.steps') requiredContent(wizardFields, steps) { diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 761d0521..c10b9d57 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -35,15 +35,15 @@ export default Component.extend({ @discourseComputed('type') header: (type) => `admin.wizard.${type}.header`, - @discourseComputed('items.@each.id', 'current') - links(items, current) { + @discourseComputed('current', 'items.@each.id', 'items.@each.label') + links(current, items) { if (!items) return; return items.map((item) => { if (item) { const id = item.id; const type = this.type; - const label = type === 'action' ? id : (item.label || item.title || id); + const label = item.label || item.title || id; let link = { id, label }; let classes = 'btn'; diff --git a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 index ce175398..efeee646 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 @@ -2,6 +2,7 @@ import { computed, set } from "@ember/object"; import { alias, equal, or } from "@ember/object/computed"; import { newPair, connectorContent, inputTypesContent } from '../lib/wizard-mapper'; import Component from "@ember/component"; +import { observes } from "discourse-common/utils/decorators"; export default Component.extend({ classNameBindings: [':mapper-input', 'type'], diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector-type.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector-type.js.es6 index d5041871..53baccef 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector-type.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector-type.js.es6 @@ -1,19 +1,14 @@ import discourseComputed from 'discourse-common/utils/decorators'; -import { snakeCase } from '../lib/wizard'; -import { selectionTypes } from '../lib/wizard-mapper'; import Component from "@ember/component"; export default Component.extend({ tagName: 'a', - classNameBindings: ['type', 'active'], + classNameBindings: ['active'], - @discourseComputed('type', 'activeType') + @discourseComputed('item.type', 'activeType') active(type, activeType) { return type === activeType }, - @discourseComputed('type') - label(type) { return I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) }, - click() { - this.toggle(this.type) + this.toggle(this.item.type) } }) \ No newline at end of file diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index 38ed763a..fd165cff 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -1,10 +1,11 @@ -import { alias, or } from "@ember/object/computed"; +import { alias, or, gt } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, observes } from "discourse-common/utils/decorators"; import { getOwner } from 'discourse-common/lib/get-owner'; import { defaultSelectionType, selectionTypes } from '../lib/wizard-mapper'; import { snakeCase, selectKitContent } from '../lib/wizard'; import Component from "@ember/component"; +import { bind } from "@ember/runloop"; export default Component.extend({ classNames: 'mapper-selector', @@ -28,25 +29,50 @@ export default Component.extend({ groupEnabled: computed('options.groupSelection', 'inputType', function() { return this.optionEnabled('groupSelection') }), userEnabled: computed('options.userSelection', 'inputType', function() { return this.optionEnabled('userSelection') }), listEnabled: computed('options.listSelection', 'inputType', function() { return this.optionEnabled('listSelection') }), + hasTypes: gt('selectorTypes.length', 1), + showTypes: false, + + didInsertElement() { + $(document).on("click", bind(this, this.documentClick)); + }, + + willDestroyElement() { + $(document).off("click", bind(this, this.documentClick)); + }, + + documentClick(e) { + let $element = $(this.element); + let $target = $(e.target); + + if (!$target.hasClass('type-selector-icon') && + $target.closest($element).length < 1 && + this._state !== "destroying") { + + this.set("showTypes", false); + } + }, + + @discourseComputed + selectorTypes() { + return selectionTypes.filter(type => (this[`${type}Enabled`])) + .map(type => ({ type, label: this.typeLabel(type) })); + }, @discourseComputed('activeType') - selectorTypes(activeType) { - return selectionTypes.filter(type => (this[`${type}Enabled`])); + activeTypeLabel(activeType) { + return this.typeLabel(activeType); }, - @discourseComputed - userFields() { - const controller = getOwner(this).lookup('controller:admin-wizard'); - return controller.model.userFields; + typeLabel(type) { + return I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) }, - @discourseComputed - wizardFields() { - const controller = getOwner(this).lookup('controller:admin-wizard'); - return controller.wizardFields; + @discourseComputed('showTypes') + typeSelectorIcon(showTypes) { + return showTypes ? 'chevron-down' : 'chevron-right'; }, - @observes('options.@each') + @observes('options.@each', 'inputType') resetActiveType() { this.set('activeType', defaultSelectionType(this.selectorType, this.options)); }, @@ -58,7 +84,15 @@ export default Component.extend({ @discourseComputed('activeType') comboBoxContent(activeType) { - return this[`${activeType}Fields`]; + const controller = getOwner(this).lookup('controller:admin-wizard'); + let content = controller[`${activeType}s`]; + + if (activeType === 'wizardField' && this.options.context === 'field') { + const currentField = controller.currentField; + content = content.filter(field => field.id !== currentField.id); + } + + return content; }, @discourseComputed('activeType') @@ -70,18 +104,19 @@ export default Component.extend({ }[activeType]; }, - @discourseComputed('activeType') - placeholder(activeType) { + @discourseComputed('activeType', 'inputType') + placeholderKey(activeType, inputType) { if (activeType === 'text' && this.options[`${this.selectorType}Placeholder`]) { return this.options[`${this.selectorType}Placeholder`]; - } - return `admin.wizard.selector.placeholder.${snakeCase(activeType)}`; + } else { + return `admin.wizard.selector.placeholder.${snakeCase(activeType)}`; + } }, @discourseComputed('activeType') multiSelectOptions(activeType) { let result = { - none: this.placeholder + none: this.placeholderKey }; if (activeType === 'list') { @@ -111,6 +146,11 @@ export default Component.extend({ actions: { toggleType(type) { this.set('activeType', type); + this.set('showTypes', false); + }, + + toggleTypes() { + this.toggleProperty('showTypes') } } }) \ No newline at end of file diff --git a/assets/javascripts/discourse/components/wizard-mapper.js.es6 b/assets/javascripts/discourse/components/wizard-mapper.js.es6 index 27363917..5db00dbe 100644 --- a/assets/javascripts/discourse/components/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper.js.es6 @@ -18,11 +18,13 @@ export default Component.extend({ let result = { inputTypes: options.inputTypes || 'conditional,assignment', pairConnector: options.pairConnector || null, - outputConnector: options.outputConnector || null + outputConnector: options.outputConnector || null, + context: options.context || null } let inputTypes = ['key', 'value', 'output']; inputTypes.forEach(type => { + result[`${type}Placeholder`] = options[`${type}Placeholder`] || null; result[`${type}DefaultSelection`] = options[`${type}DefaultSelection`] || null; }); @@ -33,18 +35,16 @@ export default Component.extend({ result[`${type}Selection`] = type === 'text' ? true : false; } }); - + return result; }, - - @observes('options.inputTypes') - clearInputs() { - this.get('inputs').clear(); - }, actions: { add() { - if (!this.get('inputs')) this.set('inputs', A()); + if (!this.get('inputs')) { + this.set('inputs', A()); + } + this.get('inputs').pushObject(newInput(this.inputOptions)); }, diff --git a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 index b99ba6d8..ae9c832b 100644 --- a/assets/javascripts/discourse/controllers/admin-wizard.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizard.js.es6 @@ -1,5 +1,5 @@ -import { default as discourseComputed, observes } from 'discourse-common/utils/decorators'; -import { notEmpty } from "@ember/object/computed"; +import { default as discourseComputed, observes, on } from 'discourse-common/utils/decorators'; +import { notEmpty, alias } from "@ember/object/computed"; import showModal from 'discourse/lib/show-modal'; import { generateId } from '../lib/wizard'; import { buildProperties } from '../lib/wizard-json'; @@ -10,15 +10,27 @@ import Controller from "@ember/controller"; export default Controller.extend({ hasName: notEmpty('model.name'), - - init() { - this._super(); + userFields: alias('model.userFields'), + + @observes('currentStep') + resetCurrentObjects() { + const currentStep = this.currentStep; + const fields = currentStep.fields; + const actions = currentStep.actions; + + this.setProperties({ + currentField: fields.length ? fields[0] : null, + currentAction: actions.length ? actions[0] : null + }); + scheduleOnce('afterRender', () => ($("body").addClass('admin-wizard'))); }, @observes('model.name') setId() { - if (!this.model.existingId) this.set('model.id', generateId(this.model.name)); + if (!this.model.existingId) { + this.set('model.id', generateId(this.model.name)); + } }, @discourseComputed('model.id') diff --git a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 index 00c0add2..cb7650e7 100644 --- a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 +++ b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 @@ -1,4 +1,4 @@ -import { default as computed } from 'discourse-common/utils/decorators'; +import { default as discourseComputed } from 'discourse-common/utils/decorators'; import { scheduleOnce } from "@ember/runloop"; import Controller from "@ember/controller"; @@ -24,12 +24,12 @@ export default Controller.extend({ }); }, - @computed('date', 'time') + @discourseComputed('date', 'time') dateTime: function(date, time) { return moment(date + 'T' + time).format(); }, - @computed('dateTime') + @discourseComputed('dateTime') submitDisabled(dateTime) { return moment().isAfter(dateTime); }, diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index 38f9429b..88d86dad 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -67,13 +67,13 @@ function connectorContent(connectorType, inputType, opts) { const selectionTypes = [ 'text', + 'list', 'wizardField', 'userField', 'group', 'category', 'tag', - 'user', - 'list' + 'user' ] function defaultSelectionType(inputType, options = {}) { @@ -116,9 +116,7 @@ function newPair(inputType, options = {}) { function newInput(options = {}) { const inputType = defaultInputType(options); - - console.log(inputType); - + let params = { type: inputType, pairs: A( @@ -134,7 +132,10 @@ function newInput(options = {}) { ) } - if (['conditional', 'assignment'].indexOf(inputType) > -1) { + if (['conditional', 'assignment'].indexOf(inputType) > -1 || + options.outputDefaultSelection || + options.outputConnector) { + params['output_type'] = defaultSelectionType('output', options); params['connector'] = defaultConnector('output', inputType, options); } diff --git a/assets/javascripts/discourse/lib/wizard.js.es6 b/assets/javascripts/discourse/lib/wizard.js.es6 index 9b085038..00bba29b 100644 --- a/assets/javascripts/discourse/lib/wizard.js.es6 +++ b/assets/javascripts/discourse/lib/wizard.js.es6 @@ -6,7 +6,7 @@ function generateName(id) { return id ? sentenceCase(id) : ''; } -function generateId(name) { +function generateId(name, opts={}) { return name ? snakeCase(name) : ''; } @@ -167,7 +167,9 @@ const actionTypes = [ 'add_to_group', 'route_to', 'open_composer' -]; +].filter(function(type) { + return Discourse.SiteSettings.wizard_api_features || type !== 'send_to_api'; +}); export { selectKitContent, diff --git a/assets/javascripts/discourse/models/custom-wizard-api.js.es6 b/assets/javascripts/discourse/models/custom-wizard-api.js.es6 index 90e74a7e..5359534e 100644 --- a/assets/javascripts/discourse/models/custom-wizard-api.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard-api.js.es6 @@ -1,10 +1,10 @@ import { ajax } from 'discourse/lib/ajax'; -import { default as computed } from 'discourse-common/utils/decorators'; +import { default as discourseComputed } from 'discourse-common/utils/decorators'; import EmberObject from "@ember/object"; import { A } from "@ember/array"; const CustomWizardApi = EmberObject.extend({ - @computed('name') + @discourseComputed('name') redirectUri(name) { let nameParam = name.toString().dasherize(); const baseUrl = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: ''); diff --git a/assets/javascripts/discourse/routes/admin-wizard.js.es6 b/assets/javascripts/discourse/routes/admin-wizard.js.es6 index 8f5173d3..3ce498ec 100644 --- a/assets/javascripts/discourse/routes/admin-wizard.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizard.js.es6 @@ -92,7 +92,7 @@ export default DiscourseRoute.extend({ setupController(controller, model) { const newWizard = this.get('newWizard'); const steps = model.get('steps') || []; - + controller.setProperties({ newWizard, model, diff --git a/assets/javascripts/discourse/templates/admin-wizard.hbs b/assets/javascripts/discourse/templates/admin-wizard.hbs index ba6fac31..fa4d65ac 100644 --- a/assets/javascripts/discourse/templates/admin-wizard.hbs +++ b/assets/javascripts/discourse/templates/admin-wizard.hbs @@ -48,7 +48,6 @@
-
@@ -113,6 +112,7 @@ inputs=model.permitted options=(hash singular=true + context='wizard' inputTypes='assignment' groupSelection='output' textSelection='key,value' @@ -153,7 +153,12 @@ {{wizard-links type="step" current=currentStep items=model.steps}} {{#if currentStep}} - {{wizard-custom-step step=currentStep wizard=model wizardFields=wizardFields}} + {{wizard-custom-step + step=currentStep + wizard=model + currentField=currentField + currentAction=currentAction + wizardFields=wizardFields}} {{/if}}
diff --git a/assets/javascripts/discourse/templates/admin-wizards.hbs b/assets/javascripts/discourse/templates/admin-wizards.hbs index 4ebb6a36..ffe33a6f 100644 --- a/assets/javascripts/discourse/templates/admin-wizards.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards.hbs @@ -1,7 +1,9 @@ {{#admin-nav}} {{nav-item route='adminWizardsCustom' label='admin.wizard.custom_label'}} {{nav-item route='adminWizardsSubmissions' label='admin.wizard.submissions_label'}} - {{nav-item route='adminWizardsApis' label='admin.wizard.api.nav_label'}} + {{#if siteSettings.wizard_api_features}} + {{nav-item route='adminWizardsApis' label='admin.wizard.api.nav_label'}} + {{/if}} {{nav-item route='adminWizardsTransfer' label='admin.wizard.transfer.nav_label'}} {{/admin-nav}} diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 5fe96814..d85d4251 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -26,6 +26,7 @@ options=(hash wizardFieldSelection=true userFieldSelection='key,value' + context='action' )}}
@@ -83,6 +84,7 @@ userFieldSelection='key,value' categorySelection='output' outputDefaultSelection='category' + context='action' )}}
@@ -99,6 +101,7 @@ tagSelection='output' wizardFieldSelection=true userFieldSelection='key,value' + context='action' )}} @@ -120,6 +123,7 @@ groupSelection='key,value' userSelection='output' outputDefaultSelection='user' + context='action' )}} @@ -139,6 +143,7 @@ wizardFieldSelection='value' keyDefaultSelection='userField' keyPlaceholder='admin.wizard.action.update_profile.key' + context='action' )}} {{/if}} @@ -209,6 +214,7 @@ userFieldSelection='key,value,assignment' groupSelection='value,output' outputDefaultSelection='group' + context='action' )}} @@ -246,6 +252,7 @@ wizardFieldSelection='value' userFieldSelection='value' keyPlaceholder='admin.wizard.action.custom_fields.key' + context='action' )}} @@ -265,6 +272,7 @@ wizardFieldSelection=true userFieldSelection=true groupSelection=true + context='action' )}} diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs index 4e39ba4a..909e7ae4 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs @@ -123,7 +123,9 @@
- {{wizard-mapper inputs=field.prefill options=prefillOptions}} + {{wizard-mapper + inputs=field.prefill + options=prefillOptions}}
{{/if}} @@ -135,7 +137,9 @@
- {{wizard-mapper inputs=field.content options=contentOptions}} + {{wizard-mapper + inputs=field.content + options=contentOptions}}
{{/if}} diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs index 770ef844..07a8c593 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs @@ -34,62 +34,66 @@ -{{wizard-advanced-toggle showAdvanced=step.showAdvanced}} +{{#if siteSettings.wizard_step_advanced}} + {{wizard-advanced-toggle showAdvanced=step.showAdvanced}} -{{#if step.showAdvanced}} -
- -
-
- -
-
- {{wizard-mapper - inputs=step.required_data - options=(hash - wizardFieldSelection='value' - userFieldSelection='value' - keyPlaceholder="admin.wizard.submission_key" - )}} - {{#if step.required_data}} -
-
- {{i18n 'admin.wizard.step.required_data.not_permitted_message'}} + {{#if step.showAdvanced}} +
+ +
+
+ +
+
+ {{wizard-mapper + inputs=step.required_data + options=(hash + wizardFieldSelection='value' + userFieldSelection='value' + keyPlaceholder="admin.wizard.submission_key" + context='step' + )}} + {{#if step.required_data}} +
+
+ {{i18n 'admin.wizard.step.required_data.not_permitted_message'}} +
+ {{input value=step.required_data_message}}
- {{input value=step.required_data_message}} -
- {{/if}} + {{/if}} +
-
-
-
- +
+
+ +
+
+ {{wizard-mapper + inputs=step.permitted_params + options=(hash + pairConnector='set' + keyPlaceholder='admin.wizard.param_key' + valuePlaceholder='admin.wizard.submission_key' + context='step' + )}} +
-
- {{wizard-mapper - inputs=step.permitted_params - options=(hash - pairConnector='set' - keyPlaceholder='admin.wizard.param_key' - valuePlaceholder='admin.wizard.submission_key' - )}} + +
+
+ +
+
+ {{input + name="key" + value=step.key + placeholderKey="admin.wizard.translation_placeholder"}} +
+
- -
-
- -
-
- {{input - name="key" - value=step.key - placeholderKey="admin.wizard.translation_placeholder"}} -
-
- -
+ {{/if}} {{/if}} {{wizard-links type="field" current=currentField items=step.fields}} diff --git a/assets/javascripts/discourse/templates/components/wizard-mapper-input.hbs b/assets/javascripts/discourse/templates/components/wizard-mapper-input.hbs index adf58e6a..65f2daa4 100644 --- a/assets/javascripts/discourse/templates/components/wizard-mapper-input.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-mapper-input.hbs @@ -32,7 +32,7 @@
{{wizard-mapper-selector selectorType='output' - inputType=inputType + inputType=input.type value=input.output activeType=input.output_type options=options}} diff --git a/assets/javascripts/discourse/templates/components/wizard-mapper-selector-type.hbs b/assets/javascripts/discourse/templates/components/wizard-mapper-selector-type.hbs index 64971c19..2ef7f2a3 100644 --- a/assets/javascripts/discourse/templates/components/wizard-mapper-selector-type.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-mapper-selector-type.hbs @@ -1 +1 @@ -{{label}} \ No newline at end of file +{{item.label}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs b/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs index 8f5683f8..49d29c22 100644 --- a/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs @@ -1,10 +1,23 @@
- {{#each selectorTypes as |type|}} - {{wizard-mapper-selector-type - activeType=activeType - type=type - toggle=(action 'toggleType')}} - {{/each}} + {{#if hasTypes}} + + {{activeTypeLabel}} + {{d-icon typeSelectorIcon class="type-selector-icon"}} + + + {{#if showTypes}} +
+ {{#each selectorTypes as |item|}} + {{wizard-mapper-selector-type + activeType=activeType + item=item + toggle=(action 'toggleType')}} + {{/each}} +
+ {{/if}} + {{else}} + {{activeTypeLabel}} + {{/if}}
@@ -12,7 +25,7 @@ {{input type="text" value=value - placeholder=(i18n placeholder)}} + placeholder=(i18n placeholderKey)}} {{/if}} {{#if showComboBox}} @@ -21,7 +34,7 @@ content=comboBoxContent onChange=(action (mut value)) options=(hash - none=placeholder + none=placeholderKey )}} {{/if}} @@ -34,7 +47,9 @@ {{/if}} {{#if showList}} - {{value-list values=value}} + {{value-list + values=value + addKey=placeholderKey}} {{/if}} {{#if showTag}} @@ -42,14 +57,14 @@ tags=value filterable=true options=(hash - none=placeholder + none=placeholderKey )}} {{/if}} {{#if showUser}} {{user-selector includeMessageableGroups='true' - placeholderKey=placeholder + placeholderKey=placeholderKey usernames=value autocomplete="discourse"}} {{/if}} diff --git a/assets/stylesheets/common/wizard-admin.scss b/assets/stylesheets/common/wizard-admin.scss index 49b960e6..ca87548e 100644 --- a/assets/stylesheets/common/wizard-admin.scss +++ b/assets/stylesheets/common/wizard-admin.scss @@ -51,12 +51,20 @@ body.admin-wizard { padding: 20px; } -.wizard-links { - &.action, &.field { - margin-top: 50px; - } +// style workdarounds for wizard_step_advanced site setting - to be refactored + +.wizard-custom-step .wizard-advanced-toggle + .wizard-links.field, +.wizard-custom-step .advanced-settings + .wizard-links.field, +.wizard-links.action { + margin-top: 40px; } +.wizard-links.field { + margin-top: 20px; +} + +// end workdarounds // + .wizard-settings > .advanced-settings > div.setting { margin-bottom: 0; } diff --git a/assets/stylesheets/common/wizard-mapper.scss b/assets/stylesheets/common/wizard-mapper.scss index 29fded74..fe400895 100644 --- a/assets/stylesheets/common/wizard-mapper.scss +++ b/assets/stylesheets/common/wizard-mapper.scss @@ -95,6 +95,8 @@ .type-selector a { color: $primary; margin-right: 4px; + display: flex; + align-items: center; &.active { color: $tertiary; @@ -104,6 +106,22 @@ &:last-of-type { margin-right: 0; } + + .type-selector-icon { + margin-left: 2px; + font-size: 0.7em; + } + } + + .selector-types { + box-shadow: shadow('dropdown'); + position: absolute; + background: $secondary; + z-index: 200; + padding: 5px 7px; + display: flex; + flex-direction: column; + border: 1px solid $primary-low; } .value-list .remove-value-btn { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 8cf0a3da..8905ca62 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -73,8 +73,8 @@ en: selector: label: text: "text" - wizard_field: "wizard ○" - user_field: "user ○" + wizard_field: "wizard field" + user_field: "user field" user: "user" category: "category" tag: "tag" @@ -141,6 +141,7 @@ en: less: '<' greater_or_equal: '>=' less_or_equal: '<=' + association: '→' action: header: "Actions" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index fe3554a3..f7c7a2ab 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -25,4 +25,6 @@ en: site_settings: custom_wizard_enabled: "Enable custom wizards." wizard_redirect_exclude_paths: "Routes excluded from wizard redirects." - wizard_recognised_image_upload_formats: "File types which will result in upload displaying an image preview" \ No newline at end of file + wizard_recognised_image_upload_formats: "File types which will result in upload displaying an image preview" + wizard_step_advanced: "Enable advanced settings for wizard steps (experimental)." + wizard_api_features: "Enable API features (experimental)." \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index 6c6b740c..a8764415 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -14,4 +14,10 @@ plugins: default: "jpg|jpeg|png|gif" refresh: true type: list - list_type: compact \ No newline at end of file + list_type: compact + wizard_step_advanced: + client: true + default: false + wizard_api_features: + client: true + default: false \ No newline at end of file