custom.js.es6 736 B

123456789101112131415161718192021222324
  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: `/wizard/custom/${wizardId}` }).then(result => {
  11. const wizard = result.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. };
  20. export default CustomWizard;