wizard-custom-field.js.es6 674 B

123456789101112131415161718192021222324252627
  1. import { observes } from 'ember-addons/ember-computed-decorators';
  2. export default Ember.Component.extend({
  3. classNames: 'wizard-custom-field',
  4. fieldTypes: ['dropdown', 'image', 'radio', 'text', 'textarea'],
  5. isDropdown: Ember.computed.equal('field.type', 'dropdown'),
  6. init() {
  7. this._super(...arguments);
  8. if (!this.get('field.choices')) {
  9. this.set('field.choices', Ember.A());
  10. }
  11. },
  12. @observes('field.label')
  13. setFieldId() {
  14. const label = this.get('field.label');
  15. this.set('field.id', Ember.String.underscore(label));
  16. },
  17. actions: {
  18. addChoice() {
  19. this.get('field.choices').pushObject(Ember.Object.create());
  20. }
  21. }
  22. });