@yuuvis/client-core 2.2.0 → 2.3.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/fesm2022/yuuvis-client-core.mjs +184 -4
- package/fesm2022/yuuvis-client-core.mjs.map +1 -1
- package/index.d.ts +1 -2
- package/lib/service/pending-changes/index.d.ts +4 -0
- package/lib/service/pending-changes/pending-changes-dialog.guard.service.d.ts +128 -0
- package/lib/service/pending-changes/pending-changes-tab.guard.directive.d.ts +9 -0
- package/package.json +1 -1
|
@@ -3,15 +3,16 @@ import { TranslateService, TranslateLoader, MissingTranslationHandler, Translate
|
|
|
3
3
|
export { TranslateDirective, TranslateLoader, TranslateModule, TranslatePipe, TranslateService } from '@ngx-translate/core';
|
|
4
4
|
import { HttpErrorResponse, HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpEventType, provideHttpClient, withInterceptors } from '@angular/common/http';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
|
-
import { inject, Injectable, InjectionToken, Inject, Pipe, importProvidersFrom, provideAppInitializer } from '@angular/core';
|
|
6
|
+
import { inject, Injectable, InjectionToken, Inject, Directive, Pipe, importProvidersFrom, provideAppInitializer } from '@angular/core';
|
|
7
7
|
import { tap, finalize, shareReplay, catchError, map, switchMap, first, filter, scan, delay } from 'rxjs/operators';
|
|
8
|
-
import { EMPTY, of, forkJoin, Observable, ReplaySubject, Subject, BehaviorSubject, tap as tap$1, map as map$1, merge, fromEvent, filter as filter$1, debounceTime, throwError, switchMap as switchMap$1 } from 'rxjs';
|
|
8
|
+
import { EMPTY, of, forkJoin, Observable, ReplaySubject, Subject, BehaviorSubject, tap as tap$1, map as map$1, merge, fromEvent, filter as filter$1, debounceTime, throwError, isObservable, switchMap as switchMap$1 } from 'rxjs';
|
|
9
9
|
import { StorageMap } from '@ngx-pwa/local-storage';
|
|
10
10
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
11
11
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
12
|
-
import { toSignal } from '@angular/core/rxjs-interop';
|
|
12
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
13
13
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
14
14
|
import { DOCUMENT, DecimalPipe, PercentPipe, CurrencyPipe, registerLocaleData } from '@angular/common';
|
|
15
|
+
import { MatTabGroup } from '@angular/material/tabs';
|
|
15
16
|
import { FormGroup, FormControl } from '@angular/forms';
|
|
16
17
|
import * as i1$1 from '@angular/platform-browser';
|
|
17
18
|
import localeAr from '@angular/common/locales/ar';
|
|
@@ -4477,6 +4478,185 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
4477
4478
|
}]
|
|
4478
4479
|
}], ctorParameters: () => [{ type: PendingChangesService }] });
|
|
4479
4480
|
|
|
4481
|
+
/**
|
|
4482
|
+
* Service that provides guards for Material Dialog close operations.
|
|
4483
|
+
*
|
|
4484
|
+
* This service allows you to intercept and control dialog close events,
|
|
4485
|
+
* enabling confirmation dialogs or preventing accidental closure when
|
|
4486
|
+
* there are unsaved changes or pending operations.
|
|
4487
|
+
*
|
|
4488
|
+
* @example
|
|
4489
|
+
* ```typescript
|
|
4490
|
+
* readonly #dialogCloseGuard = inject(DialogCloseGuard);
|
|
4491
|
+
*
|
|
4492
|
+
* openDialog() {
|
|
4493
|
+
* const dialogRef = this.dialog.open(MyComponent);
|
|
4494
|
+
*
|
|
4495
|
+
* // Prevent dialog from closing if there are unsaved changes
|
|
4496
|
+
* this.#dialogCloseGuard.dialogCanClose(dialogRef, () => {
|
|
4497
|
+
* return this.hasUnsavedChanges() ? this.confirmClose() : true;
|
|
4498
|
+
* }).subscribe();
|
|
4499
|
+
* }
|
|
4500
|
+
* ```
|
|
4501
|
+
*/
|
|
4502
|
+
class DialogCloseGuard {
|
|
4503
|
+
#pendingChangesService = inject(PendingChangesService);
|
|
4504
|
+
/**
|
|
4505
|
+
* Converts a synchronous or asynchronous check function result to an Observable.
|
|
4506
|
+
*
|
|
4507
|
+
* This private method normalizes the return value of check functions,
|
|
4508
|
+
* ensuring they are always handled as Observables for consistent processing.
|
|
4509
|
+
*
|
|
4510
|
+
* @private
|
|
4511
|
+
* @param checkFunction - Function that returns either a boolean or Observable<boolean>
|
|
4512
|
+
* @returns Observable<boolean> - Always returns an Observable, regardless of input type
|
|
4513
|
+
*/
|
|
4514
|
+
#canClose(checkFunction) {
|
|
4515
|
+
const result = checkFunction();
|
|
4516
|
+
return isObservable(result) ? result : of(result);
|
|
4517
|
+
}
|
|
4518
|
+
/**
|
|
4519
|
+
* Guards against dialog closure when the backdrop is clicked.
|
|
4520
|
+
*
|
|
4521
|
+
* This method disables the default close behavior and only allows the dialog
|
|
4522
|
+
* to close when the provided check function returns true. The check is triggered
|
|
4523
|
+
* specifically when the user clicks on the dialog backdrop.
|
|
4524
|
+
*
|
|
4525
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
4526
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
4527
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
4528
|
+
* @returns Observable<boolean> - Emits true when the dialog can be closed via backdrop click
|
|
4529
|
+
*
|
|
4530
|
+
* @example
|
|
4531
|
+
* ```typescript
|
|
4532
|
+
* this.dialogCloseGuard.checkBackdropCanClose(dialogRef, () => {
|
|
4533
|
+
* return this.formIsDirty ? this.showConfirmDialog() : true;
|
|
4534
|
+
* }).subscribe(canClose => {
|
|
4535
|
+
* if (canClose) {
|
|
4536
|
+
* dialogRef.close();
|
|
4537
|
+
* }
|
|
4538
|
+
* });
|
|
4539
|
+
* ```
|
|
4540
|
+
*/
|
|
4541
|
+
checkBackdropCanClose(dialogRef, checkFunction) {
|
|
4542
|
+
dialogRef.disableClose = true;
|
|
4543
|
+
return dialogRef.backdropClick().pipe(switchMap$1(() => this.#canClose(checkFunction)));
|
|
4544
|
+
}
|
|
4545
|
+
/**
|
|
4546
|
+
* Guards against dialog closure when the Escape key is pressed.
|
|
4547
|
+
*
|
|
4548
|
+
* This method disables the default close behavior and only allows the dialog
|
|
4549
|
+
* to close when the provided check function returns true. The check is triggered
|
|
4550
|
+
* specifically when the user presses the Escape key.
|
|
4551
|
+
*
|
|
4552
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
4553
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
4554
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
4555
|
+
* @returns Observable<boolean> - Emits true when the dialog can be closed via Escape key
|
|
4556
|
+
*
|
|
4557
|
+
* @example
|
|
4558
|
+
* ```typescript
|
|
4559
|
+
* this.dialogCloseGuard.checkKeydownEventsCanClose(dialogRef, () => {
|
|
4560
|
+
* return this.hasUnsavedChanges ? this.confirmDiscardChanges() : true;
|
|
4561
|
+
* }).subscribe(canClose => {
|
|
4562
|
+
* if (canClose) {
|
|
4563
|
+
* dialogRef.close();
|
|
4564
|
+
* }
|
|
4565
|
+
* });
|
|
4566
|
+
* ```
|
|
4567
|
+
*/
|
|
4568
|
+
checkKeydownEventsCanClose(dialogRef, checkFunction) {
|
|
4569
|
+
dialogRef.disableClose = true;
|
|
4570
|
+
return dialogRef.keydownEvents().pipe(filter$1((event) => event.key === 'Escape'), switchMap$1(() => this.#canClose(checkFunction)));
|
|
4571
|
+
}
|
|
4572
|
+
/**
|
|
4573
|
+
* Comprehensive dialog close guard that handles both backdrop clicks and Escape key presses.
|
|
4574
|
+
*
|
|
4575
|
+
* This method provides a unified approach to guard dialog closure by monitoring both
|
|
4576
|
+
* backdrop clicks and Escape key events. When either event occurs, it runs the provided
|
|
4577
|
+
* check function and automatically closes the dialog if the check passes.
|
|
4578
|
+
*
|
|
4579
|
+
* This is the most convenient method when you want to guard against all common
|
|
4580
|
+
* dialog close scenarios with a single setup.
|
|
4581
|
+
*
|
|
4582
|
+
* @template T - The type of data that the dialog returns
|
|
4583
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
4584
|
+
* @param checkFunction - Function that determines if the dialog can be closed.
|
|
4585
|
+
* Can return a boolean directly or an Observable<boolean>
|
|
4586
|
+
* @returns Observable<false | void> - Emits false if the dialog cannot be closed,
|
|
4587
|
+
* or void when the dialog is successfully closed
|
|
4588
|
+
*
|
|
4589
|
+
* @example
|
|
4590
|
+
* ```typescript
|
|
4591
|
+
* // Simple boolean check
|
|
4592
|
+
* this.dialogCloseGuard.dialogCanClose(dialogRef, () => !this.hasUnsavedChanges).subscribe();
|
|
4593
|
+
*
|
|
4594
|
+
* // Async check with confirmation dialog
|
|
4595
|
+
* this.dialogCloseGuard.dialogCanClose(dialogRef, () => {
|
|
4596
|
+
* return this.hasUnsavedChanges
|
|
4597
|
+
* ? this.confirmationService.confirm('Discard changes?')
|
|
4598
|
+
* : of(true);
|
|
4599
|
+
* }).subscribe();
|
|
4600
|
+
* ```
|
|
4601
|
+
*/
|
|
4602
|
+
preventCloseUntil(dialogRef, checkFunction) {
|
|
4603
|
+
dialogRef.disableClose = true;
|
|
4604
|
+
return merge(dialogRef.backdropClick(), dialogRef.keydownEvents().pipe(filter$1((event) => event.key === 'Escape'))).pipe(switchMap$1(() => this.#canClose(checkFunction)), map$1((canClose) => canClose && dialogRef.close()));
|
|
4605
|
+
}
|
|
4606
|
+
/**
|
|
4607
|
+
* Specialized dialog close guard that automatically checks for pending changes.
|
|
4608
|
+
*
|
|
4609
|
+
* This convenience method provides automatic pending changes detection without
|
|
4610
|
+
* requiring a custom check function. It integrates with the PendingChangesService
|
|
4611
|
+
* to determine if there are any unsaved changes, and handles both backdrop clicks
|
|
4612
|
+
* and Escape key presses automatically.
|
|
4613
|
+
*
|
|
4614
|
+
* This method is ideal when you want to prevent dialog closure if there are
|
|
4615
|
+
* pending changes anywhere in the application, without having to implement
|
|
4616
|
+
* custom change detection logic.
|
|
4617
|
+
*
|
|
4618
|
+
* @template T - The type of data that the dialog returns
|
|
4619
|
+
* @param dialogRef - Reference to the Material Dialog instance
|
|
4620
|
+
* @returns Observable<false | void> - Emits false if there are pending changes
|
|
4621
|
+
* preventing closure, or void when the dialog
|
|
4622
|
+
* is successfully closed
|
|
4623
|
+
*
|
|
4624
|
+
*/
|
|
4625
|
+
pendingChangesDialogCanClose(dialogRef) {
|
|
4626
|
+
dialogRef.disableClose = true;
|
|
4627
|
+
return merge(dialogRef.backdropClick(), dialogRef.keydownEvents().pipe(filter$1((event) => event.key === 'Escape'))).pipe(switchMap$1(() => of(this.#pendingChangesService.check())), map$1((canClose) => !canClose && dialogRef.close()));
|
|
4628
|
+
}
|
|
4629
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DialogCloseGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4630
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DialogCloseGuard }); }
|
|
4631
|
+
}
|
|
4632
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DialogCloseGuard, decorators: [{
|
|
4633
|
+
type: Injectable
|
|
4634
|
+
}] });
|
|
4635
|
+
|
|
4636
|
+
class TabGuardDirective {
|
|
4637
|
+
#tabGroup = inject(MatTabGroup);
|
|
4638
|
+
#pending = inject(PendingChangesService);
|
|
4639
|
+
constructor() {
|
|
4640
|
+
this.#tabGroup.selectedIndexChange.pipe(takeUntilDestroyed()).subscribe(() => this.#updateTabs());
|
|
4641
|
+
}
|
|
4642
|
+
ngDoCheck() {
|
|
4643
|
+
this.#updateTabs();
|
|
4644
|
+
}
|
|
4645
|
+
#updateTabs() {
|
|
4646
|
+
const activeIndex = this.#tabGroup.selectedIndex ?? 0;
|
|
4647
|
+
const hasPending = this.#pending.hasPendingTask();
|
|
4648
|
+
this.#tabGroup._tabs.forEach((tab, i) => (tab.disabled = hasPending && i !== activeIndex));
|
|
4649
|
+
}
|
|
4650
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TabGuardDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
4651
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.14", type: TabGuardDirective, isStandalone: true, selector: "mat-tab-group[yuvTabGuardDisable]", ngImport: i0 }); }
|
|
4652
|
+
}
|
|
4653
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TabGuardDirective, decorators: [{
|
|
4654
|
+
type: Directive,
|
|
4655
|
+
args: [{
|
|
4656
|
+
selector: 'mat-tab-group[yuvTabGuardDisable]'
|
|
4657
|
+
}]
|
|
4658
|
+
}], ctorParameters: () => [] });
|
|
4659
|
+
|
|
4480
4660
|
class PredictionService {
|
|
4481
4661
|
#backend = inject(BackendService);
|
|
4482
4662
|
classify(objectIDs, schemaObjectTypeId = 'CLASSIFICATION') {
|
|
@@ -5245,5 +5425,5 @@ const provideYuvClientCore = (options = { translations: [] }) => {
|
|
|
5245
5425
|
* Generated bundle index. Do not edit.
|
|
5246
5426
|
*/
|
|
5247
5427
|
|
|
5248
|
-
export { AFO_STATE, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CORE_CONFIG, CUSTOM_CONFIG, CatalogService, Classification, ClassificationPrefix, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideUser, provideYuvClientCore };
|
|
5428
|
+
export { AFO_STATE, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CORE_CONFIG, CUSTOM_CONFIG, CatalogService, Classification, ClassificationPrefix, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, DialogCloseGuard, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, TabGuardDirective, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideUser, provideYuvClientCore };
|
|
5249
5429
|
//# sourceMappingURL=yuuvis-client-core.mjs.map
|