1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-field-mapper.js.es6

25 Zeilen
711 B
Text

2020-03-21 18:30:11 +01:00
import { getOwner } from 'discourse-common/lib/get-owner';
import { on } from 'discourse-common/utils/decorators';
import { newInput } from '../lib/custom-wizard';
2020-03-30 08:16:03 +02:00
import { default as discourseComputed } from 'discourse-common/utils/decorators';
2020-03-21 18:30:11 +01:00
2018-05-24 07:34:58 +02:00
export default Ember.Component.extend({
2020-03-24 10:35:46 +01:00
classNames: 'field-mapper',
2020-03-30 08:16:03 +02:00
@discourseComputed('inputs.[]', 'options.singular')
canAdd(inputs, singular) {
return !singular || !inputs || inputs.length < 1;
},
2019-04-18 01:47:41 +02:00
2018-05-24 07:34:58 +02:00
actions: {
add() {
2020-03-21 18:30:11 +01:00
if (!this.get('inputs')) this.set('inputs', Ember.A());
this.get('inputs').pushObject(newInput(this.options));
2018-05-24 07:34:58 +02:00
},
remove(input) {
this.get('inputs').removeObject(input);
}
}
});