custom-wizard.js.es6 691 B

12345678910111213141516171819202122
  1. import Step from 'wizard/models/step';
  2. import WizardField from 'wizard/models/wizard-field';
  3. import { ajax } from 'wizard/lib/ajax';
  4. import computed from 'ember-addons/ember-computed-decorators';
  5. const CustomWizard = Ember.Object.extend({
  6. @computed('steps.length')
  7. totalSteps: length => length
  8. });
  9. export function findCustomWizard(name) {
  10. return ajax({ url: `/wizard/custom/${name}.json` }).then(response => {
  11. const wizard = response.wizard;
  12. wizard.steps = wizard.steps.map(step => {
  13. const stepObj = Step.create(step);
  14. stepObj.fields = stepObj.fields.map(f => WizardField.create(f));
  15. return stepObj;
  16. });
  17. return CustomWizard.create(wizard);
  18. });
  19. }