0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-20 07:41:11 +02:00
discourse-custom-wizard/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);
}
}
});