@flusys/ng-shared 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
## Package Information
|
|
10
10
|
|
|
11
11
|
- **Package:** `@flusys/ng-shared`
|
|
12
|
+
- **Version:** 1.1.0
|
|
12
13
|
- **Dependencies:** ng-core
|
|
13
14
|
- **Dependents:** ng-layout, ng-auth, ng-iam, ng-storage, flusysng
|
|
14
15
|
- **Build Command:** `npm run build:ng-shared`
|
|
@@ -144,6 +145,7 @@ interface IFileUploadOptions {
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
interface IUploadedFile {
|
|
148
|
+
id?: string; // File manager ID (UUID) - available when registered
|
|
147
149
|
name: string;
|
|
148
150
|
key: string;
|
|
149
151
|
size: number;
|
|
@@ -310,7 +312,46 @@ enum IconTypeEnum {
|
|
|
310
312
|
|
|
311
313
|
---
|
|
312
314
|
|
|
313
|
-
## 3.
|
|
315
|
+
## 3. Constants
|
|
316
|
+
|
|
317
|
+
### Permission Constants
|
|
318
|
+
|
|
319
|
+
Centralized permission codes for type-safe permission checks. Single source of truth to prevent typos.
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { PERMISSIONS, USER_PERMISSIONS, ROLE_PERMISSIONS } from '@flusys/ng-shared';
|
|
323
|
+
|
|
324
|
+
// Use constants instead of strings
|
|
325
|
+
*hasPermission="PERMISSIONS.USER.READ"
|
|
326
|
+
|
|
327
|
+
// Individual permission groups available:
|
|
328
|
+
USER_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
329
|
+
COMPANY_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
330
|
+
BRANCH_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
331
|
+
ACTION_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
332
|
+
ROLE_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
333
|
+
ROLE_ACTION_PERMISSIONS // { READ, ASSIGN }
|
|
334
|
+
USER_ROLE_PERMISSIONS // { READ, ASSIGN }
|
|
335
|
+
USER_ACTION_PERMISSIONS // { READ, ASSIGN }
|
|
336
|
+
COMPANY_ACTION_PERMISSIONS // { READ, ASSIGN }
|
|
337
|
+
FILE_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
338
|
+
FOLDER_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
339
|
+
STORAGE_CONFIG_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
340
|
+
EMAIL_CONFIG_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
341
|
+
EMAIL_TEMPLATE_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
342
|
+
FORM_PERMISSIONS // { CREATE, READ, UPDATE, DELETE }
|
|
343
|
+
|
|
344
|
+
// Aggregated object with all permissions
|
|
345
|
+
PERMISSIONS.USER.READ // 'user.read'
|
|
346
|
+
PERMISSIONS.ROLE.CREATE // 'role.create'
|
|
347
|
+
PERMISSIONS.FILE.DELETE // 'file.delete'
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Type:** `PermissionCode` - Union type of all valid permission code strings.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 4. Services
|
|
314
355
|
|
|
315
356
|
### ApiResourceService
|
|
316
357
|
|
|
@@ -525,7 +566,7 @@ if (!platform.isServer) {
|
|
|
525
566
|
|
|
526
567
|
---
|
|
527
568
|
|
|
528
|
-
##
|
|
569
|
+
## 5. Components
|
|
529
570
|
|
|
530
571
|
### IconComponent
|
|
531
572
|
|
|
@@ -806,7 +847,7 @@ export class MyComponent {
|
|
|
806
847
|
|
|
807
848
|
---
|
|
808
849
|
|
|
809
|
-
##
|
|
850
|
+
## 6. Directives
|
|
810
851
|
|
|
811
852
|
### HasPermissionDirective
|
|
812
853
|
|
|
@@ -880,7 +921,7 @@ Prevents default browser behavior on specified events and emits the event.
|
|
|
880
921
|
|
|
881
922
|
---
|
|
882
923
|
|
|
883
|
-
##
|
|
924
|
+
## 7. Guards
|
|
884
925
|
|
|
885
926
|
Route-level guards for permission-based access control. All guards deny access when permissions are not loaded (fail-closed).
|
|
886
927
|
|
|
@@ -928,7 +969,7 @@ AND logic - allows access only if user has ALL specified permissions.
|
|
|
928
969
|
|
|
929
970
|
---
|
|
930
971
|
|
|
931
|
-
##
|
|
972
|
+
## 8. Utilities
|
|
932
973
|
|
|
933
974
|
### Permission Evaluator
|
|
934
975
|
|
|
@@ -951,9 +992,34 @@ hasAnyPermission(['user.view', 'user.delete'], userPermissions); // true (has u
|
|
|
951
992
|
hasAllPermissions(['user.view', 'user.delete'], userPermissions); // false (missing user.delete)
|
|
952
993
|
```
|
|
953
994
|
|
|
995
|
+
### Scroll Pagination
|
|
996
|
+
|
|
997
|
+
Utility for lazy-loading dropdowns with scroll detection.
|
|
998
|
+
|
|
999
|
+
```typescript
|
|
1000
|
+
import { checkScrollPagination, ScrollPaginationConfig } from '@flusys/ng-shared';
|
|
1001
|
+
|
|
1002
|
+
// In a component
|
|
1003
|
+
onScroll(event: Event): void {
|
|
1004
|
+
const nextPagination = checkScrollPagination(event, {
|
|
1005
|
+
pagination: this.pagination(),
|
|
1006
|
+
total: this.total(),
|
|
1007
|
+
isLoading: this.isLoading(),
|
|
1008
|
+
threshold: 50, // pixels from bottom (default: 50)
|
|
1009
|
+
});
|
|
1010
|
+
if (nextPagination) {
|
|
1011
|
+
this.onPagination.emit(nextPagination);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
**Interface:** `ScrollPaginationConfig` - `{ threshold?, pagination, total, isLoading }`
|
|
1017
|
+
|
|
1018
|
+
**Returns:** `IPagination | null` - Next page pagination or null if not needed.
|
|
1019
|
+
|
|
954
1020
|
---
|
|
955
1021
|
|
|
956
|
-
##
|
|
1022
|
+
## 9. Classes
|
|
957
1023
|
|
|
958
1024
|
### BaseFormControl
|
|
959
1025
|
|
|
@@ -989,9 +1055,78 @@ export class MySelectComponent extends BaseFormControl<string | null> {
|
|
|
989
1055
|
|
|
990
1056
|
**Helper:** `provideValueAccessor(ComponentClass)` - Factory for `NG_VALUE_ACCESSOR` provider
|
|
991
1057
|
|
|
1058
|
+
### BaseFormPage
|
|
1059
|
+
|
|
1060
|
+
Abstract directive for form page components (create/edit).
|
|
1061
|
+
|
|
1062
|
+
```typescript
|
|
1063
|
+
import { BaseFormPage } from '@flusys/ng-shared';
|
|
1064
|
+
|
|
1065
|
+
@Component({ ... })
|
|
1066
|
+
export class ProductFormComponent extends BaseFormPage<IProduct, IProductFormModel> {
|
|
1067
|
+
private readonly productService = inject(ProductApiService);
|
|
1068
|
+
private readonly _formModel = signal<IProductFormModel>({ name: '', price: 0 });
|
|
1069
|
+
readonly formModel = this._formModel.asReadonly();
|
|
1070
|
+
|
|
1071
|
+
getFormModel(): Signal<IProductFormModel> { return this.formModel; }
|
|
1072
|
+
getResourceRoute(): string { return '/products'; }
|
|
1073
|
+
getResourceName(): string { return 'Product'; }
|
|
1074
|
+
isFormValid(): boolean { return this.formModel().name.trim().length > 0; }
|
|
1075
|
+
|
|
1076
|
+
loadItem(id: string): void {
|
|
1077
|
+
this.productService.findById(id).subscribe(res => {
|
|
1078
|
+
if (res.success && res.data) {
|
|
1079
|
+
this.existingItem.set(res.data);
|
|
1080
|
+
this._formModel.set({ name: res.data.name, price: res.data.price });
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
createItem(model: IProductFormModel): Observable<unknown> {
|
|
1086
|
+
return this.productService.insert(model);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
updateItem(model: IProductFormModel): Observable<unknown> {
|
|
1090
|
+
return this.productService.update({ id: this.existingItem()!.id, ...model });
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
**Signals:** `isLoading`, `existingItem`, `isEditMode` (computed)
|
|
1096
|
+
|
|
1097
|
+
**Methods:** `onSubmit()`, `onCancel()`, `showSuccess()`, `showError()`, `showValidationError()`
|
|
1098
|
+
|
|
1099
|
+
### BaseListPage
|
|
1100
|
+
|
|
1101
|
+
Abstract directive for list page components with pagination and CRUD operations.
|
|
1102
|
+
|
|
1103
|
+
```typescript
|
|
1104
|
+
import { BaseListPage } from '@flusys/ng-shared';
|
|
1105
|
+
|
|
1106
|
+
@Component({ ... })
|
|
1107
|
+
export class UserListComponent extends BaseListPage<IUser> {
|
|
1108
|
+
private readonly userService = inject(UserApiService);
|
|
1109
|
+
|
|
1110
|
+
getResourceRoute(): string { return '/users'; }
|
|
1111
|
+
getDeleteConfirmMessage(user: IUser): string { return `Delete "${user.name}"?`; }
|
|
1112
|
+
|
|
1113
|
+
async loadData(): Promise<void> {
|
|
1114
|
+
this.isLoading.set(true);
|
|
1115
|
+
const res = await this.userService.findByIdAsync(...);
|
|
1116
|
+
this.items.set(res.data ?? []);
|
|
1117
|
+
this.total.set(res.meta?.total ?? 0);
|
|
1118
|
+
this.isLoading.set(false);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
**Signals:** `items`, `isLoading`, `total`, `pageSize`, `first`, `currentPage` (computed), `showCompanyInfo` (computed)
|
|
1124
|
+
|
|
1125
|
+
**Methods:** `onCreate()`, `onEdit(id)`, `onPageChange(event)`, `onDelete()`, `onDeleteAsync()`, `showSuccess()`, `showError()`, `showInfo()`, `showWarn()`
|
|
1126
|
+
|
|
992
1127
|
---
|
|
993
1128
|
|
|
994
|
-
##
|
|
1129
|
+
## 10. Modules
|
|
995
1130
|
|
|
996
1131
|
### AngularModule
|
|
997
1132
|
|
|
@@ -1015,7 +1150,7 @@ import { PrimeModule } from '@flusys/ng-shared';
|
|
|
1015
1150
|
|
|
1016
1151
|
---
|
|
1017
1152
|
|
|
1018
|
-
##
|
|
1153
|
+
## 11. Provider Interfaces (Package Independence)
|
|
1019
1154
|
|
|
1020
1155
|
ng-shared defines **provider interfaces** to enable feature packages (ng-iam, ng-storage) to access auth functionality without direct dependencies.
|
|
1021
1156
|
|
|
@@ -1336,6 +1471,25 @@ export const appConfig: ApplicationConfig = {
|
|
|
1336
1471
|
| `CookieService` | SSR-aware cookie reading |
|
|
1337
1472
|
| `PlatformService` | SSR environment detection |
|
|
1338
1473
|
|
|
1474
|
+
### Classes
|
|
1475
|
+
|
|
1476
|
+
| Class | Description |
|
|
1477
|
+
| ------------------------ | -------------------------------------------- |
|
|
1478
|
+
| `ApiResourceService` | Signal-based CRUD base class (alias: `ApiService`) |
|
|
1479
|
+
| `BaseFormControl` | Abstract base for custom form controls |
|
|
1480
|
+
| `BaseFormPage` | Abstract directive for create/edit pages |
|
|
1481
|
+
| `BaseListPage` | Abstract directive for list pages |
|
|
1482
|
+
|
|
1483
|
+
### Constants
|
|
1484
|
+
|
|
1485
|
+
| Constant | Description |
|
|
1486
|
+
| -------------- | --------------------------------------------- |
|
|
1487
|
+
| `PERMISSIONS` | Aggregated permission codes by module |
|
|
1488
|
+
| `USER_PERMISSIONS` | `{ CREATE, READ, UPDATE, DELETE }` for users |
|
|
1489
|
+
| `ROLE_PERMISSIONS` | `{ CREATE, READ, UPDATE, DELETE }` for roles |
|
|
1490
|
+
| `FILE_PERMISSIONS` | `{ CREATE, READ, UPDATE, DELETE }` for files |
|
|
1491
|
+
| `FILE_TYPE_FILTERS` | Predefined MIME type arrays (IMAGES, DOCUMENTS, etc.) |
|
|
1492
|
+
|
|
1339
1493
|
### Components
|
|
1340
1494
|
|
|
1341
1495
|
| Component | Selector | Description |
|
|
@@ -1416,5 +1570,6 @@ export const appConfig: ApplicationConfig = {
|
|
|
1416
1570
|
|
|
1417
1571
|
---
|
|
1418
1572
|
|
|
1419
|
-
**Last Updated:** 2026-02-
|
|
1573
|
+
**Last Updated:** 2026-02-23
|
|
1574
|
+
**Version:** 1.1.0
|
|
1420
1575
|
**Angular Version:** 21
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/ng-shared",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared components and utilities for FLUSYS Angular packages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@angular/common": ">=21.0.0",
|
|
8
8
|
"@angular/core": ">=21.0.0",
|
|
9
9
|
"@angular/forms": ">=21.0.0",
|
|
10
|
-
"@flusys/ng-core": ">=1.0
|
|
10
|
+
"@flusys/ng-core": ">=1.1.0",
|
|
11
11
|
"@primeuix/themes": ">=1.0.0",
|
|
12
12
|
"primeicons": ">=7.0.0",
|
|
13
13
|
"primeng": ">=21.0.0"
|