1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2020-04-07 20:28:39 +10:00
Ursprung 539f61c610
Commit a20c74a943
3 geänderte Dateien mit 22 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -1,8 +1,9 @@
import { computed, set } from "@ember/object"; import { computed, set } from "@ember/object";
import { alias, equal, or, not } from "@ember/object/computed"; 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 Component from "@ember/component";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
import { A } from "@ember/array";
export default Component.extend({ export default Component.extend({
classNameBindings: [':mapper-input', 'inputType'], classNameBindings: [':mapper-input', 'inputType'],
@ -18,14 +19,24 @@ export default Component.extend({
inputTypes: computed(function() { return inputTypesContent(this.options) }), inputTypes: computed(function() { return inputTypesContent(this.options) }),
@observes('input.type') @observes('input.type')
setupPairs() { setupType() {
if (this.hasPairs && (!this.input.pairs || this.input.pairs.length < 1)) { if (this.hasPairs && (!this.input.pairs || this.input.pairs.length < 1)) {
this.send('addPair'); 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: { actions: {
addPair() { addPair() {
if (!this.input.pairs) {
this.set('input.pairs', A());
}
const pairs = this.input.pairs; const pairs = this.input.pairs;
const pairCount = pairs.length + 1; const pairCount = pairs.length + 1;
@ -37,10 +48,7 @@ export default Component.extend({
Object.assign( Object.assign(
{}, {},
this.options, this.options,
{ { index: pairs.length, pairCount }
index: pairs.length,
pairCount,
}
) )
) )
); );

Datei anzeigen

@ -153,6 +153,7 @@ function newInput(options = {}, count) {
export { export {
defaultInputType, defaultInputType,
defaultSelectionType, defaultSelectionType,
defaultConnector,
connectorContent, connectorContent,
inputTypesContent, inputTypesContent,
selectionTypes, selectionTypes,

Datei anzeigen

@ -55,9 +55,12 @@
a.remove-input { a.remove-input {
position: absolute; position: absolute;
right: -14px; right: -13px;
top: 0px; top: 0px;
padding: 2px 4px; padding: 4px;
display: flex;
align-items: center;
justify-content: center;
transform: translateY(-50%); transform: translateY(-50%);
background: $secondary; background: $secondary;
border-radius: 50%; border-radius: 50%;