custom.js.es6 770 B

123456789101112131415161718192021222324252627
  1. import { default as computed } from 'ember-addons/ember-computed-decorators';
  2. import WizardField from 'wizard/models/wizard-field';
  3. import { ajax } from 'wizard/lib/ajax';
  4. import Step from 'wizard/models/step';
  5. const CustomWizard = Ember.Object.extend({
  6. @computed('steps.length')
  7. totalSteps: length => length
  8. });
  9. export function findCustomWizard(wizardId) {
  10. return ajax({ url: `/w/${wizardId}` }).then(result => {
  11. const wizard = result.wizard;
  12. if (!wizard.completed) {
  13. wizard.steps = wizard.steps.map(step => {
  14. const stepObj = Step.create(step);
  15. stepObj.fields = stepObj.fields.map(f => WizardField.create(f));
  16. return stepObj;
  17. });
  18. }
  19. return CustomWizard.create(wizard);
  20. });
  21. };
  22. export default CustomWizard;