diff --git a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 index 35fbd334..1617cb64 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 @@ -16,6 +16,13 @@ export default Component.extend({ canAddPair: not('isAssignment'), connectors: computed(function() { return connectorContent('output', this.input.type, this.options) }), inputTypes: computed(function() { return inputTypesContent(this.options) }), + + @observes('input.type') + setupPairs() { + if (this.hasPairs && (!this.input.pairs || this.input.pairs.length < 1)) { + this.send('addPair'); + } + }, actions: { addPair() { diff --git a/assets/javascripts/discourse/templates/components/wizard-mapper-pair.hbs b/assets/javascripts/discourse/templates/components/wizard-mapper-pair.hbs index 4fda761f..df3a0ab1 100644 --- a/assets/javascripts/discourse/templates/components/wizard-mapper-pair.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-mapper-pair.hbs @@ -25,5 +25,5 @@ {{/if}} {{#if showRemove}} - {{d-icon 'minus'}} + {{d-icon 'times'}} {{/if}} \ No newline at end of file diff --git a/assets/javascripts/wizard/initializers/custom.js.es6 b/assets/javascripts/wizard/initializers/custom.js.es6 index 48c50204..7b0ccf63 100644 --- a/assets/javascripts/wizard/initializers/custom.js.es6 +++ b/assets/javascripts/wizard/initializers/custom.js.es6 @@ -20,7 +20,6 @@ export default { const autocomplete = requirejs('discourse/lib/autocomplete').default; const cook = requirejs('discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite').cook; const Singleton = requirejs("discourse/mixins/singleton").default; - const WizardFieldDropdown = requirejs('wizard/components/wizard-field-dropdown').default; const Store = requirejs("discourse/models/store").default; const registerRawHelpers = requirejs("discourse-common/lib/raw-handlebars-helpers").registerRawHelpers; const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars").default; @@ -277,11 +276,5 @@ export default { return valid; } }); - - WizardFieldDropdown.reopen({ - didInsertElement() { - console.log(this.field) - } - }) } }; diff --git a/assets/stylesheets/common/wizard-mapper.scss b/assets/stylesheets/common/wizard-mapper.scss index 15dfafd1..9a52b40d 100644 --- a/assets/stylesheets/common/wizard-mapper.scss +++ b/assets/stylesheets/common/wizard-mapper.scss @@ -20,7 +20,7 @@ > .mapper-connector.single { width: min-content; - margin-bottom: 5px; + margin-bottom: 10px; height: 20px; border: 2px solid $primary-low; } @@ -64,6 +64,10 @@ font-size: 0.8em; border: 2px solid $primary-low; } + + &.association, &.validation { + padding-right: 27px; + } } .add-mapper-input { @@ -156,6 +160,12 @@ align-items: center; position: relative; + .add-pair, + .remove-pair, + .join-pair { + font-size: 0.9em; + } + .add-pair { margin-top: 5px; } @@ -163,7 +173,7 @@ .remove-pair { position: absolute; top: 5px; - right: -25px; + right: -20px; } .join-pair { diff --git a/lib/custom_wizard/builder.rb b/lib/custom_wizard/builder.rb index 25d29d83..01d77fd1 100644 --- a/lib/custom_wizard/builder.rb +++ b/lib/custom_wizard/builder.rb @@ -265,10 +265,7 @@ class CustomWizard::Builder CustomWizard::Mapper.new( inputs: prefill, user: @wizard.user, - data: @submissions.last, - opts: { - debug: true - } + data: @submissions.last ).perform end end diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index ef341ffa..862ade8b 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -63,7 +63,7 @@ class CustomWizard::Mapper end end end - + perform_result end @@ -138,7 +138,7 @@ class CustomWizard::Mapper end end - def map_wizard(value) + def map_wizard_field(value) data && !data.key?("submitted_at") && data[value] end