@flusys/ng-iam 9.1.0 → 9.1.2

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.
Files changed (37) hide show
  1. package/fesm2022/flusys-ng-iam-action-form-page.component-DJ-A1gc2.mjs +685 -0
  2. package/fesm2022/flusys-ng-iam-action-form-page.component-DJ-A1gc2.mjs.map +1 -0
  3. package/fesm2022/{flusys-ng-iam-action-list-page.component-Cf4Dhh5S.mjs → flusys-ng-iam-action-list-page.component-Br0PbgRa.mjs} +369 -166
  4. package/fesm2022/flusys-ng-iam-action-list-page.component-Br0PbgRa.mjs.map +1 -0
  5. package/fesm2022/flusys-ng-iam-iam-container.component-CIdxVCSW.mjs +141 -0
  6. package/fesm2022/flusys-ng-iam-iam-container.component-CIdxVCSW.mjs.map +1 -0
  7. package/fesm2022/flusys-ng-iam-permission-api.service-C7-Yxvz8.mjs +76 -0
  8. package/fesm2022/flusys-ng-iam-permission-api.service-C7-Yxvz8.mjs.map +1 -0
  9. package/fesm2022/flusys-ng-iam-permission-page.component-BlNt83uR.mjs +306 -0
  10. package/fesm2022/flusys-ng-iam-permission-page.component-BlNt83uR.mjs.map +1 -0
  11. package/fesm2022/flusys-ng-iam-role-api.service-OwPgmSFc.mjs +33 -0
  12. package/fesm2022/flusys-ng-iam-role-api.service-OwPgmSFc.mjs.map +1 -0
  13. package/fesm2022/flusys-ng-iam-role-form-page.component-DnkWkbTF.mjs +427 -0
  14. package/fesm2022/flusys-ng-iam-role-form-page.component-DnkWkbTF.mjs.map +1 -0
  15. package/fesm2022/flusys-ng-iam-role-list-page.component-BCO_gQ8k.mjs +685 -0
  16. package/fesm2022/flusys-ng-iam-role-list-page.component-BCO_gQ8k.mjs.map +1 -0
  17. package/fesm2022/flusys-ng-iam-tree-utils-B1pBG4At.mjs +110 -0
  18. package/fesm2022/flusys-ng-iam-tree-utils-B1pBG4At.mjs.map +1 -0
  19. package/fesm2022/flusys-ng-iam-user-action-selector.component-CAXEmJWx.mjs +4592 -0
  20. package/fesm2022/flusys-ng-iam-user-action-selector.component-CAXEmJWx.mjs.map +1 -0
  21. package/fesm2022/flusys-ng-iam.mjs +2051 -2
  22. package/fesm2022/flusys-ng-iam.mjs.map +1 -1
  23. package/package.json +5 -5
  24. package/types/flusys-ng-iam.d.ts +621 -604
  25. package/fesm2022/flusys-ng-iam-action-form-page.component-Dn0TD1Zu.mjs +0 -509
  26. package/fesm2022/flusys-ng-iam-action-form-page.component-Dn0TD1Zu.mjs.map +0 -1
  27. package/fesm2022/flusys-ng-iam-action-list-page.component-Cf4Dhh5S.mjs.map +0 -1
  28. package/fesm2022/flusys-ng-iam-flusys-ng-iam-Y7U2lGZk.mjs +0 -5584
  29. package/fesm2022/flusys-ng-iam-flusys-ng-iam-Y7U2lGZk.mjs.map +0 -1
  30. package/fesm2022/flusys-ng-iam-iam-container.component-XBoIeQ0t.mjs +0 -105
  31. package/fesm2022/flusys-ng-iam-iam-container.component-XBoIeQ0t.mjs.map +0 -1
  32. package/fesm2022/flusys-ng-iam-permission-page.component-CCAQuZSJ.mjs +0 -204
  33. package/fesm2022/flusys-ng-iam-permission-page.component-CCAQuZSJ.mjs.map +0 -1
  34. package/fesm2022/flusys-ng-iam-role-form-page.component-EFjxhBRY.mjs +0 -352
  35. package/fesm2022/flusys-ng-iam-role-form-page.component-EFjxhBRY.mjs.map +0 -1
  36. package/fesm2022/flusys-ng-iam-role-list-page.component-DBfhjdkM.mjs +0 -486
  37. package/fesm2022/flusys-ng-iam-role-list-page.component-DBfhjdkM.mjs.map +0 -1
