@flusys/ng-shared 5.0.3 → 5.0.4
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/README.md +29 -25
- package/fesm2022/flusys-ng-shared.mjs +417 -197
- package/fesm2022/flusys-ng-shared.mjs.map +1 -1
- package/package.json +2 -2
- package/types/flusys-ng-shared.d.ts +209 -179
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, PLATFORM_ID, Injectable, DOCUMENT, REQUEST, signal, computed, ElementRef, input, effect, Directive, TemplateRef, ViewContainerRef, output, Pipe, Injector, isDevMode, NgModule, resource, model, runInInjectionContext, untracked, forwardRef, InjectionToken, Component, DestroyRef, ApplicationRef, viewChild, afterNextRender, ViewEncapsulation } from '@angular/core';
|
|
3
|
-
import { isPlatformServer, CommonModule, NgOptimizedImage, NgComponentOutlet, DatePipe, DOCUMENT as DOCUMENT$1 } from '@angular/common';
|
|
4
|
-
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
5
|
-
import { APP_CONFIG, getServiceUrl,
|
|
6
|
-
import { of, firstValueFrom, map as map$1, from } from 'rxjs';
|
|
3
|
+
import { isPlatformServer, isPlatformBrowser, CommonModule, NgOptimizedImage, NgComponentOutlet, DatePipe, DOCUMENT as DOCUMENT$1 } from '@angular/common';
|
|
4
|
+
import { HttpClient, HttpContextToken, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
5
|
+
import { APP_CONFIG, getServiceUrl, LOCALIZATION_STATE_SERVICE, LOCALIZATION_API_SERVICE, FALLBACK_MESSAGES_REGISTRY } from '@flusys/ng-core';
|
|
6
|
+
import { of, catchError as catchError$1, throwError, firstValueFrom, map as map$1, from } from 'rxjs';
|
|
7
7
|
import { map, tap, catchError } from 'rxjs/operators';
|
|
8
8
|
import * as i1$1 from '@angular/forms';
|
|
9
9
|
import { NgControl, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
|
+
import * as i3 from 'primeng/api';
|
|
11
|
+
import { MessageService, ConfirmationService } from 'primeng/api';
|
|
10
12
|
import { RouterOutlet, RouterLink, RouterLinkActive, Router, ActivatedRoute } from '@angular/router';
|
|
11
13
|
import { AutoCompleteModule } from 'primeng/autocomplete';
|
|
12
14
|
import { AvatarModule } from 'primeng/avatar';
|
|
@@ -56,8 +58,6 @@ import { TooltipModule } from 'primeng/tooltip';
|
|
|
56
58
|
import { TreeTableModule } from 'primeng/treetable';
|
|
57
59
|
import { ProgressSpinnerModule } from 'primeng/progressspinner';
|
|
58
60
|
import { ColorPickerModule } from 'primeng/colorpicker';
|
|
59
|
-
import * as i3 from 'primeng/api';
|
|
60
|
-
import { MessageService, ConfirmationService } from 'primeng/api';
|
|
61
61
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
62
62
|
|
|
63
63
|
const SHARED_MESSAGES = {
|
|
@@ -309,6 +309,7 @@ const SHARED_MESSAGES = {
|
|
|
309
309
|
'primeng.country.placeholder': 'Choose a country',
|
|
310
310
|
};
|
|
311
311
|
|
|
312
|
+
// ==================== AUTH MODULE ====================
|
|
312
313
|
const USER_PERMISSIONS = {
|
|
313
314
|
CREATE: 'user.create',
|
|
314
315
|
READ: 'user.read',
|
|
@@ -327,6 +328,7 @@ const BRANCH_PERMISSIONS = {
|
|
|
327
328
|
UPDATE: 'branch.update',
|
|
328
329
|
DELETE: 'branch.delete',
|
|
329
330
|
};
|
|
331
|
+
// ==================== IAM MODULE ====================
|
|
330
332
|
const ACTION_PERMISSIONS = {
|
|
331
333
|
CREATE: 'action.create',
|
|
332
334
|
READ: 'action.read',
|
|
@@ -355,6 +357,7 @@ const COMPANY_ACTION_PERMISSIONS = {
|
|
|
355
357
|
READ: 'company-action.read',
|
|
356
358
|
ASSIGN: 'company-action.assign',
|
|
357
359
|
};
|
|
360
|
+
// ==================== STORAGE MODULE ====================
|
|
358
361
|
const FILE_PERMISSIONS = {
|
|
359
362
|
CREATE: 'file.create',
|
|
360
363
|
READ: 'file.read',
|
|
@@ -373,6 +376,10 @@ const STORAGE_CONFIG_PERMISSIONS = {
|
|
|
373
376
|
UPDATE: 'storage-config.update',
|
|
374
377
|
DELETE: 'storage-config.delete',
|
|
375
378
|
};
|
|
379
|
+
const UPLOAD_CONFIG_PERMISSIONS = {
|
|
380
|
+
DELETE: 'upload-config.delete',
|
|
381
|
+
};
|
|
382
|
+
// ==================== EMAIL MODULE ====================
|
|
376
383
|
const EMAIL_CONFIG_PERMISSIONS = {
|
|
377
384
|
CREATE: 'email-config.create',
|
|
378
385
|
READ: 'email-config.read',
|
|
@@ -385,30 +392,34 @@ const EMAIL_TEMPLATE_PERMISSIONS = {
|
|
|
385
392
|
UPDATE: 'email-template.update',
|
|
386
393
|
DELETE: 'email-template.delete',
|
|
387
394
|
};
|
|
395
|
+
// ==================== FORM BUILDER MODULE ====================
|
|
388
396
|
const FORM_PERMISSIONS = {
|
|
389
397
|
CREATE: 'form.create',
|
|
390
398
|
READ: 'form.read',
|
|
391
399
|
UPDATE: 'form.update',
|
|
392
400
|
DELETE: 'form.delete',
|
|
393
401
|
};
|
|
402
|
+
const FORM_RESULT_PERMISSIONS = {
|
|
403
|
+
CREATE: 'form-result.create',
|
|
404
|
+
READ: 'form-result.read',
|
|
405
|
+
UPDATE: 'form-result.update',
|
|
406
|
+
DELETE: 'form-result.delete',
|
|
407
|
+
};
|
|
408
|
+
// ==================== EVENT MANAGER MODULE ====================
|
|
394
409
|
const EVENT_PERMISSIONS = {
|
|
395
410
|
CREATE: 'event.create',
|
|
396
411
|
READ: 'event.read',
|
|
397
412
|
UPDATE: 'event.update',
|
|
398
413
|
DELETE: 'event.delete',
|
|
399
414
|
};
|
|
400
|
-
|
|
401
|
-
CREATE: 'event-participant.create',
|
|
402
|
-
READ: 'event-participant.read',
|
|
403
|
-
UPDATE: 'event-participant.update',
|
|
404
|
-
DELETE: 'event-participant.delete',
|
|
405
|
-
};
|
|
415
|
+
// ==================== NOTIFICATION MODULE ====================
|
|
406
416
|
const NOTIFICATION_PERMISSIONS = {
|
|
407
417
|
CREATE: 'notification.create',
|
|
408
418
|
READ: 'notification.read',
|
|
409
419
|
UPDATE: 'notification.update',
|
|
410
420
|
DELETE: 'notification.delete',
|
|
411
421
|
};
|
|
422
|
+
// ==================== LOCALIZATION MODULE ====================
|
|
412
423
|
const LANGUAGE_PERMISSIONS = {
|
|
413
424
|
CREATE: 'language.create',
|
|
414
425
|
READ: 'language.read',
|
|
@@ -427,10 +438,48 @@ const TRANSLATION_PERMISSIONS = {
|
|
|
427
438
|
UPDATE: 'translation.update',
|
|
428
439
|
DELETE: 'translation.delete',
|
|
429
440
|
};
|
|
441
|
+
// ==================== AGGREGATED EXPORTS ====================
|
|
442
|
+
const PERMISSIONS = {
|
|
443
|
+
// Auth
|
|
444
|
+
USER: USER_PERMISSIONS,
|
|
445
|
+
COMPANY: COMPANY_PERMISSIONS,
|
|
446
|
+
BRANCH: BRANCH_PERMISSIONS,
|
|
447
|
+
// IAM
|
|
448
|
+
ACTION: ACTION_PERMISSIONS,
|
|
449
|
+
ROLE: ROLE_PERMISSIONS,
|
|
450
|
+
ROLE_ACTION: ROLE_ACTION_PERMISSIONS,
|
|
451
|
+
USER_ROLE: USER_ROLE_PERMISSIONS,
|
|
452
|
+
USER_ACTION: USER_ACTION_PERMISSIONS,
|
|
453
|
+
COMPANY_ACTION: COMPANY_ACTION_PERMISSIONS,
|
|
454
|
+
// Storage
|
|
455
|
+
FILE: FILE_PERMISSIONS,
|
|
456
|
+
FOLDER: FOLDER_PERMISSIONS,
|
|
457
|
+
STORAGE_CONFIG: STORAGE_CONFIG_PERMISSIONS,
|
|
458
|
+
// Email
|
|
459
|
+
EMAIL_CONFIG: EMAIL_CONFIG_PERMISSIONS,
|
|
460
|
+
EMAIL_TEMPLATE: EMAIL_TEMPLATE_PERMISSIONS,
|
|
461
|
+
// Form Builder
|
|
462
|
+
FORM: FORM_PERMISSIONS,
|
|
463
|
+
FORM_RESULT: FORM_RESULT_PERMISSIONS,
|
|
464
|
+
// Event Manager
|
|
465
|
+
EVENT: EVENT_PERMISSIONS,
|
|
466
|
+
// Notification
|
|
467
|
+
NOTIFICATION: NOTIFICATION_PERMISSIONS,
|
|
468
|
+
// Localization
|
|
469
|
+
LANGUAGE: LANGUAGE_PERMISSIONS,
|
|
470
|
+
TRANSLATION_KEY: TRANSLATION_KEY_PERMISSIONS,
|
|
471
|
+
TRANSLATION: TRANSLATION_PERMISSIONS,
|
|
472
|
+
};
|
|
430
473
|
|
|
431
474
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
432
475
|
const FILE_TYPE_FILTERS = {
|
|
433
|
-
IMAGES: [
|
|
476
|
+
IMAGES: [
|
|
477
|
+
'image/jpeg',
|
|
478
|
+
'image/png',
|
|
479
|
+
'image/gif',
|
|
480
|
+
'image/webp',
|
|
481
|
+
'image/svg+xml',
|
|
482
|
+
],
|
|
434
483
|
DOCUMENTS: [
|
|
435
484
|
'application/pdf',
|
|
436
485
|
'application/msword',
|
|
@@ -449,7 +498,9 @@ function getAcceptString(contentTypes) {
|
|
|
449
498
|
function isFileTypeAllowed(file, allowedTypes) {
|
|
450
499
|
if (!allowedTypes.length)
|
|
451
500
|
return true;
|
|
452
|
-
return allowedTypes.some((type) => type.endsWith('/*')
|
|
501
|
+
return allowedTypes.some((type) => type.endsWith('/*')
|
|
502
|
+
? file.type.startsWith(type.replace('/*', '/'))
|
|
503
|
+
: file.type === type);
|
|
453
504
|
}
|
|
454
505
|
function getFileIconClass(contentType) {
|
|
455
506
|
if (contentType.startsWith('image/'))
|
|
@@ -522,16 +573,6 @@ class FileUrlService {
|
|
|
522
573
|
appConfig = inject(APP_CONFIG);
|
|
523
574
|
_cache = signal(new Map(), ...(ngDevMode ? [{ debugName: "_cache" }] : []));
|
|
524
575
|
cache = this._cache.asReadonly();
|
|
525
|
-
/** Get file URL by ID from cache (synchronous) */
|
|
526
|
-
getFileUrl(fileId) {
|
|
527
|
-
if (!fileId)
|
|
528
|
-
return null;
|
|
529
|
-
return this._cache().get(fileId)?.url ?? null;
|
|
530
|
-
}
|
|
531
|
-
/** Get file URL as computed signal */
|
|
532
|
-
fileUrlSignal(fileId) {
|
|
533
|
-
return computed(() => this.getFileUrl(fileId));
|
|
534
|
-
}
|
|
535
576
|
/** Fetch file URLs from backend and update cache */
|
|
536
577
|
fetchFileUrls(fileIds, forceRefresh = false) {
|
|
537
578
|
if (!fileIds.length)
|
|
@@ -552,18 +593,6 @@ class FileUrlService {
|
|
|
552
593
|
fetchSingleFileUrl(fileId, forceRefresh = false) {
|
|
553
594
|
return this.fetchFileUrls([fileId], forceRefresh).pipe(map((files) => files[0] ?? null));
|
|
554
595
|
}
|
|
555
|
-
/** Clear entire cache */
|
|
556
|
-
clearCache() {
|
|
557
|
-
this._cache.set(new Map());
|
|
558
|
-
}
|
|
559
|
-
/** Remove specific file from cache */
|
|
560
|
-
removeFromCache(fileId) {
|
|
561
|
-
this._cache.update((cache) => {
|
|
562
|
-
const next = new Map(cache);
|
|
563
|
-
next.delete(fileId);
|
|
564
|
-
return next;
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
596
|
addToCache(files) {
|
|
568
597
|
this._cache.update((cache) => {
|
|
569
598
|
const next = new Map(cache);
|
|
@@ -670,6 +699,10 @@ class PermissionValidatorService {
|
|
|
670
699
|
hasPermission(code) {
|
|
671
700
|
return hasPermission(code, this._permissions());
|
|
672
701
|
}
|
|
702
|
+
/** Check if user has ANY of the specified permissions (OR logic) */
|
|
703
|
+
hasAnyPermission(code) {
|
|
704
|
+
return hasAnyPermission(code, this._permissions());
|
|
705
|
+
}
|
|
673
706
|
isPermissionsLoaded() {
|
|
674
707
|
return this._isLoaded();
|
|
675
708
|
}
|
|
@@ -681,6 +714,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
681
714
|
args: [{ providedIn: 'root' }]
|
|
682
715
|
}] });
|
|
683
716
|
|
|
717
|
+
class TranslateService {
|
|
718
|
+
localizationState = inject(LOCALIZATION_STATE_SERVICE);
|
|
719
|
+
translate(key, params) {
|
|
720
|
+
const translations = this.localizationState.translations();
|
|
721
|
+
const value = translations[key];
|
|
722
|
+
if (!value) {
|
|
723
|
+
return this.getFromFallback(key, params);
|
|
724
|
+
}
|
|
725
|
+
return this.interpolate(value, params);
|
|
726
|
+
}
|
|
727
|
+
translateSignal(key, params) {
|
|
728
|
+
return computed(() => {
|
|
729
|
+
this.localizationState.currentLanguage();
|
|
730
|
+
return this.translate(key, params);
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
getFromFallback(key, params) {
|
|
734
|
+
const fallbacks = this.localizationState.fallbackMessages();
|
|
735
|
+
const value = fallbacks[key] ?? key;
|
|
736
|
+
return this.interpolate(value, params);
|
|
737
|
+
}
|
|
738
|
+
interpolate(template, params) {
|
|
739
|
+
if (!params || !template)
|
|
740
|
+
return template;
|
|
741
|
+
return template.replace(/\{\{(\w+)\}\}/g, (match, paramKey) => {
|
|
742
|
+
const value = params[paramKey];
|
|
743
|
+
return value !== undefined ? String(value) : match;
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: TranslateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
747
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: TranslateService, providedIn: 'root' });
|
|
748
|
+
}
|
|
749
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: TranslateService, decorators: [{
|
|
750
|
+
type: Injectable,
|
|
751
|
+
args: [{ providedIn: 'root' }]
|
|
752
|
+
}] });
|
|
753
|
+
|
|
684
754
|
class EditModeElementChangerDirective {
|
|
685
755
|
el = inject(ElementRef);
|
|
686
756
|
ngControl = inject(NgControl, { optional: true });
|
|
@@ -940,38 +1010,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
940
1010
|
}], propDecorators: { eventType: [{ type: i0.Input, args: [{ isSignal: true, alias: "eventType", required: false }] }], preventKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "preventKey", required: false }] }], action: [{ type: i0.Output, args: ["action"] }] } });
|
|
941
1011
|
|
|
942
1012
|
class TranslatePipe {
|
|
943
|
-
translateAdapter = inject(
|
|
944
|
-
fallbackMessages = inject(FALLBACK_MESSAGES_REGISTRY, { optional: true });
|
|
1013
|
+
translateAdapter = inject(TranslateService);
|
|
945
1014
|
transform(key, params, fallback) {
|
|
946
1015
|
if (!key)
|
|
947
1016
|
return fallback ?? '';
|
|
948
|
-
if (!this.translateAdapter) {
|
|
949
|
-
const result = this.getFromFallback(key, params ?? undefined);
|
|
950
|
-
return fallback !== undefined && result === key ? fallback : result;
|
|
951
|
-
}
|
|
952
|
-
this.translateAdapter.languageCode();
|
|
953
1017
|
const result = this.translateAdapter.translate(key, params ?? undefined);
|
|
954
1018
|
return fallback !== undefined && result === key ? fallback : result;
|
|
955
1019
|
}
|
|
956
|
-
getFromFallback(template, params) {
|
|
957
|
-
// Try to get from fallback messages registry first
|
|
958
|
-
if (this.fallbackMessages) {
|
|
959
|
-
const value = this.fallbackMessages[template];
|
|
960
|
-
if (value) {
|
|
961
|
-
return this.interpolate(value, params);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
// Fall back to interpolating the key itself
|
|
965
|
-
return this.interpolate(template, params);
|
|
966
|
-
}
|
|
967
|
-
interpolate(template, params) {
|
|
968
|
-
if (!params)
|
|
969
|
-
return template;
|
|
970
|
-
return template.replace(/\{\{(\w+)\}\}/g, (match, paramKey) => {
|
|
971
|
-
const value = params[paramKey];
|
|
972
|
-
return value !== undefined ? String(value) : match;
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
1020
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: TranslatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
976
1021
|
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.5", ngImport: i0, type: TranslatePipe, isStandalone: true, name: "translate", pure: false });
|
|
977
1022
|
}
|
|
@@ -983,21 +1028,174 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
983
1028
|
}]
|
|
984
1029
|
}] });
|
|
985
1030
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1031
|
+
/**
|
|
1032
|
+
* HTTP context token to skip global error toast.
|
|
1033
|
+
* Use when component handles error display locally.
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```typescript
|
|
1037
|
+
* this.http.post(url, data, {
|
|
1038
|
+
* context: new HttpContext().set(SKIP_ERROR_TOAST, true)
|
|
1039
|
+
* });
|
|
1040
|
+
* ```
|
|
1041
|
+
*/
|
|
1042
|
+
const SKIP_ERROR_TOAST = new HttpContextToken(() => false);
|
|
1043
|
+
/**
|
|
1044
|
+
* Error Catching Interceptor
|
|
1045
|
+
* Displays error messages for failed HTTP requests using backend response.
|
|
1046
|
+
*
|
|
1047
|
+
* Features:
|
|
1048
|
+
* - Uses backend's error title (error.error.error) as summary
|
|
1049
|
+
* - Uses backend's error message (error.error.message) as detail
|
|
1050
|
+
* - Falls back to sensible defaults based on status code
|
|
1051
|
+
* - Skip with SKIP_ERROR_TOAST context token for local handling
|
|
1052
|
+
*
|
|
1053
|
+
* NOTE: This interceptor only handles error display.
|
|
1054
|
+
* For 401 handling and token refresh, use tokenRefreshInterceptor from @flusys/ng-auth.
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```typescript
|
|
1058
|
+
* // In app.config.ts
|
|
1059
|
+
* provideHttpClient(
|
|
1060
|
+
* withFetch(),
|
|
1061
|
+
* withInterceptors([
|
|
1062
|
+
* authInterceptor, // from @flusys/ng-auth
|
|
1063
|
+
* tokenRefreshInterceptor, // from @flusys/ng-auth
|
|
1064
|
+
* errorCatchingInterceptor, // from @flusys/ng-core
|
|
1065
|
+
* apiLoaderInterceptor, // from @flusys/ng-core
|
|
1066
|
+
* ])
|
|
1067
|
+
* )
|
|
1068
|
+
* ```
|
|
1069
|
+
*/
|
|
1070
|
+
function errorCatchingInterceptor(req, next) {
|
|
1071
|
+
const messageService = inject(MessageService);
|
|
1072
|
+
const platformId = inject(PLATFORM_ID);
|
|
1073
|
+
const translateAdapter = inject(TranslateService, { optional: true });
|
|
1074
|
+
const isBrowser = isPlatformBrowser(platformId);
|
|
1075
|
+
// Skip error display for check-login (expected to fail when not logged in)
|
|
1076
|
+
const isCheckLogin = req.url.includes('/check-login');
|
|
1077
|
+
// Skip if component handles error locally
|
|
1078
|
+
const skipErrorToast = req.context.get(SKIP_ERROR_TOAST);
|
|
1079
|
+
return next(req).pipe(catchError$1((error) => {
|
|
1080
|
+
// Skip 401 errors - handled by tokenRefreshInterceptor in ng-auth
|
|
1081
|
+
// Skip 403 errors - handled by permission denied UI in components
|
|
1082
|
+
// Skip check-login errors - expected behavior
|
|
1083
|
+
// Skip if component handles error locally
|
|
1084
|
+
if (error.status === 401 ||
|
|
1085
|
+
error.status === 403 ||
|
|
1086
|
+
isCheckLogin ||
|
|
1087
|
+
skipErrorToast) {
|
|
1088
|
+
return throwError(() => error);
|
|
1089
|
+
}
|
|
1090
|
+
// Display error message for other errors
|
|
1091
|
+
if (isBrowser) {
|
|
1092
|
+
const { summary, detail } = extractErrorInfo(error, translateAdapter);
|
|
1093
|
+
messageService.add({
|
|
1094
|
+
severity: 'error',
|
|
1095
|
+
summary,
|
|
1096
|
+
detail,
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
return throwError(() => error);
|
|
1100
|
+
}));
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Extract error summary and detail from HTTP error response.
|
|
1104
|
+
* Uses backend response format: { message, messageKey, messageVariables, error, statusCode }
|
|
1105
|
+
* If messageKey is present and translate adapter is available, translates the message.
|
|
1106
|
+
*/
|
|
1107
|
+
function extractErrorInfo(error, translateAdapter) {
|
|
1108
|
+
// Check if we have a messageKey for translation
|
|
1109
|
+
const messageKey = error.error?.messageKey;
|
|
1110
|
+
const messageVariables = error.error?.messageVariables;
|
|
1111
|
+
let detail;
|
|
1112
|
+
if (messageKey && translateAdapter) {
|
|
1113
|
+
// Use translated message if available
|
|
1114
|
+
detail = translateAdapter.translate(messageKey, messageVariables);
|
|
1115
|
+
}
|
|
1116
|
+
else if (typeof error.error?.message === 'string') {
|
|
1117
|
+
detail = error.error.message;
|
|
1118
|
+
}
|
|
1119
|
+
else if (Array.isArray(error.error?.message)) {
|
|
1120
|
+
// NestJS validation errors come as array
|
|
1121
|
+
detail = error.error.message[0];
|
|
1122
|
+
}
|
|
1123
|
+
else if (error.message) {
|
|
1124
|
+
detail = error.message;
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
detail = translateAdapter
|
|
1128
|
+
? translateAdapter.translate('shared.unexpected.error')
|
|
1129
|
+
: 'shared.unexpected.error';
|
|
1130
|
+
}
|
|
1131
|
+
// Extract summary/title from backend response or use default based on status
|
|
1132
|
+
let summary;
|
|
1133
|
+
if (typeof error.error?.error === 'string') {
|
|
1134
|
+
// Backend sends error type (e.g., "Not Found", "Bad Request", "Validation Error")
|
|
1135
|
+
summary = error.error.error;
|
|
1136
|
+
}
|
|
1137
|
+
else {
|
|
1138
|
+
// Fallback to status-based title
|
|
1139
|
+
summary = getDefaultSummary(error.status, translateAdapter);
|
|
1140
|
+
}
|
|
1141
|
+
return { summary, detail };
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Get default error summary based on HTTP status code.
|
|
1145
|
+
*/
|
|
1146
|
+
function getDefaultSummary(status, translateAdapter) {
|
|
1147
|
+
const keyMap = {
|
|
1148
|
+
400: 'shared.error.bad.request',
|
|
1149
|
+
404: 'shared.error.not.found',
|
|
1150
|
+
409: 'shared.error.conflict',
|
|
1151
|
+
422: 'shared.error.validation.error',
|
|
1152
|
+
500: 'shared.error.server.error',
|
|
1153
|
+
502: 'shared.error.service.unavailable',
|
|
1154
|
+
503: 'shared.error.service.unavailable',
|
|
1155
|
+
504: 'shared.error.service.unavailable',
|
|
1156
|
+
};
|
|
1157
|
+
const key = keyMap[status] || 'shared.error';
|
|
1158
|
+
if (translateAdapter) {
|
|
1159
|
+
return translateAdapter.translate(key);
|
|
997
1160
|
}
|
|
998
|
-
|
|
1161
|
+
// Fallback to key when no translator available
|
|
1162
|
+
return key;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Resolver to load translations for specific modules.
|
|
1167
|
+
* Works with or without @flusys/ng-localization provider.
|
|
1168
|
+
*
|
|
1169
|
+
* When localization provider is enabled:
|
|
1170
|
+
* - Registers fallback messages in state
|
|
1171
|
+
* - Fetches translations from API
|
|
1172
|
+
* - Merges them into state
|
|
1173
|
+
*
|
|
1174
|
+
* When localization provider is not enabled:
|
|
1175
|
+
* - Registers fallback messages in FALLBACK_MESSAGES_REGISTRY
|
|
1176
|
+
* - TranslatePipe uses registry for translations
|
|
1177
|
+
* - No API calls
|
|
1178
|
+
*
|
|
1179
|
+
* @param config - Module config with modules array and optional fallback messages
|
|
1180
|
+
* @returns ResolveFn that loads translations before route activation
|
|
1181
|
+
*
|
|
1182
|
+
* @example
|
|
1183
|
+
* // With fallback messages (recommended)
|
|
1184
|
+
* { resolve: { t: resolveTranslationModule({ modules: ['auth'], fallbackMessages: AUTH_MESSAGES }) } }
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* // Without fallback (API translations only, requires localization provider)
|
|
1188
|
+
* { resolve: { t: resolveTranslationModule({ modules: ['auth', 'iam'] }) } }
|
|
1189
|
+
*/
|
|
1190
|
+
async function tryLoadLocalizationServices(injector) {
|
|
1191
|
+
const stateService = injector.get(LOCALIZATION_STATE_SERVICE, null);
|
|
1192
|
+
const apiService = injector.get(LOCALIZATION_API_SERVICE, null);
|
|
1193
|
+
if (!stateService || !apiService)
|
|
999
1194
|
return null;
|
|
1000
|
-
|
|
1195
|
+
return {
|
|
1196
|
+
stateService,
|
|
1197
|
+
apiService,
|
|
1198
|
+
};
|
|
1001
1199
|
}
|
|
1002
1200
|
function resolveTranslationModule(config) {
|
|
1003
1201
|
return async () => {
|
|
@@ -1019,6 +1217,10 @@ function resolveTranslationModule(config) {
|
|
|
1019
1217
|
if (registry) {
|
|
1020
1218
|
Object.assign(registry, fallbackMessages);
|
|
1021
1219
|
}
|
|
1220
|
+
else if (isDevMode()) {
|
|
1221
|
+
console.warn('resolveTranslationModule: FALLBACK_MESSAGES_REGISTRY not provided. ' +
|
|
1222
|
+
'Add provideFallbackMessagesRegistry() to your app providers.');
|
|
1223
|
+
}
|
|
1022
1224
|
}
|
|
1023
1225
|
}
|
|
1024
1226
|
if (!locServices)
|
|
@@ -1236,19 +1438,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
1236
1438
|
}]
|
|
1237
1439
|
}] });
|
|
1238
1440
|
|
|
1441
|
+
// ── Separate default filter into a named constant so it's sharable/testable ──
|
|
1442
|
+
const DEFAULT_FILTER = {
|
|
1443
|
+
pagination: { currentPage: 0, pageSize: 10 },
|
|
1444
|
+
filter: {},
|
|
1445
|
+
select: [],
|
|
1446
|
+
sort: {},
|
|
1447
|
+
};
|
|
1239
1448
|
class ApiResourceService {
|
|
1449
|
+
// ── Injected once via `inject()` ──────────────────────────────────────────
|
|
1450
|
+
http = inject(HttpClient);
|
|
1451
|
+
_config = inject(APP_CONFIG);
|
|
1240
1452
|
baseUrl;
|
|
1241
|
-
http;
|
|
1242
1453
|
moduleApiName;
|
|
1454
|
+
// ── Public writable signals ───────────────────────────────────────────────
|
|
1243
1455
|
searchTerm = signal('', ...(ngDevMode ? [{ debugName: "searchTerm" }] : []));
|
|
1244
|
-
filterData = signal({
|
|
1245
|
-
|
|
1246
|
-
filter: {},
|
|
1247
|
-
select: [],
|
|
1248
|
-
sort: {},
|
|
1249
|
-
}, ...(ngDevMode ? [{ debugName: "filterData" }] : []));
|
|
1456
|
+
filterData = signal({ ...DEFAULT_FILTER }, ...(ngDevMode ? [{ debugName: "filterData" }] : []));
|
|
1457
|
+
// ── Private activation gate: avoids an initial fetch before fetchList() ──
|
|
1250
1458
|
_active = signal(false, ...(ngDevMode ? [{ debugName: "_active" }] : []));
|
|
1459
|
+
// ── Resource (reactive list fetching with abort support) ──────────────────
|
|
1251
1460
|
listResource;
|
|
1461
|
+
// ── Derived/computed signals (pure reads, no side-effects) ────────────────
|
|
1252
1462
|
isLoading = computed(() => this.listResource.isLoading(), ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
1253
1463
|
data = computed(() => this.listResource.value()?.data ?? [], ...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
1254
1464
|
total = computed(() => this.listResource.value()?.meta?.total ?? 0, ...(ngDevMode ? [{ debugName: "total" }] : []));
|
|
@@ -1261,52 +1471,64 @@ class ApiResourceService {
|
|
|
1261
1471
|
}, ...(ngDevMode ? [{ debugName: "hasMore" }] : []));
|
|
1262
1472
|
error = computed(() => this.listResource.error(), ...(ngDevMode ? [{ debugName: "error" }] : []));
|
|
1263
1473
|
status = computed(() => this.listResource.status(), ...(ngDevMode ? [{ debugName: "status" }] : []));
|
|
1264
|
-
constructor(moduleApiName,
|
|
1265
|
-
this.moduleApiName = moduleApiName
|
|
1266
|
-
|
|
1267
|
-
const serviceBaseUrl = serviceName
|
|
1268
|
-
|
|
1269
|
-
|
|
1474
|
+
constructor(moduleApiName, serviceName) {
|
|
1475
|
+
this.moduleApiName = moduleApiName;
|
|
1476
|
+
// ── Resolve base URL once at construction, not per-request ───────────────
|
|
1477
|
+
const serviceBaseUrl = serviceName
|
|
1478
|
+
? getServiceUrl(this._config, serviceName)
|
|
1479
|
+
: this._config.apiBaseUrl;
|
|
1480
|
+
this.baseUrl = moduleApiName
|
|
1481
|
+
? `${serviceBaseUrl}/${moduleApiName}`
|
|
1482
|
+
: serviceBaseUrl;
|
|
1270
1483
|
this.listResource = resource({ ...(ngDevMode ? { debugName: "listResource" } : {}), params: () => {
|
|
1484
|
+
// Short-circuit: skip the loader entirely when not yet activated
|
|
1271
1485
|
if (!this._active())
|
|
1272
1486
|
return undefined;
|
|
1273
1487
|
return { search: this.searchTerm(), filter: this.filterData() };
|
|
1274
1488
|
},
|
|
1275
|
-
loader: ({ params, abortSignal }) =>
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1489
|
+
loader: ({ params, abortSignal }) =>
|
|
1490
|
+
// ── Inline promise keeps the closure tight; no temp variable needed ─
|
|
1491
|
+
new Promise((resolve, reject) => {
|
|
1492
|
+
const sub = this._getAllObs(params.filter, params.search).subscribe({
|
|
1493
|
+
next: resolve,
|
|
1494
|
+
error: reject,
|
|
1280
1495
|
});
|
|
1281
|
-
|
|
1496
|
+
abortSignal.addEventListener('abort', () => sub.unsubscribe());
|
|
1497
|
+
}) });
|
|
1282
1498
|
}
|
|
1499
|
+
// ── Single, memoised header builder – avoids object churn per call ────────
|
|
1283
1500
|
getHttpOptions(endpoint, params) {
|
|
1284
1501
|
return {
|
|
1285
|
-
headers: new HttpHeaders({
|
|
1502
|
+
headers: new HttpHeaders({
|
|
1503
|
+
'x-loader-tag': `${this.moduleApiName}/${endpoint}`,
|
|
1504
|
+
}),
|
|
1286
1505
|
...(params ? { params } : {}),
|
|
1287
1506
|
};
|
|
1288
1507
|
}
|
|
1508
|
+
// ── Private observable – shared by the resource loader and the public getAll() ──
|
|
1289
1509
|
_getAllObs(filter, search = '') {
|
|
1290
|
-
|
|
1291
|
-
if (search)
|
|
1292
|
-
params = params.append('q', search);
|
|
1510
|
+
const params = search ? new HttpParams().append('q', search) : undefined;
|
|
1293
1511
|
return this.http.post(`${this.baseUrl}/get-all`, filter, this.getHttpOptions('get-all', params));
|
|
1294
1512
|
}
|
|
1513
|
+
// ── Activate guard: all list-management helpers call this first ───────────
|
|
1514
|
+
_activate() {
|
|
1515
|
+
this._active.set(true);
|
|
1516
|
+
}
|
|
1295
1517
|
// ==========================================================================
|
|
1296
|
-
// List
|
|
1518
|
+
// List management
|
|
1297
1519
|
// ==========================================================================
|
|
1298
1520
|
fetchList(search = '', filter) {
|
|
1299
1521
|
this.searchTerm.set(search);
|
|
1300
1522
|
if (filter)
|
|
1301
1523
|
this.filterData.update((prev) => ({ ...prev, ...filter }));
|
|
1302
|
-
this.
|
|
1524
|
+
this._activate();
|
|
1303
1525
|
}
|
|
1304
1526
|
setPagination(pagination) {
|
|
1305
|
-
this.
|
|
1527
|
+
this._activate();
|
|
1306
1528
|
this.filterData.update((prev) => ({ ...prev, pagination }));
|
|
1307
1529
|
}
|
|
1308
1530
|
nextPage() {
|
|
1309
|
-
this.
|
|
1531
|
+
this._activate();
|
|
1310
1532
|
this.filterData.update((prev) => ({
|
|
1311
1533
|
...prev,
|
|
1312
1534
|
pagination: {
|
|
@@ -1316,7 +1538,7 @@ class ApiResourceService {
|
|
|
1316
1538
|
}));
|
|
1317
1539
|
}
|
|
1318
1540
|
resetPagination() {
|
|
1319
|
-
this.
|
|
1541
|
+
this._activate();
|
|
1320
1542
|
this.filterData.update((prev) => ({
|
|
1321
1543
|
...prev,
|
|
1322
1544
|
pagination: { currentPage: 0, pageSize: prev.pagination?.pageSize ?? 10 },
|
|
@@ -1326,131 +1548,107 @@ class ApiResourceService {
|
|
|
1326
1548
|
this.listResource.reload();
|
|
1327
1549
|
}
|
|
1328
1550
|
// ==========================================================================
|
|
1329
|
-
// Promise API
|
|
1551
|
+
// Promise API (IApiService implementation)
|
|
1330
1552
|
// ==========================================================================
|
|
1553
|
+
// ── DRY helper: all promise methods are one-liners via this ───────────────
|
|
1554
|
+
_post(endpoint, body, params) {
|
|
1555
|
+
return firstValueFrom(this.http.post(`${this.baseUrl}/${endpoint}`, body, this.getHttpOptions(endpoint, params)));
|
|
1556
|
+
}
|
|
1331
1557
|
insert(dto) {
|
|
1332
|
-
return
|
|
1558
|
+
return this._post('insert', dto);
|
|
1333
1559
|
}
|
|
1334
1560
|
insertMany(dtos) {
|
|
1335
|
-
return
|
|
1561
|
+
return this._post('insert-many', dtos);
|
|
1336
1562
|
}
|
|
1337
1563
|
findById(id, select) {
|
|
1338
|
-
return
|
|
1564
|
+
return this._post(`get/${id}`, { select });
|
|
1339
1565
|
}
|
|
1340
1566
|
getAll(filter, search = '') {
|
|
1341
1567
|
return firstValueFrom(this._getAllObs(filter, search));
|
|
1342
1568
|
}
|
|
1343
1569
|
update(dto) {
|
|
1344
|
-
return
|
|
1570
|
+
return this._post('update', dto);
|
|
1345
1571
|
}
|
|
1346
1572
|
updateMany(dtos) {
|
|
1347
|
-
return
|
|
1573
|
+
return this._post('update-many', dtos);
|
|
1348
1574
|
}
|
|
1349
|
-
|
|
1350
|
-
return
|
|
1575
|
+
delete(deleteDto) {
|
|
1576
|
+
return this._post('delete', deleteDto);
|
|
1351
1577
|
}
|
|
1352
|
-
|
|
1353
|
-
return
|
|
1578
|
+
findByIds(ids, select) {
|
|
1579
|
+
return this._post('get-by-ids', { ids, select });
|
|
1354
1580
|
}
|
|
1355
1581
|
getByFilter(filter) {
|
|
1356
|
-
return
|
|
1582
|
+
return this._post('get-by-filter', filter);
|
|
1357
1583
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1584
|
+
async bulkUpsert(toInsert, toUpdate) {
|
|
1585
|
+
const res = await this._post('bulk-upsert', [
|
|
1586
|
+
...toInsert,
|
|
1587
|
+
...toUpdate,
|
|
1588
|
+
]);
|
|
1589
|
+
return res.data ?? [];
|
|
1360
1590
|
}
|
|
1361
1591
|
}
|
|
1362
1592
|
|
|
1363
|
-
/**
|
|
1364
|
-
* Base class for form controls that support ALL Angular form patterns:
|
|
1365
|
-
*
|
|
1366
|
-
* 1. **Template-driven forms:** `[(value)]="mySignal"` or `[(ngModel)]="myValue"`
|
|
1367
|
-
* 2. **Reactive forms:** `[formControl]="ctrl"` or `formControlName="field"`
|
|
1368
|
-
* 3. **Signal forms (Angular 21+):** `[formField]="formTree.field"`
|
|
1369
|
-
*
|
|
1370
|
-
* Implements both `ControlValueAccessor` (reactive forms) and `FormValueControl` (signal forms).
|
|
1371
|
-
*
|
|
1372
|
-
* @example
|
|
1373
|
-
* ```typescript
|
|
1374
|
-
* @Component({
|
|
1375
|
-
* providers: [provideValueAccessor(MySelectComponent)]
|
|
1376
|
-
* })
|
|
1377
|
-
* export class MySelectComponent extends BaseFormControl<string | null> {
|
|
1378
|
-
* override readonly value = model<string | null>(null);
|
|
1379
|
-
*
|
|
1380
|
-
* constructor() {
|
|
1381
|
-
* super();
|
|
1382
|
-
* this.initializeFormControl();
|
|
1383
|
-
* }
|
|
1384
|
-
* }
|
|
1385
|
-
*
|
|
1386
|
-
* // Usage:
|
|
1387
|
-
* // Template-driven: <my-select [(value)]="selectedId" />
|
|
1388
|
-
* // Reactive forms: <my-select [formControl]="myControl" />
|
|
1389
|
-
* // Signal forms: <my-select [formField]="formTree.myField" />
|
|
1390
|
-
* ```
|
|
1391
|
-
*/
|
|
1392
1593
|
class BaseFormControl {
|
|
1393
1594
|
injector = inject(Injector);
|
|
1394
|
-
/**
|
|
1395
|
-
* Disabled state model - bound to form control disabled state.
|
|
1396
|
-
* Using model() to satisfy FormValueControl interface requirements.
|
|
1397
|
-
*/
|
|
1398
1595
|
disabled = model(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
1399
|
-
/**
|
|
1400
|
-
* Touched state model - for validation styling.
|
|
1401
|
-
* Using model() to satisfy FormValueControl interface requirements.
|
|
1402
|
-
*/
|
|
1403
1596
|
touched = model(false, ...(ngDevMode ? [{ debugName: "touched" }] : []));
|
|
1597
|
+
// ── CVA callbacks ─────────────────────────────────────────────────────────
|
|
1598
|
+
// Initialised to no-ops so subclasses never need null-guards
|
|
1404
1599
|
onChange = () => { };
|
|
1405
1600
|
onTouched = () => { };
|
|
1406
|
-
|
|
1601
|
+
// ── Write-guard: prevents echo loop (writeValue → effect → onChange) ──────
|
|
1602
|
+
// Using a counter instead of a boolean handles the (rare) re-entrant case
|
|
1603
|
+
writeDepth = 0;
|
|
1407
1604
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1605
|
+
* Wire up the ControlValueAccessor ↔ signal bridge.
|
|
1606
|
+
* Call once at the end of the subclass constructor.
|
|
1607
|
+
*
|
|
1608
|
+
* Signal-form consumers ([formField]) don't need this — Angular's
|
|
1609
|
+
* FormField directive binds directly to `value`.
|
|
1410
1610
|
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* constructor() { super(); this.initializeFormControl(); }
|
|
1413
1613
|
*/
|
|
1414
1614
|
initializeFormControl() {
|
|
1415
1615
|
runInInjectionContext(this.injector, () => {
|
|
1416
1616
|
effect(() => {
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1419
|
-
|
|
1617
|
+
const next = this.value();
|
|
1618
|
+
// Skip propagation while writeValue() is on the call stack
|
|
1619
|
+
if (this.writeDepth === 0) {
|
|
1620
|
+
untracked(() => this.onChange(next));
|
|
1420
1621
|
}
|
|
1421
1622
|
});
|
|
1422
1623
|
});
|
|
1423
1624
|
}
|
|
1424
|
-
//
|
|
1425
|
-
// ControlValueAccessor
|
|
1426
|
-
//
|
|
1427
|
-
// ============================================
|
|
1428
|
-
/** ControlValueAccessor: Write value from form control to signal */
|
|
1625
|
+
// ==========================================================================
|
|
1626
|
+
// ControlValueAccessor
|
|
1627
|
+
// ==========================================================================
|
|
1429
1628
|
writeValue(value) {
|
|
1430
|
-
this.
|
|
1431
|
-
|
|
1432
|
-
|
|
1629
|
+
this.writeDepth++;
|
|
1630
|
+
try {
|
|
1631
|
+
this.value.set(value);
|
|
1632
|
+
}
|
|
1633
|
+
finally {
|
|
1634
|
+
// Always decrement — even if set() throws — so the guard never sticks
|
|
1635
|
+
this.writeDepth--;
|
|
1636
|
+
}
|
|
1433
1637
|
}
|
|
1434
|
-
/** ControlValueAccessor: Register change callback */
|
|
1435
1638
|
registerOnChange(fn) {
|
|
1436
1639
|
this.onChange = fn;
|
|
1437
1640
|
}
|
|
1438
|
-
/** ControlValueAccessor: Register touched callback */
|
|
1439
1641
|
registerOnTouched(fn) {
|
|
1440
1642
|
this.onTouched = fn;
|
|
1441
1643
|
}
|
|
1442
|
-
/** ControlValueAccessor: Set disabled state from form control */
|
|
1443
1644
|
setDisabledState(isDisabled) {
|
|
1444
1645
|
this.disabled.set(isDisabled);
|
|
1445
1646
|
}
|
|
1446
|
-
//
|
|
1447
|
-
// FormValueControl
|
|
1448
|
-
//
|
|
1449
|
-
//
|
|
1450
|
-
|
|
1451
|
-
// - value: ModelSignal<T> (already declared as abstract above)
|
|
1452
|
-
// The FormField directive automatically binds to the value model.
|
|
1453
|
-
/** Mark the control as touched (call on blur or panel close) */
|
|
1647
|
+
// ==========================================================================
|
|
1648
|
+
// FormValueControl (signal forms)
|
|
1649
|
+
// `value: ModelSignal<T>` satisfies the interface — nothing else needed.
|
|
1650
|
+
// ==========================================================================
|
|
1651
|
+
/** Call on blur / panel-close to propagate touched state. */
|
|
1454
1652
|
markAsTouched() {
|
|
1455
1653
|
if (!this.touched()) {
|
|
1456
1654
|
this.touched.set(true);
|
|
@@ -1479,7 +1677,7 @@ function provideValueAccessor(component) {
|
|
|
1479
1677
|
return {
|
|
1480
1678
|
provide: NG_VALUE_ACCESSOR,
|
|
1481
1679
|
useExisting: forwardRef(() => component),
|
|
1482
|
-
multi: true
|
|
1680
|
+
multi: true,
|
|
1483
1681
|
};
|
|
1484
1682
|
}
|
|
1485
1683
|
|
|
@@ -1607,7 +1805,7 @@ function checkScrollPagination(event, config) {
|
|
|
1607
1805
|
|
|
1608
1806
|
class FileUploaderComponent {
|
|
1609
1807
|
messageService = inject(MessageService);
|
|
1610
|
-
translateAdapter = inject(
|
|
1808
|
+
translateAdapter = inject(TranslateService, {
|
|
1611
1809
|
optional: true,
|
|
1612
1810
|
});
|
|
1613
1811
|
fileProvider = inject(FILE_PROVIDER, { optional: true });
|
|
@@ -2069,7 +2267,7 @@ const DEFAULT_PAGE_SIZE$1 = 20;
|
|
|
2069
2267
|
const DEFAULT_SELECTOR_PAGE_SIZE = 50;
|
|
2070
2268
|
class FileSelectorDialogComponent {
|
|
2071
2269
|
destroyRef = inject(DestroyRef);
|
|
2072
|
-
translateAdapter = inject(
|
|
2270
|
+
translateAdapter = inject(TranslateService, {
|
|
2073
2271
|
optional: true,
|
|
2074
2272
|
});
|
|
2075
2273
|
fileProvider = inject(FILE_PROVIDER, { optional: true });
|
|
@@ -2965,7 +3163,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
2965
3163
|
class LazyMultiSelectComponent extends BaseFormControl {
|
|
2966
3164
|
document = inject(DOCUMENT$1);
|
|
2967
3165
|
appRef = inject(ApplicationRef);
|
|
2968
|
-
translateAdapter = inject(
|
|
3166
|
+
translateAdapter = inject(TranslateService, {
|
|
2969
3167
|
optional: true,
|
|
2970
3168
|
});
|
|
2971
3169
|
onDocumentClickBound = this.handleDocumentClick.bind(this);
|
|
@@ -3171,7 +3369,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
3171
3369
|
*/
|
|
3172
3370
|
class LazySelectComponent extends BaseFormControl {
|
|
3173
3371
|
destroyRef = inject(DestroyRef);
|
|
3174
|
-
translateAdapter = inject(
|
|
3372
|
+
translateAdapter = inject(TranslateService, {
|
|
3373
|
+
optional: true,
|
|
3374
|
+
});
|
|
3175
3375
|
onScrollBound = this.onScroll.bind(this);
|
|
3176
3376
|
scrollTargetEl = null;
|
|
3177
3377
|
isDestroyed = false;
|
|
@@ -3295,9 +3495,7 @@ class BaseUserSelectComponent {
|
|
|
3295
3495
|
destroyRef = inject(DestroyRef);
|
|
3296
3496
|
injector = inject(Injector);
|
|
3297
3497
|
userProvider = inject(USER_PROVIDER);
|
|
3298
|
-
translateAdapter = inject(
|
|
3299
|
-
optional: true,
|
|
3300
|
-
});
|
|
3498
|
+
translateAdapter = inject(TranslateService);
|
|
3301
3499
|
abortController = null;
|
|
3302
3500
|
// Inputs
|
|
3303
3501
|
loadUsers = input(...(ngDevMode ? [undefined, { debugName: "loadUsers" }] : []));
|
|
@@ -3775,7 +3973,7 @@ class BaseFormPage {
|
|
|
3775
3973
|
route = inject(ActivatedRoute);
|
|
3776
3974
|
messageService = inject(MessageService);
|
|
3777
3975
|
destroyRef = inject(DestroyRef);
|
|
3778
|
-
translateAdapter = inject(
|
|
3976
|
+
translateAdapter = inject(TranslateService, {
|
|
3779
3977
|
optional: true,
|
|
3780
3978
|
});
|
|
3781
3979
|
routeParams = toSignal(this.route.paramMap);
|
|
@@ -3911,7 +4109,9 @@ class BaseListPage {
|
|
|
3911
4109
|
appConfig = inject(APP_CONFIG);
|
|
3912
4110
|
confirmationService = inject(ConfirmationService);
|
|
3913
4111
|
destroyRef = inject(DestroyRef);
|
|
3914
|
-
translateAdapter = inject(
|
|
4112
|
+
translateAdapter = inject(TranslateService, {
|
|
4113
|
+
optional: true,
|
|
4114
|
+
});
|
|
3915
4115
|
/** Items list */
|
|
3916
4116
|
items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : []));
|
|
3917
4117
|
/** Loading state */
|
|
@@ -3961,25 +4161,41 @@ class BaseListPage {
|
|
|
3961
4161
|
* Show success toast message
|
|
3962
4162
|
*/
|
|
3963
4163
|
showSuccess(detail, summary) {
|
|
3964
|
-
this.messageService.add({
|
|
4164
|
+
this.messageService.add({
|
|
4165
|
+
severity: 'success',
|
|
4166
|
+
summary: summary ?? this.t('shared.success'),
|
|
4167
|
+
detail,
|
|
4168
|
+
});
|
|
3965
4169
|
}
|
|
3966
4170
|
/**
|
|
3967
4171
|
* Show error toast message
|
|
3968
4172
|
*/
|
|
3969
4173
|
showError(detail, summary) {
|
|
3970
|
-
this.messageService.add({
|
|
4174
|
+
this.messageService.add({
|
|
4175
|
+
severity: 'error',
|
|
4176
|
+
summary: summary ?? this.t('shared.error'),
|
|
4177
|
+
detail,
|
|
4178
|
+
});
|
|
3971
4179
|
}
|
|
3972
4180
|
/**
|
|
3973
4181
|
* Show info toast message
|
|
3974
4182
|
*/
|
|
3975
4183
|
showInfo(detail, summary) {
|
|
3976
|
-
this.messageService.add({
|
|
4184
|
+
this.messageService.add({
|
|
4185
|
+
severity: 'info',
|
|
4186
|
+
summary: summary ?? this.t('shared.info'),
|
|
4187
|
+
detail,
|
|
4188
|
+
});
|
|
3977
4189
|
}
|
|
3978
4190
|
/**
|
|
3979
4191
|
* Show warning toast message
|
|
3980
4192
|
*/
|
|
3981
4193
|
showWarn(detail, summary) {
|
|
3982
|
-
this.messageService.add({
|
|
4194
|
+
this.messageService.add({
|
|
4195
|
+
severity: 'warn',
|
|
4196
|
+
summary: summary ?? this.t('shared.warning'),
|
|
4197
|
+
detail,
|
|
4198
|
+
});
|
|
3983
4199
|
}
|
|
3984
4200
|
/**
|
|
3985
4201
|
* Translate a key using the adapter, fallback to key if not available.
|
|
@@ -4006,7 +4222,9 @@ class BaseListPage {
|
|
|
4006
4222
|
.subscribe({
|
|
4007
4223
|
next: (res) => {
|
|
4008
4224
|
const r = res;
|
|
4009
|
-
this.showSuccess(r?.messageKey
|
|
4225
|
+
this.showSuccess(r?.messageKey
|
|
4226
|
+
? this.t(r.messageKey, r.messageVariables)
|
|
4227
|
+
: (r?.message ?? ''));
|
|
4010
4228
|
this.loadData();
|
|
4011
4229
|
},
|
|
4012
4230
|
});
|
|
@@ -4029,7 +4247,9 @@ class BaseListPage {
|
|
|
4029
4247
|
accept: async () => {
|
|
4030
4248
|
const res = await deleteApiCall(idGetter(item));
|
|
4031
4249
|
const r = res;
|
|
4032
|
-
this.showSuccess(r?.messageKey
|
|
4250
|
+
this.showSuccess(r?.messageKey
|
|
4251
|
+
? this.t(r.messageKey, r.messageVariables)
|
|
4252
|
+
: (r?.message ?? ''));
|
|
4033
4253
|
await this.loadData();
|
|
4034
4254
|
},
|
|
4035
4255
|
});
|
|
@@ -4114,5 +4334,5 @@ function getUserTimezone() {
|
|
|
4114
4334
|
* Generated bundle index. Do not edit.
|
|
4115
4335
|
*/
|
|
4116
4336
|
|
|
4117
|
-
export { ACTION_PERMISSIONS, AUTH_STATE_PROVIDER, AngularModule, ApiResourceService, ApiResourceService as ApiService, BRANCH_PERMISSIONS, BaseFormControl, BaseFormPage, BaseListPage, BaseUserSelectComponent, COMPANY_ACTION_PERMISSIONS, COMPANY_API_PROVIDER, COMPANY_PERMISSIONS, CookieService, EMAIL_CONFIG_PERMISSIONS, EMAIL_TEMPLATE_PERMISSIONS,
|
|
4337
|
+
export { ACTION_PERMISSIONS, AUTH_STATE_PROVIDER, AngularModule, ApiResourceService, ApiResourceService as ApiService, BRANCH_PERMISSIONS, BaseFormControl, BaseFormPage, BaseListPage, BaseUserSelectComponent, COMPANY_ACTION_PERMISSIONS, COMPANY_API_PROVIDER, COMPANY_PERMISSIONS, CookieService, EMAIL_CONFIG_PERMISSIONS, EMAIL_TEMPLATE_PERMISSIONS, EVENT_PERMISSIONS, EditModeElementChangerDirective, FILE_PERMISSIONS, FILE_PROVIDER, FILE_TYPE_FILTERS, FOLDER_PERMISSIONS, FORM_PERMISSIONS, FORM_RESULT_PERMISSIONS, FileSelectorDialogComponent, FileUploaderComponent, FileUrlService, HasPermissionDirective, IconComponent, IconTypeEnum, IsEmptyImageDirective, LANGUAGE_PERMISSIONS, LazyMultiSelectComponent, LazySelectComponent, NOTIFICATION_PERMISSIONS, PERMISSIONS, PROFILE_PERMISSION_PROVIDER, PermissionValidatorService, PlatformService, PreventDefaultDirective, PrimeModule, ROLE_ACTION_PERMISSIONS, ROLE_PERMISSIONS, SHARED_MESSAGES, SKIP_ERROR_TOAST, STORAGE_CONFIG_PERMISSIONS, TRANSLATION_KEY_PERMISSIONS, TRANSLATION_PERMISSIONS, TranslatePipe, TranslateService, UPLOAD_CONFIG_PERMISSIONS, USER_ACTION_PERMISSIONS, USER_PERMISSIONS, USER_PERMISSION_PROVIDER, USER_PROVIDER, USER_ROLE_PERMISSIONS, UserMultiSelectComponent, UserSelectComponent, allPermissionsGuard, anyPermissionGuard, checkScrollPagination, errorCatchingInterceptor, evaluateLogicNode, evaluatePermission, formatFileSize, formatInTimezone, getAcceptString, getFileIconClass, getUserTimezone, hasAllPermissions, hasAnyPermission, hasPermission, isFileTypeAllowed, localToUtc, permissionGuard, provideValueAccessor, resolveTranslationModule, utcToLocal };
|
|
4118
4338
|
//# sourceMappingURL=flusys-ng-shared.mjs.map
|