1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-mapper.js.es6
Angus McLeod 0d94c1d8c6 various
2020-04-02 19:21:03 +11:00

44 Zeilen
1,6 KiB
JavaScript

import { getOwner } from 'discourse-common/lib/get-owner';
import { on } from 'discourse-common/utils/decorators';
import { newInput } from '../lib/wizard-mapper';
import { default as discourseComputed } from 'discourse-common/utils/decorators';
export default Ember.Component.extend({
classNames: 'wizard-mapper',
@discourseComputed('inputs.[]', 'options.singular')
canAdd(inputs, singular) {
return !singular || !inputs || inputs.length < 1;
},
@discourseComputed('options')
inputOptions(options) {
return {
hasOutput: options.hasOutput || false,
inputTypes: options.inputTypes || null,
pairConnector: options.pairConnector || null,
outputConnector: options.outputConnector || null,
textSelection: options.textSelection || true,
wizardSelection: options.wizardSelection || false,
userFieldSelection: options.userFieldSelection || false,
categorySelection: options.categorySelection || false,
tagSelection: options.tagSelection || false,
groupSelection: options.groupSelection || false,
userSelection: options.userSelection || false,
keyDefaultSelection: options.keyDefaultSelection || null,
valueDefaultSelection: options.valueDefaultSelection || null,
outputDefaultSelection: options.outputDefaultSelection || null
}
},
actions: {
add() {
if (!this.get('inputs')) this.set('inputs', Ember.A());
this.get('inputs').pushObject(newInput(this.inputOptions));
},
remove(input) {
this.get('inputs').removeObject(input);
}
}
});