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