1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-custom-field.js.es6
Angus McLeod 9f40821db0 Various
2017-10-06 10:59:02 +08:00

29 Zeilen
671 B
JavaScript

import { default as computed, on, observes } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
classNames: 'wizard-custom-field',
isDropdown: Ember.computed.equal('field.type', 'dropdown'),
@on('init')
@observes('field.id')
init() {
this._super(...arguments);
if (!this.get('field.choices')) {
this.set('field.choices', Ember.A());
}
},
@computed('field.choices.[]')
dropdownChoices: choices => choices,
actions: {
addChoice() {
this.get('field.choices').pushObject(Ember.Object.create());
},
removeChoice(c) {
this.get('field.choices').removeObject(c);
}
}
});