@sprucelabs/spruce-form-utils 15.0.2 → 15.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,12 +7,13 @@ export default class FormPlayerCardViewController extends AbstractViewController
7
7
  private builderSource;
8
8
  private shouldIgnoreChanges;
9
9
  private router?;
10
+ private onSaveAndBeDoneHandler?;
10
11
  constructor(options: FormPlayerCardViewControllerOptions & ViewControllerOptions);
11
12
  private SwipeVc;
12
13
  private handleSlideChange;
13
14
  private renderFooter;
14
15
  private handleClickSaveProgress;
15
- private handleClickSaveAndDone;
16
+ protected handleClickSaveAndDone(): Promise<void>;
16
17
  private handleClickNext;
17
18
  private renderHeader;
18
19
  setIsBusy(isLoading: boolean): void;
@@ -41,6 +42,7 @@ export type FormPlayerCardViewControllerOptions = Partial<FormPlayerImportObject
41
42
  onChange?: ChangeHandler;
42
43
  isBusy?: boolean;
43
44
  id?: string;
45
+ onSaveAndBeDone?: () => Promise<void> | void;
44
46
  };
45
47
  export type PlayerLoadOptions = Partial<FormPlayerImportObject> & {
46
48
  router?: Router;
@@ -17,8 +17,9 @@ class FormPlayerCardViewController extends heartwood_view_controllers_1.Abstract
17
17
  constructor(options) {
18
18
  super(options);
19
19
  this.shouldIgnoreChanges = false;
20
- const { onChange, isBusy, id } = options, builderSource = __rest(options, ["onChange", "isBusy", "id"]);
20
+ const { onChange, isBusy, id, onSaveAndBeDone } = options, builderSource = __rest(options, ["onChange", "isBusy", "id", "onSaveAndBeDone"]);
21
21
  this.builderSource = (0, heartwood_view_controllers_1.removeUniversalViewOptions)(builderSource);
22
+ this.onSaveAndBeDoneHandler = onSaveAndBeDone;
22
23
  this.swipeVc = this.SwipeVc(id, builderSource);
23
24
  if (!options.pages || isBusy) {
24
25
  this.swipeVc.setIsBusy(true);
@@ -78,12 +79,16 @@ class FormPlayerCardViewController extends heartwood_view_controllers_1.Abstract
78
79
  });
79
80
  }
80
81
  async handleClickSaveAndDone() {
81
- var _a;
82
+ var _a, _b;
82
83
  await this.alert({
83
84
  message: `Progress saved, lets get outa here! 🚀`,
84
85
  style: 'success',
85
86
  });
86
- await ((_a = this.router) === null || _a === void 0 ? void 0 : _a.redirect('profile.root'));
87
+ if (this.onSaveAndBeDoneHandler) {
88
+ await ((_a = this.onSaveAndBeDoneHandler) === null || _a === void 0 ? void 0 : _a.call(this));
89
+ return;
90
+ }
91
+ await ((_b = this.router) === null || _b === void 0 ? void 0 : _b.redirect('profile.root'));
87
92
  }
88
93
  async handleClickNext() {
89
94
  await this.swipeVc.jumpToSlide(this.swipeVc.getPresentSlide() + 1);
@@ -7,12 +7,13 @@ export default class FormPlayerCardViewController extends AbstractViewController
7
7
  private builderSource;
8
8
  private shouldIgnoreChanges;
9
9
  private router?;
10
+ private onSaveAndBeDoneHandler?;
10
11
  constructor(options: FormPlayerCardViewControllerOptions & ViewControllerOptions);
11
12
  private SwipeVc;
12
13
  private handleSlideChange;
13
14
  private renderFooter;
14
15
  private handleClickSaveProgress;
15
- private handleClickSaveAndDone;
16
+ protected handleClickSaveAndDone(): Promise<void>;
16
17
  private handleClickNext;
17
18
  private renderHeader;
18
19
  setIsBusy(isLoading: boolean): void;
@@ -41,6 +42,7 @@ export type FormPlayerCardViewControllerOptions = Partial<FormPlayerImportObject
41
42
  onChange?: ChangeHandler;
42
43
  isBusy?: boolean;
43
44
  id?: string;
45
+ onSaveAndBeDone?: () => Promise<void> | void;
44
46
  };
45
47
  export type PlayerLoadOptions = Partial<FormPlayerImportObject> & {
46
48
  router?: Router;
@@ -24,8 +24,9 @@ class FormPlayerCardViewController extends AbstractViewController {
24
24
  constructor(options) {
25
25
  super(options);
26
26
  this.shouldIgnoreChanges = false;
27
- const { onChange, isBusy, id } = options, builderSource = __rest(options, ["onChange", "isBusy", "id"]);
27
+ const { onChange, isBusy, id, onSaveAndBeDone } = options, builderSource = __rest(options, ["onChange", "isBusy", "id", "onSaveAndBeDone"]);
28
28
  this.builderSource = removeUniversalViewOptions(builderSource);
29
+ this.onSaveAndBeDoneHandler = onSaveAndBeDone;
29
30
  this.swipeVc = this.SwipeVc(id, builderSource);
30
31
  if (!options.pages || isBusy) {
31
32
  this.swipeVc.setIsBusy(true);
@@ -87,13 +88,17 @@ class FormPlayerCardViewController extends AbstractViewController {
87
88
  });
88
89
  }
89
90
  handleClickSaveAndDone() {
90
- var _a;
91
+ var _a, _b;
91
92
  return __awaiter(this, void 0, void 0, function* () {
92
93
  yield this.alert({
93
94
  message: `Progress saved, lets get outa here! 🚀`,
94
95
  style: 'success',
95
96
  });
96
- yield ((_a = this.router) === null || _a === void 0 ? void 0 : _a.redirect('profile.root'));
97
+ if (this.onSaveAndBeDoneHandler) {
98
+ yield ((_a = this.onSaveAndBeDoneHandler) === null || _a === void 0 ? void 0 : _a.call(this));
99
+ return;
100
+ }
101
+ yield ((_b = this.router) === null || _b === void 0 ? void 0 : _b.redirect('profile.root'));
97
102
  });
98
103
  }
99
104
  handleClickNext() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-form-utils",
3
3
  "description": "Support for working with forms and Sprucebot. 📄",
4
- "version": "15.0.2",
4
+ "version": "15.2.0",
5
5
  "skill": {
6
6
  "namespace": "forms"
7
7
  },