diff --git a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 index 1617cb64..f97bf44c 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-input.js.es6 @@ -1,8 +1,9 @@ import { computed, set } from "@ember/object"; import { alias, equal, or, not } from "@ember/object/computed"; -import { newPair, connectorContent, inputTypesContent } from '../lib/wizard-mapper'; +import { newPair, connectorContent, inputTypesContent, defaultSelectionType, defaultConnector } from '../lib/wizard-mapper'; import Component from "@ember/component"; import { observes } from "discourse-common/utils/decorators"; +import { A } from "@ember/array"; export default Component.extend({ classNameBindings: [':mapper-input', 'inputType'], @@ -18,29 +19,36 @@ export default Component.extend({ inputTypes: computed(function() { return inputTypesContent(this.options) }), @observes('input.type') - setupPairs() { + setupType() { if (this.hasPairs && (!this.input.pairs || this.input.pairs.length < 1)) { this.send('addPair'); } + + if (this.hasOutput && !this.input.outputConnector) { + const options = this.options; + this.set('input.output_type', defaultSelectionType('output', options)); + this.set('input.output_connector', defaultConnector('output', this.inputType, options)); + } }, actions: { addPair() { + if (!this.input.pairs) { + this.set('input.pairs', A()); + } + const pairs = this.input.pairs; const pairCount = pairs.length + 1; - + pairs.forEach(p => (set(p, 'pairCount', pairCount))); pairs.pushObject( newPair( - this.input.type, + this.input.type, Object.assign( {}, this.options, - { - index: pairs.length, - pairCount, - } + { index: pairs.length, pairCount } ) ) ); diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index ebb280e3..3d3ad034 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -153,6 +153,7 @@ function newInput(options = {}, count) { export { defaultInputType, defaultSelectionType, + defaultConnector, connectorContent, inputTypesContent, selectionTypes, diff --git a/assets/stylesheets/common/wizard-mapper.scss b/assets/stylesheets/common/wizard-mapper.scss index 9a52b40d..9e90652a 100644 --- a/assets/stylesheets/common/wizard-mapper.scss +++ b/assets/stylesheets/common/wizard-mapper.scss @@ -55,9 +55,12 @@ a.remove-input { position: absolute; - right: -14px; + right: -13px; top: 0px; - padding: 2px 4px; + padding: 4px; + display: flex; + align-items: center; + justify-content: center; transform: translateY(-50%); background: $secondary; border-radius: 50%;