wizard-custom-action.js.es6 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
  2. const PROFILE_FIELDS = [
  3. 'name',
  4. 'email',
  5. 'username',
  6. 'title',
  7. 'date_of_birth',
  8. 'muted_usernames',
  9. 'theme_key',
  10. 'locale',
  11. 'bio_raw',
  12. 'location',
  13. 'website',
  14. 'dismissed_banner_key',
  15. 'profile_background',
  16. 'card_background'
  17. ];
  18. export default Ember.Component.extend({
  19. classNames: 'wizard-custom-action',
  20. types: ['create_topic', 'update_profile', 'send_message'],
  21. profileFields: PROFILE_FIELDS,
  22. createTopic: Ember.computed.equal('action.type', 'create_topic'),
  23. updateProfile: Ember.computed.equal('action.type', 'update_profile'),
  24. sendMessage: Ember.computed.equal('action.type', 'send_message'),
  25. @on('init')
  26. @observes('action')
  27. setup() {
  28. if (!this.get('isNew')) this.set('existingId', this.get('action.id'));
  29. },
  30. @computed('steps')
  31. wizardFields(steps) {
  32. let fields = [];
  33. steps.forEach((s) => {
  34. let stepFields = s.fields.map((f) => `${f.id} (${s.id})`);
  35. fields.push(...stepFields);
  36. });
  37. return fields;
  38. },
  39. @computed('action.profile_updates.[]')
  40. profileUpdates: fields => fields,
  41. actions: {
  42. addProfileUpdate() {
  43. if (!this.get('action.profile_updates')) {
  44. this.set('action.profile_updates', Ember.A());
  45. }
  46. this.get('action.profile_updates').pushObject(Ember.Object.create());
  47. },
  48. removeProfileUpdate(f) {
  49. this.get('action.profile_updates').removeObject(f);
  50. }
  51. }
  52. });