@quadrel-enterprise-ui/framework 20.10.0-beta.139.1 → 20.10.0-beta.140.1

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.
@@ -27090,13 +27090,25 @@ class QdPageCommitActionExecutor {
27090
27090
  if (ok)
27091
27091
  applySuccess();
27092
27092
  },
27093
- error: err => console.error('QD-UI | QdPage - Commit action observable errored — form was not marked as saved. Catch errors via catchError() in your handler.', err)
27093
+ error: err => this.handleError(action, err)
27094
27094
  });
27095
27095
  }
27096
27096
  else {
27097
27097
  applySuccess();
27098
27098
  }
27099
27099
  }
27100
+ static handleError(action, err) {
27101
+ if (!action.onError) {
27102
+ console.error('QD-UI | QdPage - Commit action observable errored — form was not marked as saved. Provide an `onError` hook on the action, or handle errors in the handler.', err);
27103
+ return;
27104
+ }
27105
+ try {
27106
+ action.onError(err);
27107
+ }
27108
+ catch (callbackErr) {
27109
+ console.error('QD-UI | QdPage - onError callback threw.', callbackErr);
27110
+ }
27111
+ }
27100
27112
  }
27101
27113
 
27102
27114
  /**
@@ -28874,6 +28886,22 @@ const SAFE_BOTTOM_OFFSET_PX = 64;
28874
28886
  *
28875
28887
  * Please check the relevant interfaces for each page type: `QdPageConfigOverview`, `QdPageConfigCreate`, `QdPageConfigInspect`, and `QdPageConfigCustom`.
28876
28888
  *
28889
+ * #### **Commit Actions**
28890
+ *
28891
+ * Commit actions (`submit`, `save`, `saveDraft`) can either run synchronously (handler returns `void`) or wait on an async result (handler returns `Observable<boolean>`). The framework waits for the first emission, advances the saved-state baseline on `true`, and exposes race-free hooks for side effects so navigation after a successful commit does not trigger the unsaved-changes dialog.
28892
+ *
28893
+ * `onSuccess` runs when the handler emits `true` (after the baseline has advanced), `onError` runs when the handler observable errors — e.g. a failed HTTP request that is not caught inside the pipeline.
28894
+ *
28895
+ * ```ts
28896
+ * submit: {
28897
+ * handler: (formValues) => this.api.create(formValues).pipe(map(() => true)),
28898
+ * onSuccess: () => this.router.navigateByUrl('/'),
28899
+ * onError: (err) => this.notifications.add('', { type: 'critical', i18n: 'i18n.myApp.create.failed' })
28900
+ * }
28901
+ * ```
28902
+ *
28903
+ * The same mechanism applies to `save` and `saveDraft`. For the full contract (success vs. planned `false` vs. error, anti-patterns, `discardUnsavedChanges()`), see `QdPageCommitAction` and its action-specific extensions `QdPageSaveAction`, `QdPageSaveDraftAction`, `QdPageCreateSubmitAction`, and `QdPageInspectSubmitAction`.
28904
+ *
28877
28905
  * #### **Validation/Parameterization**
28878
28906
  *
28879
28907
  * Validation and parameterization are covered in a dedicated chapter in the Storybook. Please check the "Validation" section for more information.
@@ -29328,6 +29356,34 @@ class QdPageComponent {
29328
29356
  this._destroyed$.next();
29329
29357
  this._destroyed$.complete();
29330
29358
  }
29359
+ /**
29360
+ * @description Resets all registered form groups to their last saved snapshot, marking the page
29361
+ * as no longer dirty.
29362
+ *
29363
+ * Intended for explicit consumer-driven discard scenarios where you want subsequent navigation
29364
+ * to bypass the unsaved-changes dialog — for example inside a commit action's `onError` hook
29365
+ * after an auth-expiry response, where the user must be redirected to the login page regardless
29366
+ * of unsaved edits.
29367
+ *
29368
+ * Prefer this over wiring custom bypass logic; it keeps the discard explicit and auditable in
29369
+ * application code.
29370
+ *
29371
+ * @example
29372
+ * ```ts
29373
+ * save: {
29374
+ * handler: (values) => api.save(values).pipe(map(() => true)),
29375
+ * onError: (err) => {
29376
+ * if (err.status === 401) {
29377
+ * this.pageComponent.discardUnsavedChanges();
29378
+ * this.router.navigateByUrl('/login');
29379
+ * }
29380
+ * }
29381
+ * }
29382
+ * ```
29383
+ */
29384
+ discardUnsavedChanges() {
29385
+ this.formGroupManagerService.restoreFormGroupsFromSnapshot();
29386
+ }
29331
29387
  checkConfigValidity() {
29332
29388
  if (!this.config)
29333
29389
  console.warn('QdUi | QdPageComponent - To configure the page you should provide a valid config.');