wizard-custom-action.js.es6 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { default as computed } from 'ember-addons/ember-computed-decorators';
  2. const ACTION_TYPES = [
  3. { id: 'create_topic', name: 'Create Topic' },
  4. { id: 'update_profile', name: 'Update Profile' },
  5. { id: 'send_message', name: 'Send Message' }
  6. ];
  7. const PROFILE_FIELDS = [
  8. 'name',
  9. 'email',
  10. 'username',
  11. 'title',
  12. 'date_of_birth',
  13. 'muted_usernames',
  14. 'theme_key',
  15. 'locale',
  16. 'bio_raw',
  17. 'location',
  18. 'website',
  19. 'profile_background',
  20. 'card_background'
  21. ];
  22. export default Ember.Component.extend({
  23. classNames: 'wizard-custom-action',
  24. types: ACTION_TYPES,
  25. profileFields: PROFILE_FIELDS,
  26. createTopic: Ember.computed.equal('action.type', 'create_topic'),
  27. updateProfile: Ember.computed.equal('action.type', 'update_profile'),
  28. sendMessage: Ember.computed.equal('action.type', 'send_message'),
  29. disableId: Ember.computed.not('action.isNew'),
  30. @computed('currentStepId', 'wizard.save_submissions')
  31. availableFields(currentStepId, saveSubmissions) {
  32. const allSteps = this.get('wizard.steps');
  33. let steps = allSteps;
  34. let fields = [];
  35. if (!saveSubmissions) {
  36. steps = [allSteps.findBy('id', currentStepId)];
  37. }
  38. steps.forEach((s) => {
  39. if (s.fields && s.fields.length > 0) {
  40. let stepFields = s.fields.map((f) => {
  41. return Ember.Object.create({
  42. id: f.id,
  43. label: `${f.id} (${s.id})`
  44. });
  45. });
  46. fields.push(...stepFields);
  47. }
  48. });
  49. return fields;
  50. }
  51. });