wizard-custom-field.js.es6 670 B

12345678910111213141516171819202122232425262728
  1. import { default as computed, on, observes } from 'ember-addons/ember-computed-decorators';
  2. export default Ember.Component.extend({
  3. classNames: 'wizard-custom-field',
  4. isDropdown: Ember.computed.equal('field.type', 'dropdown'),
  5. @on('init')
  6. @observes('field.id')
  7. init() {
  8. this._super(...arguments);
  9. if (!this.get('field.choices')) {
  10. this.set('field.choices', Ember.A());
  11. }
  12. },
  13. @computed('field.choices.[]')
  14. dropdownChoices: choices => choices,
  15. actions: {
  16. addChoice() {
  17. this.get('field.choices').pushObject(Ember.Object.create());
  18. },
  19. removeChoice(c) {
  20. this.get('field.choices').removeObject(c);
  21. }
  22. }
  23. });