wizard.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import _ from 'lodash';
  4. import $ from 'jquery';
  5. import coreModule from 'app/core/core_module';
  6. import appEvents from 'app/core/app_events';
  7. export class WizardSrv {
  8. /** @ngInject */
  9. constructor() {
  10. }
  11. }
  12. export interface WizardStep {
  13. name: string;
  14. type: string;
  15. process: any;
  16. }
  17. export class SelectOptionStep {
  18. type: string;
  19. name: string;
  20. fulfill: any;
  21. constructor() {
  22. this.type = 'select';
  23. }
  24. process() {
  25. return new Promise((fulfill, reject) => {
  26. });
  27. }
  28. }
  29. export class WizardFlow {
  30. name: string;
  31. steps: WizardStep[];
  32. constructor(name) {
  33. this.name = name;
  34. this.steps = [];
  35. }
  36. addStep(step) {
  37. this.steps.push(step);
  38. }
  39. next(index) {
  40. var step = this.steps[0];
  41. return step.process().then(() => {
  42. if (this.steps.length === index+1) {
  43. return;
  44. }
  45. return this.next(index+1);
  46. });
  47. }
  48. start() {
  49. appEvents.emit('show-modal', {
  50. src: 'public/app/core/components/wizard/wizard.html',
  51. model: this
  52. });
  53. return this.next(0);
  54. }
  55. }
  56. coreModule.service('wizardSrv', WizardSrv);