@quadrel-enterprise-ui/framework 20.10.0 → 20.10.1-beta.145.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.
package/index.d.ts
CHANGED
|
@@ -9051,6 +9051,31 @@ interface QdPageConfigInspect<T extends object = object> extends QdPageConfigBas
|
|
|
9051
9051
|
* @description Information placed in the header of the page. Concerns current shown object.
|
|
9052
9052
|
*/
|
|
9053
9053
|
headerFacets?: QdPageHeaderFacetConfig<T>[];
|
|
9054
|
+
/**
|
|
9055
|
+
* @description Observable to push partial metadata updates for header facets from outside.
|
|
9056
|
+
* Each emission is shallow-merged into the current object data, so only the fields that
|
|
9057
|
+
* changed need to be emitted. Stream-pushed fields survive subsequent resolver re-runs.
|
|
9058
|
+
*
|
|
9059
|
+
* Prefer a `ReplaySubject<Partial<T>>(1)` or `BehaviorSubject` over a plain `Subject`:
|
|
9060
|
+
* the header subscribes during its own `ngOnInit`, so emissions fired earlier (e.g. from
|
|
9061
|
+
* the page component's `ngOnInit`) would be lost without a replay buffer.
|
|
9062
|
+
*
|
|
9063
|
+
* @example
|
|
9064
|
+
* ```ts
|
|
9065
|
+
* private metadataUpdates$ = new ReplaySubject<Partial<MyObject>>(1);
|
|
9066
|
+
*
|
|
9067
|
+
* pageConfig: QdPageConfig<MyObject> = {
|
|
9068
|
+
* // ...
|
|
9069
|
+
* headerFacets: [...],
|
|
9070
|
+
* metadata$: this.metadataUpdates$
|
|
9071
|
+
* };
|
|
9072
|
+
*
|
|
9073
|
+
* onStatusChange() {
|
|
9074
|
+
* this.metadataUpdates$.next({ status: 'approved' });
|
|
9075
|
+
* }
|
|
9076
|
+
* ```
|
|
9077
|
+
*/
|
|
9078
|
+
metadata$?: Observable<Partial<T>>;
|
|
9054
9079
|
/**
|
|
9055
9080
|
* @description Determines whether the facets in header should be collapsed and custom actions are in a menu. This mode is designed for touch devices and mobile phones only.
|
|
9056
9081
|
*
|
|
@@ -9073,6 +9098,31 @@ interface QdPageConfigCustom<T extends object = object> extends QdPageConfigBase
|
|
|
9073
9098
|
* @description Information placed in the header of the page. Concerns current shown object.
|
|
9074
9099
|
*/
|
|
9075
9100
|
headerFacets?: QdPageHeaderFacetConfig<T>[];
|
|
9101
|
+
/**
|
|
9102
|
+
* @description Observable to push partial metadata updates for header facets from outside.
|
|
9103
|
+
* Each emission is shallow-merged into the current object data, so only the fields that
|
|
9104
|
+
* changed need to be emitted. Stream-pushed fields survive subsequent resolver re-runs.
|
|
9105
|
+
*
|
|
9106
|
+
* Prefer a `ReplaySubject<Partial<T>>(1)` or `BehaviorSubject` over a plain `Subject`:
|
|
9107
|
+
* the header subscribes during its own `ngOnInit`, so emissions fired earlier (e.g. from
|
|
9108
|
+
* the page component's `ngOnInit`) would be lost without a replay buffer.
|
|
9109
|
+
*
|
|
9110
|
+
* @example
|
|
9111
|
+
* ```ts
|
|
9112
|
+
* private metadataUpdates$ = new ReplaySubject<Partial<MyObject>>(1);
|
|
9113
|
+
*
|
|
9114
|
+
* pageConfig: QdPageConfig<MyObject> = {
|
|
9115
|
+
* // ...
|
|
9116
|
+
* headerFacets: [...],
|
|
9117
|
+
* metadata$: this.metadataUpdates$
|
|
9118
|
+
* };
|
|
9119
|
+
*
|
|
9120
|
+
* onStatusChange() {
|
|
9121
|
+
* this.metadataUpdates$.next({ status: 'approved' });
|
|
9122
|
+
* }
|
|
9123
|
+
* ```
|
|
9124
|
+
*/
|
|
9125
|
+
metadata$?: Observable<Partial<T>>;
|
|
9076
9126
|
/**
|
|
9077
9127
|
* @description Determines whether the facets in header should be collapsed and custom actions are in a menu. This mode is designed for touch devices and mobile phones only.
|
|
9078
9128
|
*
|
|
@@ -9214,11 +9264,17 @@ interface QdPageCustomActionsLabel {
|
|
|
9214
9264
|
*/
|
|
9215
9265
|
type QdInspectOperationMode = 'view' | 'edit';
|
|
9216
9266
|
/**
|
|
9217
|
-
* @description
|
|
9267
|
+
* @description Common shape for all framework-managed commit actions (save, save draft, submit).
|
|
9268
|
+
*
|
|
9269
|
+
* Each commit action is built around a single `handler` whose return value tells the framework how
|
|
9270
|
+
* the action ended (success / planned failure / error), with optional `onSuccess` / `onError` hooks
|
|
9271
|
+
* for consumer-side reactions. Per-action interfaces (`QdPageSaveAction`, `QdPageSaveDraftAction`,
|
|
9272
|
+
* `QdPageCreateSubmitAction`, `QdPageInspectSubmitAction`) extend this base with their action-specific
|
|
9273
|
+
* options.
|
|
9218
9274
|
*/
|
|
9219
|
-
interface
|
|
9275
|
+
interface QdPageCommitAction {
|
|
9220
9276
|
/**
|
|
9221
|
-
* @description Label for the
|
|
9277
|
+
* @description Label for the action, used for translation.
|
|
9222
9278
|
*
|
|
9223
9279
|
* * If no custom translation key is provided, a standard label will be used by default.
|
|
9224
9280
|
*/
|
|
@@ -9226,17 +9282,106 @@ interface QdPageSaveAction {
|
|
|
9226
9282
|
i18n: string;
|
|
9227
9283
|
};
|
|
9228
9284
|
/**
|
|
9229
|
-
* @description Triggered when the
|
|
9285
|
+
* @description Triggered when the action is executed.
|
|
9230
9286
|
*
|
|
9231
9287
|
* Success criteria:
|
|
9232
|
-
* - If the handler returns an Observable<boolean
|
|
9233
|
-
* - **true:** success
|
|
9234
|
-
* - **false:** failure/cancel
|
|
9235
|
-
* - If the handler returns
|
|
9288
|
+
* - If the handler returns an `Observable<boolean>`, only the first emission counts:
|
|
9289
|
+
* - **true:** success — the framework marks the form as saved (the page is no longer dirty).
|
|
9290
|
+
* - **false:** failure/cancel — the form stays dirty.
|
|
9291
|
+
* - If the handler returns `void`, the action is treated as instant success and the form is marked as saved immediately.
|
|
9292
|
+
*
|
|
9293
|
+
* Errors emitted by the Observable trigger the optional `onError` hook, or fall back to `console.error` if
|
|
9294
|
+
* `onError` is not configured. The form stays dirty either way.
|
|
9295
|
+
*
|
|
9296
|
+
* **When to emit `false` vs. let an error fly:**
|
|
9297
|
+
* - `false` = predictable cancel/reject (user aborted, business rule, structured validation response from the backend).
|
|
9298
|
+
* - Error = unexpected (network outage, 5xx, bug).
|
|
9299
|
+
*
|
|
9300
|
+
* Rule of thumb: if the UI can explain the cause to the user, emit `false` (plus a notification). Otherwise let the error propagate.
|
|
9301
|
+
*
|
|
9302
|
+
* ---
|
|
9303
|
+
*
|
|
9304
|
+
* **Anti-pattern: do not navigate from inside an async handler pipeline.**
|
|
9305
|
+
*
|
|
9306
|
+
* The framework runs the synchronous handler invocation inside its navigation-bypass window. For
|
|
9307
|
+
* a sync `void` handler that calls `router.navigate(...)` directly, this is fine — the bypass is
|
|
9308
|
+
* active and the form is marked as saved immediately afterwards.
|
|
9236
9309
|
*
|
|
9237
|
-
*
|
|
9310
|
+
* For an `Observable<boolean>` handler, the bypass window closes as soon as the handler returns
|
|
9311
|
+
* the observable. Side effects wired into `tap` (or any later operator) run **after** the bypass
|
|
9312
|
+
* has already closed AND **before** the framework marks the form as saved on the `true` emission.
|
|
9313
|
+
* Navigating from there raises the unsaved-changes dialog — exactly what the framework is trying
|
|
9314
|
+
* to suppress. Use `onSuccess` for navigation after async commits.
|
|
9238
9315
|
*/
|
|
9239
9316
|
handler: (formValues?: any) => void | Observable<boolean>;
|
|
9317
|
+
/**
|
|
9318
|
+
* @description Optional callback invoked after the framework marks the form as saved on a successful commit.
|
|
9319
|
+
*
|
|
9320
|
+
* * Runs in the framework's navigation-bypass window, so router navigation from this hook does **not**
|
|
9321
|
+
* raise the unsaved-changes dialog.
|
|
9322
|
+
*
|
|
9323
|
+
* * For async handlers (returning `Observable<boolean>`), this hook is the **only** race-free place to
|
|
9324
|
+
* navigate. Side effects in `tap` run *before* the framework marks the form as saved; navigation
|
|
9325
|
+
* from there would still see a dirty form and trigger the dialog.
|
|
9326
|
+
*
|
|
9327
|
+
* @example
|
|
9328
|
+
* ```ts
|
|
9329
|
+
* submit: {
|
|
9330
|
+
* handler: (values) => api.create(values).pipe(map(() => true)),
|
|
9331
|
+
* onSuccess: () => router.navigateByUrl('/')
|
|
9332
|
+
* }
|
|
9333
|
+
* ```
|
|
9334
|
+
*/
|
|
9335
|
+
onSuccess?: () => void;
|
|
9336
|
+
/**
|
|
9337
|
+
* @description Optional callback invoked when the handler observable emits an error.
|
|
9338
|
+
*
|
|
9339
|
+
* * Receives the original error from the observable.
|
|
9340
|
+
*
|
|
9341
|
+
* * **Not** invoked when the handler emits `false` — `false` is a planned outcome, errors are unexpected
|
|
9342
|
+
* (see the `handler` doc for the distinction).
|
|
9343
|
+
*
|
|
9344
|
+
* * **Does not run in the navigation-bypass window.** Navigation from this hook raises the unsaved-changes
|
|
9345
|
+
* dialog, because the form is still dirty after a failed commit — and the user usually wants to keep
|
|
9346
|
+
* their edits. To navigate away unconditionally (e.g. on auth expiry), call
|
|
9347
|
+
* `QdPageComponent.discardUnsavedChanges()` first to reset the form to its last saved state.
|
|
9348
|
+
*
|
|
9349
|
+
* * If `onError` is not configured, the framework falls back to `console.error` so failures never go silent.
|
|
9350
|
+
*
|
|
9351
|
+
* @example
|
|
9352
|
+
* ```ts
|
|
9353
|
+
* submit: {
|
|
9354
|
+
* handler: (values) => api.create(values).pipe(map(() => true)),
|
|
9355
|
+
* onSuccess: () => router.navigateByUrl('/'),
|
|
9356
|
+
* onError: (err) => notifications.error('i18n.create.failed', err)
|
|
9357
|
+
* }
|
|
9358
|
+
* ```
|
|
9359
|
+
*
|
|
9360
|
+
* @example
|
|
9361
|
+
* Navigate away unconditionally from onError (e.g. auth-expiry redirect to login). Call `discardUnsavedChanges()` first to drop the dirty snapshot so the next navigation passes through without the dialog:
|
|
9362
|
+
*
|
|
9363
|
+
* ```ts
|
|
9364
|
+
* @ViewChild(QdPageComponent) pageComponent!: QdPageComponent<MyModel>;
|
|
9365
|
+
*
|
|
9366
|
+
* submit: {
|
|
9367
|
+
* handler: (values) => api.save(values).pipe(map(() => true)),
|
|
9368
|
+
* onError: (err) => {
|
|
9369
|
+
* if (err.status === 401) {
|
|
9370
|
+
* this.pageComponent.discardUnsavedChanges();
|
|
9371
|
+
* this.router.navigateByUrl('/login');
|
|
9372
|
+
* return;
|
|
9373
|
+
* }
|
|
9374
|
+
* this.notifications.error('i18n.save.failed', err);
|
|
9375
|
+
* }
|
|
9376
|
+
* }
|
|
9377
|
+
* ```
|
|
9378
|
+
*/
|
|
9379
|
+
onError?: (err: unknown) => void;
|
|
9380
|
+
}
|
|
9381
|
+
/**
|
|
9382
|
+
* @description Interface for the save action, including optional validation configuration.
|
|
9383
|
+
*/
|
|
9384
|
+
interface QdPageSaveAction extends QdPageCommitAction {
|
|
9240
9385
|
/**
|
|
9241
9386
|
* @description Optional validation flag, defaults to true.
|
|
9242
9387
|
* Determines whether form validation is required before saving and ensures that changes must be present in the form before saving.
|
|
@@ -9250,21 +9395,10 @@ interface QdPageSaveAction {
|
|
|
9250
9395
|
hasValidation?: boolean;
|
|
9251
9396
|
}
|
|
9252
9397
|
/**
|
|
9253
|
-
* @description Interface for the
|
|
9398
|
+
* @description Interface for the save draft action. Inherits the standard commit-action shape
|
|
9399
|
+
* (`label`, `handler`, `onSuccess`, `onError`) without further options.
|
|
9254
9400
|
*/
|
|
9255
|
-
interface QdPageSaveDraftAction {
|
|
9256
|
-
/**
|
|
9257
|
-
* @description Label for the save draft action, used for translation.
|
|
9258
|
-
*
|
|
9259
|
-
* * If no custom translation key is provided, a standard label will be used by default.
|
|
9260
|
-
*/
|
|
9261
|
-
label?: {
|
|
9262
|
-
i18n: string;
|
|
9263
|
-
};
|
|
9264
|
-
/**
|
|
9265
|
-
* @description Handler function that is triggered when the save draft action is executed.
|
|
9266
|
-
*/
|
|
9267
|
-
handler: () => void;
|
|
9401
|
+
interface QdPageSaveDraftAction extends QdPageCommitAction {
|
|
9268
9402
|
}
|
|
9269
9403
|
/**
|
|
9270
9404
|
* @description Interface for the cancel action, including an optional confirmation message.
|
|
@@ -9295,45 +9429,10 @@ interface QdPageCancelAction {
|
|
|
9295
9429
|
};
|
|
9296
9430
|
}
|
|
9297
9431
|
/**
|
|
9298
|
-
* @description Interface for the submit action on create pages.
|
|
9432
|
+
* @description Interface for the submit action on create pages. Inherits the standard commit-action
|
|
9433
|
+
* shape (`label`, `handler`, `onSuccess`, `onError`) without further options.
|
|
9299
9434
|
*/
|
|
9300
|
-
interface QdPageCreateSubmitAction {
|
|
9301
|
-
/**
|
|
9302
|
-
* @description Label for the submit action, used for translation.
|
|
9303
|
-
*
|
|
9304
|
-
* * If no custom translation key is provided, a standard label will be used by default.
|
|
9305
|
-
*/
|
|
9306
|
-
label?: {
|
|
9307
|
-
i18n: string;
|
|
9308
|
-
};
|
|
9309
|
-
/**
|
|
9310
|
-
* @description Handler function that is triggered when the submit action is executed.
|
|
9311
|
-
*/
|
|
9312
|
-
handler: (formValues?: any) => void;
|
|
9313
|
-
}
|
|
9314
|
-
/**
|
|
9315
|
-
* @description Interface for the submit action.
|
|
9316
|
-
*/
|
|
9317
|
-
interface QdPageSubmitAction {
|
|
9318
|
-
/**
|
|
9319
|
-
* @description Label for the submit action, used for translation.
|
|
9320
|
-
*
|
|
9321
|
-
* * If no custom translation key is provided, a standard label will be used by default.
|
|
9322
|
-
*/
|
|
9323
|
-
label?: {
|
|
9324
|
-
i18n: string;
|
|
9325
|
-
};
|
|
9326
|
-
/**
|
|
9327
|
-
* @description Handler function that is triggered when the submit action is executed.
|
|
9328
|
-
*/
|
|
9329
|
-
handler: (formValues?: any) => void;
|
|
9330
|
-
/**
|
|
9331
|
-
* @description By default, the visibility of the submit button depends on the page type and the operation mode.
|
|
9332
|
-
* To completely hide the submit button, you can set this isHidden flag.
|
|
9333
|
-
*
|
|
9334
|
-
* @default false
|
|
9335
|
-
*/
|
|
9336
|
-
isHidden?: boolean;
|
|
9435
|
+
interface QdPageCreateSubmitAction extends QdPageCommitAction {
|
|
9337
9436
|
}
|
|
9338
9437
|
/**
|
|
9339
9438
|
* @description Interface for the edit action.
|
|
@@ -9375,9 +9474,18 @@ interface QdPageArchiveAction {
|
|
|
9375
9474
|
handler: (formValues?: any) => void;
|
|
9376
9475
|
}
|
|
9377
9476
|
/**
|
|
9378
|
-
* @description Inspect-specific submit action configuration.
|
|
9477
|
+
* @description Inspect-specific submit action configuration. Submit on inspect pages is a process
|
|
9478
|
+
* action (status change, approval, workflow transition) and is only visible in **view** mode.
|
|
9379
9479
|
*/
|
|
9380
|
-
interface QdPageInspectSubmitAction extends
|
|
9480
|
+
interface QdPageInspectSubmitAction extends QdPageCommitAction {
|
|
9481
|
+
/**
|
|
9482
|
+
* @description By default, the visibility of the submit button depends on the operation mode
|
|
9483
|
+
* (visible in view mode, hidden in edit mode). Set this flag to hide the button entirely,
|
|
9484
|
+
* regardless of mode.
|
|
9485
|
+
*
|
|
9486
|
+
* @default false
|
|
9487
|
+
*/
|
|
9488
|
+
isHidden?: boolean;
|
|
9381
9489
|
/**
|
|
9382
9490
|
* @description Optional info message shown when submit is disabled on inspect pages for non-validation reasons.
|
|
9383
9491
|
*
|
|
@@ -11716,6 +11824,11 @@ interface QdPageObjectResolver<T extends object> {
|
|
|
11716
11824
|
resolve(): Observable<T>;
|
|
11717
11825
|
/**
|
|
11718
11826
|
* Updates the metadata of the page object model. Can be invoked with an action and accepts a partial metadata object.
|
|
11827
|
+
*
|
|
11828
|
+
* @deprecated Use `QdPageConfig.metadata$` instead. Declare an `Observable<Partial<T>>` (typically a `Subject`)
|
|
11829
|
+
* on the page config and emit partial updates through it — the page header subscribes to it and merges each
|
|
11830
|
+
* emission into the current object data. The `updateMetadata` method is kept for backward compatibility and
|
|
11831
|
+
* will be removed in a future major version.
|
|
11719
11832
|
*/
|
|
11720
11833
|
updateMetadata?(metadata: Partial<T>): void;
|
|
11721
11834
|
}
|
|
@@ -12806,6 +12919,22 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
12806
12919
|
*
|
|
12807
12920
|
* Please check the relevant interfaces for each page type: `QdPageConfigOverview`, `QdPageConfigCreate`, `QdPageConfigInspect`, and `QdPageConfigCustom`.
|
|
12808
12921
|
*
|
|
12922
|
+
* #### **Commit Actions**
|
|
12923
|
+
*
|
|
12924
|
+
* 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.
|
|
12925
|
+
*
|
|
12926
|
+
* `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.
|
|
12927
|
+
*
|
|
12928
|
+
* ```ts
|
|
12929
|
+
* submit: {
|
|
12930
|
+
* handler: (formValues) => this.api.create(formValues).pipe(map(() => true)),
|
|
12931
|
+
* onSuccess: () => this.router.navigateByUrl('/'),
|
|
12932
|
+
* onError: (err) => this.notifications.add('', { type: 'critical', i18n: 'i18n.myApp.create.failed' })
|
|
12933
|
+
* }
|
|
12934
|
+
* ```
|
|
12935
|
+
*
|
|
12936
|
+
* 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`.
|
|
12937
|
+
*
|
|
12809
12938
|
* #### **Validation/Parameterization**
|
|
12810
12939
|
*
|
|
12811
12940
|
* Validation and parameterization are covered in a dedicated chapter in the Storybook. Please check the "Validation" section for more information.
|
|
@@ -12875,7 +13004,15 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
12875
13004
|
* handler: () => handleCancel()
|
|
12876
13005
|
* },
|
|
12877
13006
|
* save: {
|
|
12878
|
-
* handler: (
|
|
13007
|
+
* handler: () => saveApi.save(form.value).pipe(
|
|
13008
|
+
* tap(result => notifications.success('Saved')),
|
|
13009
|
+
* map(() => true),
|
|
13010
|
+
* catchError(err => {
|
|
13011
|
+
* notifications.showError(err);
|
|
13012
|
+
* return of(false);
|
|
13013
|
+
* })
|
|
13014
|
+
* ),
|
|
13015
|
+
* onSuccess: () => router.navigate(['/overview'])
|
|
12879
13016
|
* }
|
|
12880
13017
|
* }
|
|
12881
13018
|
* };
|
|
@@ -12884,19 +13021,42 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
12884
13021
|
*
|
|
12885
13022
|
* #### **Updating Facets**
|
|
12886
13023
|
*
|
|
12887
|
-
* Typically, the values of the facets on a create or inspect page are set to read-only.
|
|
13024
|
+
* Typically, the values of the facets on a create or inspect page are set to read-only. If a facet value needs to change at runtime — for instance after a status update from a dialog — push the partial update through an observable on the page config. The header subscribes to `QdPageConfig.metadata$` and shallow-merges every emission into the current object data.
|
|
12888
13025
|
*
|
|
12889
13026
|
* **Please note: These values should not be modified directly within a QdPage.**
|
|
12890
13027
|
*
|
|
12891
13028
|
* ```ts
|
|
12892
|
-
* @
|
|
12893
|
-
*
|
|
12894
|
-
*
|
|
12895
|
-
*
|
|
13029
|
+
* @Component({
|
|
13030
|
+
* // ...
|
|
13031
|
+
* providers: [
|
|
13032
|
+
* {
|
|
13033
|
+
* provide: QD_PAGE_OBJECT_RESOLVER_TOKEN,
|
|
13034
|
+
* useClass: MyObjectModelResolver
|
|
13035
|
+
* }
|
|
13036
|
+
* ]
|
|
13037
|
+
* })
|
|
13038
|
+
* class MyPageComponent {
|
|
13039
|
+
* private metadataUpdates$ = new Subject<Partial<MyObjectModel>>();
|
|
13040
|
+
*
|
|
13041
|
+
* pageConfig: QdPageConfig<MyObjectModel> = {
|
|
13042
|
+
* title: { i18n: 'i18n.page.title' },
|
|
13043
|
+
* pageType: 'inspect',
|
|
13044
|
+
* headerFacets: [ /* ... *\/ ],
|
|
13045
|
+
* metadata$: this.metadataUpdates$,
|
|
13046
|
+
* pageTypeConfig: { /* ... *\/ }
|
|
13047
|
+
* };
|
|
13048
|
+
*
|
|
13049
|
+
* updateStatus() {
|
|
13050
|
+
* this.metadataUpdates$.next({ state: 'Updated' });
|
|
12896
13051
|
* }
|
|
13052
|
+
* }
|
|
13053
|
+
* ```
|
|
12897
13054
|
*
|
|
12898
|
-
*
|
|
13055
|
+
* Legacy approach (`@deprecated`): the resolver-level `updateMetadata` method is still wired up for backward compatibility, but prefer `metadata$` on the config for new code.
|
|
12899
13056
|
*
|
|
13057
|
+
* ```ts
|
|
13058
|
+
* @Injectable()
|
|
13059
|
+
* class MyObjectModelResolver implements QdPageObjectResolver<MyObjectModel> {
|
|
12900
13060
|
* resolve(): Observable<MyObjectModel> {
|
|
12901
13061
|
* // your implementation here
|
|
12902
13062
|
* }
|
|
@@ -12906,15 +13066,6 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
12906
13066
|
* }
|
|
12907
13067
|
* }
|
|
12908
13068
|
*
|
|
12909
|
-
* @Component({
|
|
12910
|
-
* // ...
|
|
12911
|
-
* providers: [
|
|
12912
|
-
* {
|
|
12913
|
-
* provide: QD_PAGE_OBJECT_RESOLVER_TOKEN,
|
|
12914
|
-
* useClass: MyObjectModelResolver
|
|
12915
|
-
* }
|
|
12916
|
-
* ]
|
|
12917
|
-
* })
|
|
12918
13069
|
* class MyPageComponent {
|
|
12919
13070
|
* constructor(@Inject(QD_PAGE_OBJECT_RESOLVER_TOKEN) private objectResolver: MyObjectModelResolver) {}
|
|
12920
13071
|
*
|
|
@@ -12993,7 +13144,8 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
12993
13144
|
* pageType: 'create',
|
|
12994
13145
|
* pageTypeConfig: {
|
|
12995
13146
|
* submit: {
|
|
12996
|
-
* handler: (formValues) =>
|
|
13147
|
+
* handler: (formValues) => createApi.create(formValues).pipe(map(() => true)),
|
|
13148
|
+
* onSuccess: () => router.navigate(['/items'])
|
|
12997
13149
|
* }
|
|
12998
13150
|
* }
|
|
12999
13151
|
* };
|
|
@@ -13086,7 +13238,14 @@ declare class QdSectionComponent implements OnInit, AfterViewInit, OnChanges, On
|
|
|
13086
13238
|
* handler: () => handleCancel()
|
|
13087
13239
|
* },
|
|
13088
13240
|
* save: {
|
|
13089
|
-
* handler: (formValues) =>
|
|
13241
|
+
* handler: (formValues) => saveApi.save(formValues).pipe(
|
|
13242
|
+
* map(() => true),
|
|
13243
|
+
* catchError(err => {
|
|
13244
|
+
* notifications.showError(err);
|
|
13245
|
+
* return of(false);
|
|
13246
|
+
* })
|
|
13247
|
+
* ),
|
|
13248
|
+
* onSuccess: () => router.navigate(['/overview'])
|
|
13090
13249
|
* }
|
|
13091
13250
|
* }
|
|
13092
13251
|
* };
|
|
@@ -13193,12 +13352,38 @@ declare class QdPageComponent<T extends object> implements OnInit, OnChanges, Af
|
|
|
13193
13352
|
ngOnChanges(changes: SimpleChanges): void;
|
|
13194
13353
|
ngAfterViewInit(): void;
|
|
13195
13354
|
ngOnDestroy(): void;
|
|
13355
|
+
/**
|
|
13356
|
+
* @description Resets all registered form groups to their last saved snapshot, marking the page
|
|
13357
|
+
* as no longer dirty.
|
|
13358
|
+
*
|
|
13359
|
+
* Intended for explicit consumer-driven discard scenarios where you want subsequent navigation
|
|
13360
|
+
* to bypass the unsaved-changes dialog — for example inside a commit action's `onError` hook
|
|
13361
|
+
* after an auth-expiry response, where the user must be redirected to the login page regardless
|
|
13362
|
+
* of unsaved edits.
|
|
13363
|
+
*
|
|
13364
|
+
* Prefer this over wiring custom bypass logic; it keeps the discard explicit and auditable in
|
|
13365
|
+
* application code.
|
|
13366
|
+
*
|
|
13367
|
+
* @example
|
|
13368
|
+
* ```ts
|
|
13369
|
+
* save: {
|
|
13370
|
+
* handler: (values) => api.save(values).pipe(map(() => true)),
|
|
13371
|
+
* onError: (err) => {
|
|
13372
|
+
* if (err.status === 401) {
|
|
13373
|
+
* this.pageComponent.discardUnsavedChanges();
|
|
13374
|
+
* this.router.navigateByUrl('/login');
|
|
13375
|
+
* }
|
|
13376
|
+
* }
|
|
13377
|
+
* }
|
|
13378
|
+
* ```
|
|
13379
|
+
*/
|
|
13380
|
+
discardUnsavedChanges(): void;
|
|
13196
13381
|
private checkConfigValidity;
|
|
13197
13382
|
private setupCreatePageFooterActions;
|
|
13198
13383
|
private handleCancelActionWithFormChanges;
|
|
13199
13384
|
private initSaveDraftFooterAction;
|
|
13200
13385
|
private updateInspectPageOperationMode;
|
|
13201
|
-
private
|
|
13386
|
+
private generateCommitActionHandler;
|
|
13202
13387
|
private setupCancelConfirmation;
|
|
13203
13388
|
private initSubmitValidation;
|
|
13204
13389
|
private setupPageDialogCloseContract;
|
|
@@ -13325,6 +13510,7 @@ declare class QdPageStoreService<T extends object> {
|
|
|
13325
13510
|
declare class QdPageObjectHeaderComponent<T extends object> implements OnInit, OnChanges, OnDestroy {
|
|
13326
13511
|
private pageObjectResolver;
|
|
13327
13512
|
private formGroupManagerService;
|
|
13513
|
+
private navigationInterceptor;
|
|
13328
13514
|
private dialogComponent;
|
|
13329
13515
|
private dialog;
|
|
13330
13516
|
private confirmationDialogService;
|
|
@@ -13341,6 +13527,8 @@ declare class QdPageObjectHeaderComponent<T extends object> implements OnInit, O
|
|
|
13341
13527
|
private _isLoadingSubject;
|
|
13342
13528
|
private _customActionsSubject;
|
|
13343
13529
|
private _customActionsSub?;
|
|
13530
|
+
private _metadataSub?;
|
|
13531
|
+
private _streamPartial;
|
|
13344
13532
|
private _destroyed$;
|
|
13345
13533
|
private _availableContexts;
|
|
13346
13534
|
pageObjectData$: Observable<T>;
|
|
@@ -13387,6 +13575,7 @@ declare class QdPageObjectHeaderComponent<T extends object> implements OnInit, O
|
|
|
13387
13575
|
private setupResolverTrigger;
|
|
13388
13576
|
private initContexts;
|
|
13389
13577
|
private updateCustomActions;
|
|
13578
|
+
private subscribeToMetadataStream;
|
|
13390
13579
|
private subscribeToViewOnlyMode;
|
|
13391
13580
|
private getCustomActionsByMode;
|
|
13392
13581
|
private openCancelDialog;
|