@@ -0,0 +1,427 @@
1
+ import { t as RoleApiService } from "./flusys-ng-iam-role-api.service-OwPgmSFc.mjs";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, computed, effect, inject, signal } from "@angular/core";
4
+ import { TranslatePipe, TranslateService } from "@flusys/ng-shared";
5
+ import { APP_CONFIG, isCompanyFeatureEnabled } from "@flusys/ng-core";
6
+ import { CheckboxComponent, FButtonDirective, InputTextDirective, MessageService, UiIconComponent } from "@flusys/ng-ui";
7
+ import { LAYOUT_AUTH_STATE } from "@flusys/ng-layout";
8
+ import { toSignal } from "@angular/core/rxjs-interop";
9
+ import { FormField, form, required } from "@angular/forms/signals";
10
+ import { ActivatedRoute, Router } from "@angular/router";
11
+ var RoleFormPageComponent = class RoleFormPageComponent {
12
+ route = inject(ActivatedRoute);
13
+ router = inject(Router);
14
+ appConfig = inject(APP_CONFIG);
15
+ companyContext = inject(LAYOUT_AUTH_STATE);
16
+ roleApi = inject(RoleApiService);
17
+ messageService = inject(MessageService);
18
+ translateAdapter = inject(TranslateService, { optional: true });
19
+ routeParams = toSignal(this.route.paramMap);
20
+ initialized = false;
21
+ translate(key, vars) {
22
+ return this.translateAdapter?.translate(key, vars) ?? key;
23
+ }
24
+ isLoading = signal(false, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
25
+ existingRole = signal(null, ...ngDevMode ? [{ debugName: "existingRole" }] : /* istanbul ignore next */ []);
26
+ isEditMode = computed(() => !!this.existingRole(), ...ngDevMode ? [{ debugName: "isEditMode" }] : /* istanbul ignore next */ []);
27
+ formModel = signal({
28
+ id: "",
29
+ name: "",
30
+ description: "",
31
+ serial: "",
32
+ isActive: true
33
+ }, ...ngDevMode ? [{ debugName: "formModel" }] : /* istanbul ignore next */ []);
34
+ roleForm = form(this.formModel, (f) => {
35
+ required(f.name, { message: this.translate("shared.validation.required", { field: this.translate("iam.role.name") }) });
36
+ });
37
+ isFormValid = computed(() => {
38
+ return this.formModel().name.trim().length > 0;
39
+ }, ...ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []);
40
+ constructor() {
41
+ effect(() => {
42
+ const params = this.routeParams();
43
+ if (!params || this.initialized) return;
44
+ this.initialized = true;
45
+ const id = params.get("id");
46
+ if (id && id !== "new") this.loadRole(id);
47
+ });
48
+ }
49
+ async loadRole(id) {
50
+ this.isLoading.set(true);
51
+ try {
52
+ const role = (await this.roleApi.findById(id))?.data;
53
+ if (role?.readOnly) {
54
+ this.messageService.add({
55
+ severity: "error",
56
+ summary: this.translate("shared.error"),
57
+ detail: this.translate("iam.role.readonly.edit.forbidden")
58
+ });
59
+ this.router.navigate(["/iam/roles"]);
60
+ return;
61
+ }
62
+ if (role) {
63
+ this.existingRole.set(role);
64
+ this.formModel.set({
65
+ id: role.id,
66
+ name: role.name,
67
+ description: role.description ?? "",
68
+ serial: role.serial?.toString() ?? "",
69
+ isActive: role.isActive
70
+ });
71
+ } else this.router.navigate(["/iam/roles"]);
72
+ } catch {
73
+ this.router.navigate(["/iam/roles"]);
74
+ } finally {
75
+ this.isLoading.set(false);
76
+ }
77
+ }
78
+ async onSubmit(event) {
79
+ event.preventDefault();
80
+ if (!this.isFormValid()) {
81
+ this.messageService.add({
82
+ severity: "error",
83
+ summary: this.translate("shared.validation.error"),
84
+ detail: this.translate("shared.fill.required.fields")
85
+ });
86
+ return;
87
+ }
88
+ this.isLoading.set(true);
89
+ try {
90
+ const formValue = this.formModel();
91
+ const companyId = isCompanyFeatureEnabled(this.appConfig) ? this.companyContext.currentCompanyInfo()?.id || void 0 : void 0;
92
+ const dto = {
93
+ ...formValue,
94
+ description: formValue.description || void 0,
95
+ serial: formValue.serial ? parseInt(formValue.serial, 10) : void 0,
96
+ companyId: this.isEditMode() ? void 0 : companyId
97
+ };
98
+ const response = this.isEditMode() ? await this.roleApi.update(dto) : await this.roleApi.insert(dto);
99
+ this.messageService.add({
100
+ severity: "success",
101
+ summary: this.translate("shared.success"),
102
+ detail: response.messageKey ? this.translate(response.messageKey, response.messageVariables) : response.message ?? ""
103
+ });
104
+ this.router.navigate(["/iam/roles"]);
105
+ } catch {} finally {
106
+ this.isLoading.set(false);
107
+ }
108
+ }
109
+ onBack() {
110
+ this.router.navigate(["/iam/roles"]);
111
+ }
112
+ static ɵfac = i0.ɵɵngDeclareFactory({
113
+ minVersion: "12.0.0",
114
+ version: "22.2.1",
115
+ ngImport: i0,
116
+ type: RoleFormPageComponent,
117
+ deps: [],
118
+ target: i0.ɵɵFactoryTarget.Component
119
+ });
120
+ static ɵcmp = i0.ɵɵngDeclareComponent({
121
+ minVersion: "17.0.0",
122
+ version: "22.2.1",
123
+ type: RoleFormPageComponent,
124
+ isStandalone: true,
125
+ selector: "lib-role-form-page",
126
+ ngImport: i0,
127
+ template: `
128
+ <div class="card">
129
+ <h3 class="text-lg sm:text-xl font-semibold mb-4">
130
+ {{
131
+ isEditMode()
132
+ ? ('iam.role.edit' | translate)
133
+ : ('iam.role.new' | translate)
134
+ }}
135
+ </h3>
136
+
137
+ <form
138
+ (submit)="onSubmit($event)"
139
+ class="grid grid-cols-1 md:grid-cols-2 gap-4"
140
+ >
141
+ <!-- Name -->
142
+ <div class="flex flex-col gap-2">
143
+ <label for="name" class="font-medium"
144
+ >{{ 'iam.role.name' | translate }} *</label
145
+ >
146
+ <input
147
+ fInputText
148
+ id="name"
149
+ [formField]="roleForm.name"
150
+ [placeholder]="'iam.role.name.placeholder' | translate"
151
+ />
152
+ </div>
153
+
154
+ <!-- Description -->
155
+ <div class="flex flex-col gap-2">
156
+ <label for="description" class="font-medium">{{
157
+ 'shared.description' | translate
158
+ }}</label>
159
+ <input
160
+ fInputText
161
+ id="description"
162
+ [formField]="roleForm.description"
163
+ [placeholder]="'shared.description.placeholder' | translate"
164
+ />
165
+ </div>
166
+
167
+ <!-- Order -->
168
+ <div class="flex flex-col gap-2">
169
+ <label for="serial" class="font-medium">{{
170
+ 'shared.display.order' | translate
171
+ }}</label>
172
+ <input
173
+ fInputText
174
+ id="serial"
175
+ type="number"
176
+ [formField]="roleForm.serial"
177
+ [placeholder]="'shared.display.order.placeholder' | translate"
178
+ />
179
+ </div>
180
+
181
+ <!-- Is Active -->
182
+ <div class="flex items-end gap-2 pb-1">
183
+ <f-checkbox
184
+ [formField]="roleForm.isActive"
185
+ [binary]="true"
186
+ inputId="isActive"
187
+ />
188
+ <label for="isActive">{{ 'shared.active' | translate }}</label>
189
+ </div>
190
+
191
+ <!-- Actions -->
192
+ <div class="flex justify-end gap-2 md:col-span-2 pt-4">
193
+ <button
194
+ fButton
195
+ type="button"
196
+ severity="secondary"
197
+ [outlined]="true"
198
+ (click)="onBack()"
199
+ >
200
+ <span pButtonLabel>{{ 'shared.cancel' | translate }}</span>
201
+ </button>
202
+ <button
203
+ fButton
204
+ type="submit"
205
+ [disabled]="!isFormValid() || isLoading()"
206
+ >
207
+ @if (isLoading()) {
208
+ <ui-icon pButtonIcon name="spinner" [spin]="true"></ui-icon>
209
+ }
210
+ <span pButtonLabel>{{
211
+ isEditMode()
212
+ ? ('shared.update' | translate)
213
+ : ('shared.create' | translate)
214
+ }}</span>
215
+ </button>
216
+ </div>
217
+ </form>
218
+ </div>
219
+ `,
220
+ isInline: true,
221
+ dependencies: [
222
+ {
223
+ kind: "component",
224
+ type: CheckboxComponent,
225
+ selector: "f-checkbox",
226
+ inputs: [
227
+ "label",
228
+ "binary",
229
+ "disabled",
230
+ "readonly",
231
+ "inputId",
232
+ "invalid",
233
+ "indeterminate",
234
+ "variant",
235
+ "size",
236
+ "touched",
237
+ "styleClass",
238
+ "style",
239
+ "checked"
240
+ ],
241
+ outputs: [
242
+ "onChange",
243
+ "onBlur",
244
+ "touch",
245
+ "checkedChange"
246
+ ]
247
+ },
248
+ {
249
+ kind: "directive",
250
+ type: FButtonDirective,
251
+ selector: "[fButton]",
252
+ inputs: [
253
+ "severity",
254
+ "text",
255
+ "outlined",
256
+ "link",
257
+ "variant",
258
+ "rounded",
259
+ "raised",
260
+ "fluid",
261
+ "disabled",
262
+ "loading",
263
+ "loadingIcon",
264
+ "size",
265
+ "label",
266
+ "icon",
267
+ "iconPos",
268
+ "ariaLabel",
269
+ "plain"
270
+ ]
271
+ },
272
+ {
273
+ kind: "directive",
274
+ type: InputTextDirective,
275
+ selector: "[fInputText]",
276
+ inputs: [
277
+ "invalid",
278
+ "touched",
279
+ "variant",
280
+ "size",
281
+ "fluid"
282
+ ]
283
+ },
284
+ {
285
+ kind: "component",
286
+ type: UiIconComponent,
287
+ selector: "ui-icon",
288
+ inputs: [
289
+ "name",
290
+ "size",
291
+ "spin",
292
+ "fill",
293
+ "severity"
294
+ ]
295
+ },
296
+ {
297
+ kind: "directive",
298
+ type: FormField,
299
+ selector: "[formField]",
300
+ inputs: ["formField"],
301
+ exportAs: ["formField"]
302
+ },
303
+ {
304
+ kind: "pipe",
305
+ type: TranslatePipe,
306
+ name: "translate"
307
+ }
308
+ ]
309
+ });
310
+ };
311
+ i0.ɵɵngDeclareClassMetadata({
312
+ minVersion: "12.0.0",
313
+ version: "22.2.1",
314
+ ngImport: i0,
315
+ type: RoleFormPageComponent,
316
+ decorators: [{
317
+ type: Component,
318
+ args: [{
319
+ selector: "lib-role-form-page",
320
+ imports: [
321
+ CheckboxComponent,
322
+ FButtonDirective,
323
+ InputTextDirective,
324
+ UiIconComponent,
325
+ FormField,
326
+ TranslatePipe
327
+ ],
328
+ template: `
329
+ <div class="card">
330
+ <h3 class="text-lg sm:text-xl font-semibold mb-4">
331
+ {{
332
+ isEditMode()
333
+ ? ('iam.role.edit' | translate)
334
+ : ('iam.role.new' | translate)
335
+ }}
336
+ </h3>
337
+
338
+ <form
339
+ (submit)="onSubmit($event)"
340
+ class="grid grid-cols-1 md:grid-cols-2 gap-4"
341
+ >
342
+ <!-- Name -->
343
+ <div class="flex flex-col gap-2">
344
+ <label for="name" class="font-medium"
345
+ >{{ 'iam.role.name' | translate }} *</label
346
+ >
347
+ <input
348
+ fInputText
349
+ id="name"
350
+ [formField]="roleForm.name"
351
+ [placeholder]="'iam.role.name.placeholder' | translate"
352
+ />
353
+ </div>
354
+
355
+ <!-- Description -->
356
+ <div class="flex flex-col gap-2">
357
+ <label for="description" class="font-medium">{{
358
+ 'shared.description' | translate
359
+ }}</label>
360
+ <input
361
+ fInputText
362
+ id="description"
363
+ [formField]="roleForm.description"
364
+ [placeholder]="'shared.description.placeholder' | translate"
365
+ />
366
+ </div>
367
+
368
+ <!-- Order -->
369
+ <div class="flex flex-col gap-2">
370
+ <label for="serial" class="font-medium">{{
371
+ 'shared.display.order' | translate
372
+ }}</label>
373
+ <input
374
+ fInputText
375
+ id="serial"
376
+ type="number"
377
+ [formField]="roleForm.serial"
378
+ [placeholder]="'shared.display.order.placeholder' | translate"
379
+ />
380
+ </div>
381
+
382
+ <!-- Is Active -->
383
+ <div class="flex items-end gap-2 pb-1">
384
+ <f-checkbox
385
+ [formField]="roleForm.isActive"
386
+ [binary]="true"
387
+ inputId="isActive"
388
+ />
389
+ <label for="isActive">{{ 'shared.active' | translate }}</label>
390
+ </div>
391
+
392
+ <!-- Actions -->
393
+ <div class="flex justify-end gap-2 md:col-span-2 pt-4">
394
+ <button
395
+ fButton
396
+ type="button"
397
+ severity="secondary"
398
+ [outlined]="true"
399
+ (click)="onBack()"
400
+ >
401
+ <span pButtonLabel>{{ 'shared.cancel' | translate }}</span>
402
+ </button>
403
+ <button
404
+ fButton
405
+ type="submit"
406
+ [disabled]="!isFormValid() || isLoading()"
407
+ >
408
+ @if (isLoading()) {
409
+ <ui-icon pButtonIcon name="spinner" [spin]="true"></ui-icon>
410
+ }
411
+ <span pButtonLabel>{{
412
+ isEditMode()
413
+ ? ('shared.update' | translate)
414
+ : ('shared.create' | translate)
415
+ }}</span>
416
+ </button>
417
+ </div>
418
+ </form>
419
+ </div>
420
+ `
421
+ }]
422
+ }],
423
+ ctorParameters: () => []
424
+ });
425
+ export { RoleFormPageComponent };
426
+
427
+ //# sourceMappingURL=flusys-ng-iam-role-form-page.component-DnkWkbTF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusys-ng-iam-role-form-page.component-DnkWkbTF.mjs","names":[],"sources":["../../../projects/ng-iam/pages/role/role-form-page.component.ts"],"sourcesContent":["import { Component, computed, effect, inject, signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { form, FormField, required } from '@angular/forms/signals';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { APP_CONFIG, isCompanyFeatureEnabled } from '@flusys/ng-core';\nimport { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';\nimport {\n CheckboxComponent,\n FButtonDirective,\n InputTextDirective,\n MessageService,\n UiIconComponent,\n} from '@flusys/ng-ui';\nimport {\n TranslatePipe,\n TranslateService,\n} from '@flusys/ng-shared';\nimport { IRole } from '../../interfaces/role.interface';\nimport { RoleApiService } from '../../services/role-api.service';\n\ninterface IRoleFormModel {\n id: string;\n name: string;\n description: string;\n serial: string;\n isActive: boolean;\n}\n\n@Component({\n selector: 'lib-role-form-page',\n imports: [\n CheckboxComponent,\n FButtonDirective,\n InputTextDirective,\n UiIconComponent,\n FormField,\n TranslatePipe,\n ],\n template: `\n <div class=\"card\">\n <h3 class=\"text-lg sm:text-xl font-semibold mb-4\">\n {{\n isEditMode()\n ? ('iam.role.edit' | translate)\n : ('iam.role.new' | translate)\n }}\n </h3>\n\n <form\n (submit)=\"onSubmit($event)\"\n class=\"grid grid-cols-1 md:grid-cols-2 gap-4\"\n >\n <!-- Name -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"name\" class=\"font-medium\"\n >{{ 'iam.role.name' | translate }} *</label\n >\n <input\n fInputText\n id=\"name\"\n [formField]=\"roleForm.name\"\n [placeholder]=\"'iam.role.name.placeholder' | translate\"\n />\n </div>\n\n <!-- Description -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"description\" class=\"font-medium\">{{\n 'shared.description' | translate\n }}</label>\n <input\n fInputText\n id=\"description\"\n [formField]=\"roleForm.description\"\n [placeholder]=\"'shared.description.placeholder' | translate\"\n />\n </div>\n\n <!-- Order -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"serial\" class=\"font-medium\">{{\n 'shared.display.order' | translate\n }}</label>\n <input\n fInputText\n id=\"serial\"\n type=\"number\"\n [formField]=\"roleForm.serial\"\n [placeholder]=\"'shared.display.order.placeholder' | translate\"\n />\n </div>\n\n <!-- Is Active -->\n <div class=\"flex items-end gap-2 pb-1\">\n <f-checkbox\n [formField]=\"roleForm.isActive\"\n [binary]=\"true\"\n inputId=\"isActive\"\n />\n <label for=\"isActive\">{{ 'shared.active' | translate }}</label>\n </div>\n\n <!-- Actions -->\n <div class=\"flex justify-end gap-2 md:col-span-2 pt-4\">\n <button\n fButton\n type=\"button\"\n severity=\"secondary\"\n [outlined]=\"true\"\n (click)=\"onBack()\"\n >\n <span pButtonLabel>{{ 'shared.cancel' | translate }}</span>\n </button>\n <button\n fButton\n type=\"submit\"\n [disabled]=\"!isFormValid() || isLoading()\"\n >\n @if (isLoading()) {\n <ui-icon pButtonIcon name=\"spinner\" [spin]=\"true\"></ui-icon>\n }\n <span pButtonLabel>{{ \n isEditMode()\n ? ('shared.update' | translate)\n : ('shared.create' | translate)\n }}</span>\n </button>\n </div>\n </form>\n </div>\n `,\n})\nexport class RoleFormPageComponent {\n private readonly route = inject(ActivatedRoute);\n private readonly router = inject(Router);\n private readonly appConfig = inject(APP_CONFIG);\n private readonly companyContext = inject(LAYOUT_AUTH_STATE);\n private readonly roleApi = inject(RoleApiService);\n private readonly messageService = inject(MessageService);\n private readonly translateAdapter = inject(TranslateService, {\n optional: true,\n });\n\n private readonly routeParams = toSignal(this.route.paramMap);\n private initialized = false;\n\n private translate(\n key: string,\n vars?: Record<string, string | number>,\n ): string {\n return this.translateAdapter?.translate(key, vars) ?? key;\n }\n\n readonly isLoading = signal(false);\n readonly existingRole = signal<IRole | null>(null);\n readonly isEditMode = computed(() => !!this.existingRole());\n\n readonly formModel = signal<IRoleFormModel>({\n id: '',\n name: '',\n description: '',\n serial: '',\n isActive: true,\n });\n\n readonly roleForm = form(this.formModel, (f) => {\n required(f.name, {\n message: this.translate('shared.validation.required', {\n field: this.translate('iam.role.name'),\n }),\n });\n });\n\n readonly isFormValid = computed(() => {\n const model = this.formModel();\n return model.name.trim().length > 0;\n });\n\n constructor() {\n effect(() => {\n const params = this.routeParams();\n if (!params || this.initialized) return;\n\n this.initialized = true;\n const id = params.get('id');\n if (id && id !== 'new') {\n this.loadRole(id);\n }\n });\n }\n\n async loadRole(id: string): Promise<void> {\n this.isLoading.set(true);\n try {\n const response = await this.roleApi.findById(id);\n const role = response?.data;\n\n if (role?.readOnly) {\n this.messageService.add({\n severity: 'error',\n summary: this.translate('shared.error'),\n detail: this.translate('iam.role.readonly.edit.forbidden'),\n });\n this.router.navigate(['/iam/roles']);\n return;\n }\n\n if (role) {\n this.existingRole.set(role);\n this.formModel.set({\n id: role.id,\n name: role.name,\n description: role.description ?? '',\n serial: role.serial?.toString() ?? '',\n isActive: role.isActive,\n });\n } else {\n // Error toast handled by global interceptor\n this.router.navigate(['/iam/roles']);\n }\n } catch {\n // Error toast handled by global interceptor\n this.router.navigate(['/iam/roles']);\n } finally {\n this.isLoading.set(false);\n }\n }\n\n async onSubmit(event: Event): Promise<void> {\n event.preventDefault();\n\n if (!this.isFormValid()) {\n this.messageService.add({\n severity: 'error',\n summary: this.translate('shared.validation.error'),\n detail: this.translate('shared.fill.required.fields'),\n });\n return;\n }\n\n this.isLoading.set(true);\n\n try {\n const formValue = this.formModel();\n\n // Get company context if feature enabled\n const companyId = isCompanyFeatureEnabled(this.appConfig)\n ? this.companyContext.currentCompanyInfo()?.id || undefined\n : undefined;\n\n // Convert empty strings to undefined for DTO compatibility\n const dto = {\n ...formValue,\n description: formValue.description || undefined,\n serial: formValue.serial ? parseInt(formValue.serial, 10) : undefined,\n companyId: this.isEditMode() ? undefined : companyId,\n };\n\n const response = this.isEditMode()\n ? await this.roleApi.update(dto)\n : await this.roleApi.insert(dto);\n\n this.messageService.add({\n severity: 'success',\n summary: this.translate('shared.success'),\n detail: response.messageKey\n ? this.translate(\n response.messageKey,\n response.messageVariables as Record<string, string | number>,\n )\n : (response.message ?? ''),\n });\n\n this.router.navigate(['/iam/roles']);\n } catch {\n // Error toast handled by global interceptor\n } finally {\n this.isLoading.set(false);\n }\n }\n\n onBack(): void {\n this.router.navigate(['/iam/roles']);\n }\n}\n"],"mappings":";;;;;;;;;;AAoIA,IAAa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