@flusys/ng-iam 1.1.0 → 1.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -1179
- package/fesm2022/flusys-ng-iam-action-form-page.component-Vc5Toouu.mjs +502 -0
- package/fesm2022/flusys-ng-iam-action-form-page.component-Vc5Toouu.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-UGKclpFx.mjs +348 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-UGKclpFx.mjs.map +1 -0
- package/fesm2022/{flusys-ng-iam-flusys-ng-iam-CJAQT60K.mjs → flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs} +1814 -1622
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-D0m8u6nu.mjs +105 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-D0m8u6nu.mjs.map +1 -0
- package/fesm2022/{flusys-ng-iam-permission-page.component-DcgT7L3_.mjs → flusys-ng-iam-permission-page.component-x88X4AgJ.mjs} +38 -32
- package/fesm2022/flusys-ng-iam-permission-page.component-x88X4AgJ.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-role-form-page.component-InsxdriD.mjs +335 -0
- package/fesm2022/flusys-ng-iam-role-form-page.component-InsxdriD.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-8NGXCeSZ.mjs +389 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-8NGXCeSZ.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam.mjs +1 -1
- package/package.json +11 -10
- package/types/flusys-ng-iam.d.ts +53 -252
- package/fesm2022/flusys-ng-iam-action-form-page.component-eXpZNJ_H.mjs +0 -389
- package/fesm2022/flusys-ng-iam-action-form-page.component-eXpZNJ_H.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-action-list-page.component-BtJlGcTj.mjs +0 -262
- package/fesm2022/flusys-ng-iam-action-list-page.component-BtJlGcTj.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-CJAQT60K.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-iam-container.component-UYJjqYV9.mjs +0 -92
- package/fesm2022/flusys-ng-iam-iam-container.component-UYJjqYV9.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-permission-page.component-DcgT7L3_.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-role-form-page.component-D_AAEay2.mjs +0 -272
- package/fesm2022/flusys-ng-iam-role-form-page.component-D_AAEay2.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-role-list-page.component-D4J1by6Q.mjs +0 -299
- package/fesm2022/flusys-ng-iam-role-list-page.component-D4J1by6Q.mjs.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, computed, Component } from '@angular/core';
|
|
3
|
+
import { RouterOutlet } from '@angular/router';
|
|
4
|
+
import { APP_CONFIG, getPermissionMode } from '@flusys/ng-core';
|
|
5
|
+
import { PermissionValidatorService, TranslateService, ACTION_PERMISSIONS, ROLE_PERMISSIONS, ROLE_ACTION_PERMISSIONS, USER_ROLE_PERMISSIONS, USER_ACTION_PERMISSIONS, COMPANY_ACTION_PERMISSIONS, RouterTabsComponent, TranslatePipe } from '@flusys/ng-shared';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* IAM Container Component
|
|
9
|
+
*
|
|
10
|
+
* Main container for IAM module with tab navigation
|
|
11
|
+
* Routes: Actions | Roles (conditional) | Users (permission assignment)
|
|
12
|
+
*/
|
|
13
|
+
class IamContainerComponent {
|
|
14
|
+
appConfig = inject(APP_CONFIG);
|
|
15
|
+
permissionValidator = inject(PermissionValidatorService);
|
|
16
|
+
translateService = inject(TranslateService);
|
|
17
|
+
/** All available tabs */
|
|
18
|
+
allTabs = [
|
|
19
|
+
{
|
|
20
|
+
id: 'actions',
|
|
21
|
+
labelKey: 'iam.action.title',
|
|
22
|
+
icon: 'bolt',
|
|
23
|
+
route: 'actions',
|
|
24
|
+
permission: [ACTION_PERMISSIONS.READ],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'roles',
|
|
28
|
+
labelKey: 'iam.role.title',
|
|
29
|
+
icon: 'shield',
|
|
30
|
+
route: 'roles',
|
|
31
|
+
requiresRBAC: true,
|
|
32
|
+
permission: [ROLE_PERMISSIONS.READ],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'permissions',
|
|
36
|
+
labelKey: 'iam.permission.title',
|
|
37
|
+
icon: 'key',
|
|
38
|
+
route: 'permissions',
|
|
39
|
+
permission: [
|
|
40
|
+
ROLE_ACTION_PERMISSIONS.READ,
|
|
41
|
+
USER_ROLE_PERMISSIONS.READ,
|
|
42
|
+
USER_ACTION_PERMISSIONS.READ,
|
|
43
|
+
COMPANY_ACTION_PERMISSIONS.READ,
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
/** Visible tabs based on permission mode */
|
|
48
|
+
visibleTabs = computed(() => {
|
|
49
|
+
const permissionMode = getPermissionMode(this.appConfig);
|
|
50
|
+
return this.allTabs
|
|
51
|
+
.filter((tab) => {
|
|
52
|
+
const hasPermission = this.permissionValidator.hasAnyPermission(tab.permission);
|
|
53
|
+
return (hasPermission &&
|
|
54
|
+
(!tab.requiresRBAC ||
|
|
55
|
+
permissionMode === 'rbac' ||
|
|
56
|
+
permissionMode === 'full'));
|
|
57
|
+
})
|
|
58
|
+
.map((tab) => ({
|
|
59
|
+
id: tab.id,
|
|
60
|
+
label: this.translateService.translate(tab.labelKey),
|
|
61
|
+
icon: tab.icon,
|
|
62
|
+
route: tab.route,
|
|
63
|
+
}));
|
|
64
|
+
}, /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "visibleTabs" }] : /* istanbul ignore next */ []));
|
|
66
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: IamContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
67
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: IamContainerComponent, isStandalone: true, selector: "lib-iam-container", ngImport: i0, template: `
|
|
68
|
+
<div class="p-4">
|
|
69
|
+
<div class="mb-4">
|
|
70
|
+
<h1 class="text-xl sm:text-2xl font-bold m-0">
|
|
71
|
+
{{ 'iam.title' | translate }}
|
|
72
|
+
</h1>
|
|
73
|
+
<p class="text-muted-color mt-1">{{ 'iam.subtitle' | translate }}</p>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<lib-router-tabs [tabs]="visibleTabs()" class="mb-4" />
|
|
77
|
+
|
|
78
|
+
<router-outlet />
|
|
79
|
+
</div>
|
|
80
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "component", type: RouterTabsComponent, selector: "lib-router-tabs", inputs: ["tabs"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
81
|
+
}
|
|
82
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: IamContainerComponent, decorators: [{
|
|
83
|
+
type: Component,
|
|
84
|
+
args: [{
|
|
85
|
+
selector: 'lib-iam-container',
|
|
86
|
+
imports: [RouterOutlet, TranslatePipe, RouterTabsComponent],
|
|
87
|
+
template: `
|
|
88
|
+
<div class="p-4">
|
|
89
|
+
<div class="mb-4">
|
|
90
|
+
<h1 class="text-xl sm:text-2xl font-bold m-0">
|
|
91
|
+
{{ 'iam.title' | translate }}
|
|
92
|
+
</h1>
|
|
93
|
+
<p class="text-muted-color mt-1">{{ 'iam.subtitle' | translate }}</p>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<lib-router-tabs [tabs]="visibleTabs()" class="mb-4" />
|
|
97
|
+
|
|
98
|
+
<router-outlet />
|
|
99
|
+
</div>
|
|
100
|
+
`,
|
|
101
|
+
}]
|
|
102
|
+
}] });
|
|
103
|
+
|
|
104
|
+
export { IamContainerComponent };
|
|
105
|
+
//# sourceMappingURL=flusys-ng-iam-iam-container.component-D0m8u6nu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-iam-iam-container.component-D0m8u6nu.mjs","sources":["../../../projects/ng-iam/pages/iam-container/iam-container.component.ts"],"sourcesContent":["import { Component, computed, inject } from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\nimport { APP_CONFIG, getPermissionMode } from '@flusys/ng-core';\nimport {\n ACTION_PERMISSIONS,\n COMPANY_ACTION_PERMISSIONS,\n PermissionValidatorService,\n ROLE_ACTION_PERMISSIONS,\n ROLE_PERMISSIONS,\n RouterTabItem,\n RouterTabsComponent,\n TranslatePipe,\n TranslateService,\n USER_ACTION_PERMISSIONS,\n USER_ROLE_PERMISSIONS,\n} from '@flusys/ng-shared';\n\ninterface ITab {\n id: string;\n labelKey: string;\n icon: string;\n route: string;\n requiresRBAC?: boolean;\n permission: string[];\n}\n\n/**\n * IAM Container Component\n *\n * Main container for IAM module with tab navigation\n * Routes: Actions | Roles (conditional) | Users (permission assignment)\n */\n@Component({\n selector: 'lib-iam-container',\n imports: [RouterOutlet, TranslatePipe, RouterTabsComponent],\n template: `\n <div class=\"p-4\">\n <div class=\"mb-4\">\n <h1 class=\"text-xl sm:text-2xl font-bold m-0\">\n {{ 'iam.title' | translate }}\n </h1>\n <p class=\"text-muted-color mt-1\">{{ 'iam.subtitle' | translate }}</p>\n </div>\n\n <lib-router-tabs [tabs]=\"visibleTabs()\" class=\"mb-4\" />\n\n <router-outlet />\n </div>\n `,\n})\nexport class IamContainerComponent {\n private readonly appConfig = inject(APP_CONFIG);\n\n private readonly permissionValidator = inject(PermissionValidatorService);\n private readonly translateService = inject(TranslateService);\n\n /** All available tabs */\n private readonly allTabs: ITab[] = [\n {\n id: 'actions',\n labelKey: 'iam.action.title',\n icon: 'bolt',\n route: 'actions',\n permission: [ACTION_PERMISSIONS.READ],\n },\n {\n id: 'roles',\n labelKey: 'iam.role.title',\n icon: 'shield',\n route: 'roles',\n requiresRBAC: true,\n permission: [ROLE_PERMISSIONS.READ],\n },\n {\n id: 'permissions',\n labelKey: 'iam.permission.title',\n icon: 'key',\n route: 'permissions',\n permission: [\n ROLE_ACTION_PERMISSIONS.READ,\n USER_ROLE_PERMISSIONS.READ,\n USER_ACTION_PERMISSIONS.READ,\n COMPANY_ACTION_PERMISSIONS.READ,\n ],\n },\n ];\n\n /** Visible tabs based on permission mode */\n readonly visibleTabs = computed<RouterTabItem[]>(() => {\n const permissionMode = getPermissionMode(this.appConfig);\n return this.allTabs\n .filter((tab) => {\n const hasPermission = this.permissionValidator.hasAnyPermission(\n tab.permission,\n );\n return (\n hasPermission &&\n (!tab.requiresRBAC ||\n permissionMode === 'rbac' ||\n permissionMode === 'full')\n );\n })\n .map((tab) => ({\n id: tab.id,\n label: this.translateService.translate(tab.labelKey),\n icon: tab.icon,\n route: tab.route,\n }));\n });\n}\n"],"names":[],"mappings":";;;;;;AA0BA;;;;;AAKG;MAmBU,qBAAqB,CAAA;AACf,IAAA,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;AAE9B,IAAA,mBAAmB,GAAG,MAAM,CAAC,0BAA0B,CAAC;AACxD,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;;AAG3C,IAAA,OAAO,GAAW;AACjC,QAAA;AACE,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,QAAQ,EAAE,kBAAkB;AAC5B,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,UAAU,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;AACtC,SAAA;AACD,QAAA;AACE,YAAA,EAAE,EAA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ISSIONS, USER_ACTION_PERMISSIONS, USER_ROLE_PERMISSIONS, ROLE_ACTION_PERMISSIONS, AngularModule,
|
|
2
|
+
import { inject, signal, computed, effect, untracked, Component } from '@angular/core';
|
|
3
|
+
import { COMPANY_ACTION_PERMISSIONS, USER_ACTION_PERMISSIONS, USER_ROLE_PERMISSIONS, ROLE_ACTION_PERMISSIONS, AngularModule, HasPermissionDirective, TranslatePipe } from '@flusys/ng-shared';
|
|
4
4
|
import { APP_CONFIG, getPermissionMode, isCompanyFeatureEnabled } from '@flusys/ng-core';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { b as RoleActionSelectorComponent, C as CompanyActionSelectorComponent, U as UserRoleSelectorComponent, d as UserActionSelectorComponent } from './flusys-ng-iam-flusys-ng-iam-CJAQT60K.mjs';
|
|
5
|
+
import { b as RoleActionSelectorComponent, C as CompanyActionSelectorComponent, U as UserRoleSelectorComponent, d as UserActionSelectorComponent } from './flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs';
|
|
6
|
+
import * as i2 from '@flusys/ng-ui';
|
|
7
|
+
import { UiModule } from '@flusys/ng-ui';
|
|
9
8
|
|
|
10
9
|
/** Permission codes for each tab */
|
|
11
10
|
const TAB_PERMISSIONS = {
|
|
@@ -17,22 +16,24 @@ const TAB_PERMISSIONS = {
|
|
|
17
16
|
/** Main permission management interface with tabs for role/user/company permission assignment */
|
|
18
17
|
class PermissionPageComponent {
|
|
19
18
|
appConfig = inject(APP_CONFIG);
|
|
20
|
-
activeTab = signal('',
|
|
19
|
+
activeTab = signal('', /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
|
|
21
21
|
/** Available tabs based on permission mode */
|
|
22
22
|
availableTabs = computed(() => {
|
|
23
23
|
const permissionMode = getPermissionMode(this.appConfig);
|
|
24
24
|
const tabs = [];
|
|
25
25
|
if (permissionMode === 'rbac' || permissionMode === 'full') {
|
|
26
|
-
tabs.push({ id: 'role-actions',
|
|
26
|
+
tabs.push({ id: 'role-actions', labelKey: 'iam.permission.role.actions', icon: 'shield', permission: TAB_PERMISSIONS['role-actions'] }, { id: 'user-roles', labelKey: 'iam.permission.user.roles', icon: 'user', permission: TAB_PERMISSIONS['user-roles'] });
|
|
27
27
|
}
|
|
28
28
|
if (permissionMode === 'direct' || permissionMode === 'full') {
|
|
29
|
-
tabs.push({ id: 'user-actions',
|
|
29
|
+
tabs.push({ id: 'user-actions', labelKey: 'iam.permission.user.actions', icon: 'key', permission: TAB_PERMISSIONS['user-actions'] });
|
|
30
30
|
}
|
|
31
31
|
if (isCompanyFeatureEnabled(this.appConfig)) {
|
|
32
|
-
tabs.push({ id: 'company-actions',
|
|
32
|
+
tabs.push({ id: 'company-actions', labelKey: 'iam.permission.company.actions', icon: 'building', permission: TAB_PERMISSIONS['company-actions'] });
|
|
33
33
|
}
|
|
34
34
|
return tabs;
|
|
35
|
-
},
|
|
35
|
+
}, /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "availableTabs" }] : /* istanbul ignore next */ []));
|
|
36
37
|
constructor() {
|
|
37
38
|
effect(() => {
|
|
38
39
|
const tabs = this.availableTabs();
|
|
@@ -47,21 +48,24 @@ class PermissionPageComponent {
|
|
|
47
48
|
setActiveTab(tabId) {
|
|
48
49
|
this.activeTab.set(tabId);
|
|
49
50
|
}
|
|
50
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
51
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
51
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PermissionPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
52
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PermissionPageComponent, isStandalone: true, selector: "lib-permission-page", ngImport: i0, template: `
|
|
52
53
|
<div class="card">
|
|
53
|
-
<h3 class="text-xl font-semibold mb-4">
|
|
54
|
+
<h3 class="text-xl font-semibold mb-4">{{ 'iam.permission.title' | translate }}</h3>
|
|
54
55
|
|
|
55
56
|
<div class="scrollbar-hide flex gap-2 mb-4 overflow-x-auto flex-nowrap">
|
|
56
57
|
@for (tab of availableTabs(); track tab.id) {
|
|
57
|
-
<
|
|
58
|
+
<button
|
|
59
|
+
fButton
|
|
58
60
|
*hasPermission="tab.permission"
|
|
59
|
-
[label]="tab.label"
|
|
60
|
-
[icon]="tab.icon"
|
|
61
61
|
[outlined]="activeTab() !== tab.id"
|
|
62
62
|
size="small"
|
|
63
|
-
|
|
64
|
-
(
|
|
63
|
+
class="shrink-0"
|
|
64
|
+
(click)="setActiveTab(tab.id)"
|
|
65
|
+
>
|
|
66
|
+
<ui-icon pButtonIcon [name]="tab.icon"></ui-icon>
|
|
67
|
+
<span pButtonLabel>{{ tab.labelKey | translate }}</span>
|
|
68
|
+
</button>
|
|
65
69
|
}
|
|
66
70
|
</div>
|
|
67
71
|
|
|
@@ -82,34 +86,36 @@ class PermissionPageComponent {
|
|
|
82
86
|
}
|
|
83
87
|
</div>
|
|
84
88
|
</div>
|
|
85
|
-
`, isInline: true, styles: [".scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}\n"], dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "ngmodule", type:
|
|
89
|
+
`, isInline: true, styles: [".scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}\n"], dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "ngmodule", type: UiModule }, { kind: "directive", type: i2.FButtonDirective, selector: "[fButton]", inputs: ["severity", "text", "outlined", "link", "variant", "rounded", "raised", "fluid", "disabled", "loading", "loadingIcon", "size", "label", "icon", "iconPos", "ariaLabel", "plain"] }, { kind: "component", type: i2.UiIconComponent, selector: "ui-icon", inputs: ["name", "size", "spin", "fill", "severity"] }, { kind: "directive", type: HasPermissionDirective, selector: "[hasPermission]", inputs: ["hasPermission"] }, { kind: "component", type: RoleActionSelectorComponent, selector: "flusys-role-action-selector" }, { kind: "component", type: CompanyActionSelectorComponent, selector: "flusys-company-action-selector" }, { kind: "component", type: UserRoleSelectorComponent, selector: "flusys-user-role-selector" }, { kind: "component", type: UserActionSelectorComponent, selector: "flusys-user-action-selector" }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
86
90
|
}
|
|
87
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PermissionPageComponent, decorators: [{
|
|
88
92
|
type: Component,
|
|
89
|
-
args: [{ selector: 'lib-permission-page',
|
|
93
|
+
args: [{ selector: 'lib-permission-page', imports: [
|
|
90
94
|
AngularModule,
|
|
91
|
-
|
|
92
|
-
ButtonModule,
|
|
93
|
-
TabsModule,
|
|
95
|
+
UiModule,
|
|
94
96
|
HasPermissionDirective,
|
|
97
|
+
TranslatePipe,
|
|
95
98
|
RoleActionSelectorComponent,
|
|
96
99
|
CompanyActionSelectorComponent,
|
|
97
100
|
UserRoleSelectorComponent,
|
|
98
101
|
UserActionSelectorComponent
|
|
99
102
|
], template: `
|
|
100
103
|
<div class="card">
|
|
101
|
-
<h3 class="text-xl font-semibold mb-4">
|
|
104
|
+
<h3 class="text-xl font-semibold mb-4">{{ 'iam.permission.title' | translate }}</h3>
|
|
102
105
|
|
|
103
106
|
<div class="scrollbar-hide flex gap-2 mb-4 overflow-x-auto flex-nowrap">
|
|
104
107
|
@for (tab of availableTabs(); track tab.id) {
|
|
105
|
-
<
|
|
108
|
+
<button
|
|
109
|
+
fButton
|
|
106
110
|
*hasPermission="tab.permission"
|
|
107
|
-
[label]="tab.label"
|
|
108
|
-
[icon]="tab.icon"
|
|
109
111
|
[outlined]="activeTab() !== tab.id"
|
|
110
112
|
size="small"
|
|
111
|
-
|
|
112
|
-
(
|
|
113
|
+
class="shrink-0"
|
|
114
|
+
(click)="setActiveTab(tab.id)"
|
|
115
|
+
>
|
|
116
|
+
<ui-icon pButtonIcon [name]="tab.icon"></ui-icon>
|
|
117
|
+
<span pButtonLabel>{{ tab.labelKey | translate }}</span>
|
|
118
|
+
</button>
|
|
113
119
|
}
|
|
114
120
|
</div>
|
|
115
121
|
|
|
@@ -134,4 +140,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
|
|
|
134
140
|
}], ctorParameters: () => [] });
|
|
135
141
|
|
|
136
142
|
export { PermissionPageComponent };
|
|
137
|
-
//# sourceMappingURL=flusys-ng-iam-permission-page.component-
|
|
143
|
+
//# sourceMappingURL=flusys-ng-iam-permission-page.component-x88X4AgJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-iam-permission-page.component-x88X4AgJ.mjs","sources":["../../../projects/ng-iam/pages/permission/permission-page.component.ts"],"sourcesContent":["import { Component, computed, effect, inject, signal, untracked } from '@angular/core';\nimport {\n AngularModule,\n HasPermissionDirective,\n ROLE_ACTION_PERMISSIONS,\n USER_ROLE_PERMISSIONS,\n USER_ACTION_PERMISSIONS,\n COMPANY_ACTION_PERMISSIONS,\n TranslatePipe,\n} from '@flusys/ng-shared';\nimport { APP_CONFIG, getPermissionMode, isCompanyFeatureEnabled } from '@flusys/ng-core';\nimport { RoleActionSelectorComponent } from '../../components/role-action-selector.component';\nimport { CompanyActionSelectorComponent } from '../../components/company-action-selector.component';\nimport { UserRoleSelectorComponent } from '../../components/user-role-selector.component';\nimport { UserActionSelectorComponent } from '../../components/user-action-selector.component';\nimport { UiModule } from '@flusys/ng-ui';\n\n/** Permission codes for each tab */\nconst TAB_PERMISSIONS = {\n 'role-actions': ROLE_ACTION_PERMISSIONS.READ,\n 'user-roles': USER_ROLE_PERMISSIONS.READ,\n 'user-actions': USER_ACTION_PERMISSIONS.READ,\n 'company-actions': COMPANY_ACTION_PERMISSIONS.READ,\n} as const;\n\n/** Main permission management interface with tabs for role/user/company permission assignment */\n@Component({\n selector: 'lib-permission-page',\n imports: [\n AngularModule,\n UiModule,\n HasPermissionDirective,\n TranslatePipe,\n RoleActionSelectorComponent,\n CompanyActionSelectorComponent,\n UserRoleSelectorComponent,\n UserActionSelectorComponent\n ],\n styles: `\n .scrollbar-hide {\n -ms-overflow-style: none;\n scrollbar-width: none;\n &::-webkit-scrollbar { display: none; }\n }\n `,\n template: `\n <div class=\"card\">\n <h3 class=\"text-xl font-semibold mb-4\">{{ 'iam.permission.title' | translate }}</h3>\n\n <div class=\"scrollbar-hide flex gap-2 mb-4 overflow-x-auto flex-nowrap\">\n @for (tab of availableTabs(); track tab.id) {\n <button\n fButton\n *hasPermission=\"tab.permission\"\n [outlined]=\"activeTab() !== tab.id\"\n size=\"small\"\n class=\"shrink-0\"\n (click)=\"setActiveTab(tab.id)\"\n >\n <ui-icon pButtonIcon [name]=\"tab.icon\"></ui-icon>\n <span pButtonLabel>{{ tab.labelKey | translate }}</span>\n </button>\n }\n </div>\n\n <div class=\"mt-4\">\n @switch (activeTab()) {\n @case ('role-actions') {\n <flusys-role-action-selector />\n }\n @case ('user-roles') {\n <flusys-user-role-selector />\n }\n @case ('user-actions') {\n <flusys-user-action-selector />\n }\n @case ('company-actions') {\n <flusys-company-action-selector />\n }\n }\n </div>\n </div>\n `,\n})\nexport class PermissionPageComponent {\n private readonly appConfig = inject(APP_CONFIG);\n\n readonly activeTab = signal<string>('');\n\n /** Available tabs based on permission mode */\n readonly availableTabs = computed(() => {\n const permissionMode = getPermissionMode(this.appConfig);\n const tabs: Array<{ id: string; labelKey: string; icon: string; permission: string }> = [];\n\n if (permissionMode === 'rbac' || permissionMode === 'full') {\n tabs.push(\n { id: 'role-actions', labelKey: 'iam.permission.role.actions', icon: 'shield', permission: TAB_PERMISSIONS['role-actions'] },\n { id: 'user-roles', labelKey: 'iam.permission.user.roles', icon: 'user', permission: TAB_PERMISSIONS['user-roles'] }\n );\n }\n\n if (permissionMode === 'direct' || permissionMode === 'full') {\n tabs.push({ id: 'user-actions', labelKey: 'iam.permission.user.actions', icon: 'key', permission: TAB_PERMISSIONS['user-actions'] });\n }\n\n if (isCompanyFeatureEnabled(this.appConfig)) {\n tabs.push({ id: 'company-actions', labelKey: 'iam.permission.company.actions', icon: 'building', permission: TAB_PERMISSIONS['company-actions'] });\n }\n\n return tabs;\n });\n\n constructor() {\n effect(() => {\n const tabs = this.availableTabs();\n const currentTab = untracked(() => this.activeTab());\n if (!currentTab || !tabs.some((t) => t.id === currentTab)) {\n if (tabs.length > 0) {\n this.activeTab.set(tabs[0].id);\n }\n }\n });\n }\n\n setActiveTab(tabId: string): void {\n this.activeTab.set(tabId);\n }\n}\n"],"names":["i1"],"mappings":";;;;;;;;AAiBA;AACA,MAAM,eAAe,GAAG;IACtB,cAAc,EAAE,uBAAuB,CAAC,IAAI;IAC5C,YAAY,EAAE,qBAAqB,CAAC,IAAI;IACxC,cAAc,EAAE,uBAAuB,CAAC,IAAI;IAC5C,iBAAiB,EAAE,0BAA0B,CAAC,IAAI;CAC1C;AAEV;MA2Da,uBAAuB,CAAA;AACjB,IAAA,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;IAEtC,SAAS,GAAG,MAAM,CAAS,EAAE;kFAAC;;AAG9B,IAAA,aAAa,GAAG,QAAQ,CAAC,MAAK;QACrC,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC;QACxD,MAAM,IAAI,GAA8E,EAAE;QAE1F,IAAI,cAAc,KAAK,MAAM,IAAI,cAAc,KAAK,MAAM,EAAE;YAC1D,IAAI,CAAC,IAAI,CACP,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,6BAA6B,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE,E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AAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAEtB,2BAA2B,EAAA,QAAA,EAAA,6BAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAC3B,8BAA8B,EAAA,QAAA,EAAA,gCAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAC9B,yBAAyB,EAAA,QAAA,EAAA,2BAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACzB,2BAA2B,mEAJ3B,aAAa,EAAA,IAAA,EAAA,WAAA,EAAA,CAAA,EAAA,CAAA;;2FAoDJ,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBA1DnC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,qBAAqB,EAAA,OAAA,EACtB;wBACP,aAAa;wBACb,QAAQ;wBACR,sBAAsB;wBACtB,aAAa;wBACb,2BAA2B;wBAC3B,8BAA8B;wBAC9B,yBAAyB;wBACzB;qBACD,EAAA,QAAA,EAQS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,iHAAA,CAAA,EAAA;;;;;"}
|
|
@@ -0,0 +1,335 @@
|
|
|
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 * as i2 from '@flusys/ng-ui';
|
|
9
|
+
import { MessageService, UiModule } from '@flusys/ng-ui';
|
|
10
|
+
import { TranslateService, AngularModule, TranslatePipe } from '@flusys/ng-shared';
|
|
11
|
+
import { R as RoleApiService } from './flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs';
|
|
12
|
+
import * as i1 from '@angular/forms';
|
|
13
|
+
|
|
14
|
+
class RoleFormPageComponent {
|
|
15
|
+
route = inject(ActivatedRoute);
|
|
16
|
+
router = inject(Router);
|
|
17
|
+
appConfig = inject(APP_CONFIG);
|
|
18
|
+
companyContext = inject(LAYOUT_AUTH_STATE);
|
|
19
|
+
roleApi = inject(RoleApiService);
|
|
20
|
+
messageService = inject(MessageService);
|
|
21
|
+
translateAdapter = inject(TranslateService, {
|
|
22
|
+
optional: true,
|
|
23
|
+
});
|
|
24
|
+
routeParams = toSignal(this.route.paramMap);
|
|
25
|
+
initialized = false;
|
|
26
|
+
translate(key, vars) {
|
|
27
|
+
return this.translateAdapter?.translate(key, vars) ?? key;
|
|
28
|
+
}
|
|
29
|
+
isLoading = signal(false, /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
31
|
+
existingRole = signal(null, /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "existingRole" }] : /* istanbul ignore next */ []));
|
|
33
|
+
isEditMode = computed(() => !!this.existingRole(), /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "isEditMode" }] : /* istanbul ignore next */ []));
|
|
35
|
+
formModel = signal({
|
|
36
|
+
id: '',
|
|
37
|
+
name: '',
|
|
38
|
+
description: '',
|
|
39
|
+
serial: '',
|
|
40
|
+
isActive: true,
|
|
41
|
+
}, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "formModel" }] : /* istanbul ignore next */ []));
|
|
43
|
+
roleForm = form(this.formModel, (f) => {
|
|
44
|
+
required(f.name, {
|
|
45
|
+
message: this.translate('shared.validation.required', {
|
|
46
|
+
field: this.translate('iam.role.name'),
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
isFormValid = computed(() => {
|
|
51
|
+
const model = this.formModel();
|
|
52
|
+
return model.name.trim().length > 0;
|
|
53
|
+
}, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []));
|
|
55
|
+
constructor() {
|
|
56
|
+
effect(() => {
|
|
57
|
+
const params = this.routeParams();
|
|
58
|
+
if (!params || this.initialized)
|
|
59
|
+
return;
|
|
60
|
+
this.initialized = true;
|
|
61
|
+
const id = params.get('id');
|
|
62
|
+
if (id && id !== 'new') {
|
|
63
|
+
this.loadRole(id);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async loadRole(id) {
|
|
68
|
+
this.isLoading.set(true);
|
|
69
|
+
try {
|
|
70
|
+
const response = await this.roleApi.findById(id);
|
|
71
|
+
const role = response?.data;
|
|
72
|
+
if (role) {
|
|
73
|
+
this.existingRole.set(role);
|
|
74
|
+
this.formModel.set({
|
|
75
|
+
id: role.id,
|
|
76
|
+
name: role.name,
|
|
77
|
+
description: role.description ?? '',
|
|
78
|
+
serial: role.serial?.toString() ?? '',
|
|
79
|
+
isActive: role.isActive,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Error toast handled by global interceptor
|
|
84
|
+
this.router.navigate(['/iam/roles']);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Error toast handled by global interceptor
|
|
89
|
+
this.router.navigate(['/iam/roles']);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.isLoading.set(false);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async onSubmit() {
|
|
96
|
+
if (!this.isFormValid()) {
|
|
97
|
+
this.messageService.add({
|
|
98
|
+
severity: 'error',
|
|
99
|
+
summary: this.translate('shared.validation.error'),
|
|
100
|
+
detail: this.translate('shared.fill.required.fields'),
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.isLoading.set(true);
|
|
105
|
+
try {
|
|
106
|
+
const formValue = this.formModel();
|
|
107
|
+
// Get company context if feature enabled
|
|
108
|
+
const companyId = isCompanyFeatureEnabled(this.appConfig)
|
|
109
|
+
? this.companyContext.currentCompanyInfo()?.id || undefined
|
|
110
|
+
: undefined;
|
|
111
|
+
// Convert empty strings to undefined for DTO compatibility
|
|
112
|
+
const dto = {
|
|
113
|
+
...formValue,
|
|
114
|
+
description: formValue.description || undefined,
|
|
115
|
+
serial: formValue.serial ? parseInt(formValue.serial, 10) : undefined,
|
|
116
|
+
companyId: this.isEditMode() ? undefined : companyId,
|
|
117
|
+
};
|
|
118
|
+
const response = this.isEditMode()
|
|
119
|
+
? await this.roleApi.update(dto)
|
|
120
|
+
: await this.roleApi.insert(dto);
|
|
121
|
+
this.messageService.add({
|
|
122
|
+
severity: 'success',
|
|
123
|
+
summary: this.translate('shared.success'),
|
|
124
|
+
detail: response.messageKey
|
|
125
|
+
? this.translate(response.messageKey, response.messageVariables)
|
|
126
|
+
: (response.message ?? ''),
|
|
127
|
+
});
|
|
128
|
+
this.router.navigate(['/iam/roles']);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Error toast handled by global interceptor
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this.isLoading.set(false);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
onBack() {
|
|
138
|
+
this.router.navigate(['/iam/roles']);
|
|
139
|
+
}
|
|
140
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RoleFormPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
141
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: RoleFormPageComponent, isStandalone: true, selector: "lib-role-form-page", ngImport: i0, template: `
|
|
142
|
+
<div class="card">
|
|
143
|
+
<h3 class="text-lg sm:text-xl font-semibold mb-4">
|
|
144
|
+
{{
|
|
145
|
+
isEditMode()
|
|
146
|
+
? ('iam.role.edit' | translate)
|
|
147
|
+
: ('iam.role.new' | translate)
|
|
148
|
+
}}
|
|
149
|
+
</h3>
|
|
150
|
+
|
|
151
|
+
<form
|
|
152
|
+
(ngSubmit)="onSubmit()"
|
|
153
|
+
class="grid grid-cols-1 md:grid-cols-2 gap-4"
|
|
154
|
+
>
|
|
155
|
+
<!-- Name -->
|
|
156
|
+
<div class="flex flex-col gap-2">
|
|
157
|
+
<label for="name" class="font-medium"
|
|
158
|
+
>{{ 'iam.role.name' | translate }} *</label
|
|
159
|
+
>
|
|
160
|
+
<input
|
|
161
|
+
fInputText
|
|
162
|
+
id="name"
|
|
163
|
+
[formField]="roleForm.name"
|
|
164
|
+
[placeholder]="'iam.role.name.placeholder' | translate"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<!-- Description -->
|
|
169
|
+
<div class="flex flex-col gap-2">
|
|
170
|
+
<label for="description" class="font-medium">{{
|
|
171
|
+
'shared.description' | translate
|
|
172
|
+
}}</label>
|
|
173
|
+
<input
|
|
174
|
+
fInputText
|
|
175
|
+
id="description"
|
|
176
|
+
[formField]="roleForm.description"
|
|
177
|
+
[placeholder]="'shared.description.placeholder' | translate"
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<!-- Order -->
|
|
182
|
+
<div class="flex flex-col gap-2">
|
|
183
|
+
<label for="serial" class="font-medium">{{
|
|
184
|
+
'shared.display.order' | translate
|
|
185
|
+
}}</label>
|
|
186
|
+
<input
|
|
187
|
+
fInputText
|
|
188
|
+
id="serial"
|
|
189
|
+
type="number"
|
|
190
|
+
[formField]="roleForm.serial"
|
|
191
|
+
[placeholder]="'shared.display.order.placeholder' | translate"
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<!-- Is Active -->
|
|
196
|
+
<div class="flex items-end gap-2 pb-1">
|
|
197
|
+
<f-checkbox
|
|
198
|
+
[formField]="roleForm.isActive"
|
|
199
|
+
[binary]="true"
|
|
200
|
+
inputId="isActive"
|
|
201
|
+
/>
|
|
202
|
+
<label for="isActive">{{ 'shared.active' | translate }}</label>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<!-- Actions -->
|
|
206
|
+
<div class="flex justify-end gap-2 md:col-span-2 pt-4">
|
|
207
|
+
<button
|
|
208
|
+
fButton
|
|
209
|
+
severity="secondary"
|
|
210
|
+
[outlined]="true"
|
|
211
|
+
(click)="onBack()"
|
|
212
|
+
>
|
|
213
|
+
<span pButtonLabel>{{ 'shared.cancel' | translate }}</span>
|
|
214
|
+
</button>
|
|
215
|
+
<button
|
|
216
|
+
fButton
|
|
217
|
+
type="submit"
|
|
218
|
+
[disabled]="!isFormValid() || isLoading()"
|
|
219
|
+
>
|
|
220
|
+
@if (isLoading()) {
|
|
221
|
+
<ui-icon pButtonIcon name="spinner" [spin]="true"></ui-icon>
|
|
222
|
+
}
|
|
223
|
+
<span pButtonLabel>{{
|
|
224
|
+
isEditMode()
|
|
225
|
+
? ('shared.update' | translate)
|
|
226
|
+
: ('shared.create' | translate)
|
|
227
|
+
}}</span>
|
|
228
|
+
</button>
|
|
229
|
+
</div>
|
|
230
|
+
</form>
|
|
231
|
+
</div>
|
|
232
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: UiModule }, { kind: "directive", type: i2.FButtonDirective, selector: "[fButton]", inputs: ["severity", "text", "outlined", "link", "variant", "rounded", "raised", "fluid", "disabled", "loading", "loadingIcon", "size", "label", "icon", "iconPos", "ariaLabel", "plain"] }, { kind: "component", type: i2.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: i2.InputTextDirective, selector: "[fInputText]", inputs: ["invalid", "touched", "variant", "size", "fluid"] }, { kind: "component", type: i2.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" }] });
|
|
233
|
+
}
|
|
234
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RoleFormPageComponent, decorators: [{
|
|
235
|
+
type: Component,
|
|
236
|
+
args: [{
|
|
237
|
+
selector: 'lib-role-form-page',
|
|
238
|
+
imports: [AngularModule, UiModule, FormField, TranslatePipe],
|
|
239
|
+
template: `
|
|
240
|
+
<div class="card">
|
|
241
|
+
<h3 class="text-lg sm:text-xl font-semibold mb-4">
|
|
242
|
+
{{
|
|
243
|
+
isEditMode()
|
|
244
|
+
? ('iam.role.edit' | translate)
|
|
245
|
+
: ('iam.role.new' | translate)
|
|
246
|
+
}}
|
|
247
|
+
</h3>
|
|
248
|
+
|
|
249
|
+
<form
|
|
250
|
+
(ngSubmit)="onSubmit()"
|
|
251
|
+
class="grid grid-cols-1 md:grid-cols-2 gap-4"
|
|
252
|
+
>
|
|
253
|
+
<!-- Name -->
|
|
254
|
+
<div class="flex flex-col gap-2">
|
|
255
|
+
<label for="name" class="font-medium"
|
|
256
|
+
>{{ 'iam.role.name' | translate }} *</label
|
|
257
|
+
>
|
|
258
|
+
<input
|
|
259
|
+
fInputText
|
|
260
|
+
id="name"
|
|
261
|
+
[formField]="roleForm.name"
|
|
262
|
+
[placeholder]="'iam.role.name.placeholder' | translate"
|
|
263
|
+
/>
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<!-- Description -->
|
|
267
|
+
<div class="flex flex-col gap-2">
|
|
268
|
+
<label for="description" class="font-medium">{{
|
|
269
|
+
'shared.description' | translate
|
|
270
|
+
}}</label>
|
|
271
|
+
<input
|
|
272
|
+
fInputText
|
|
273
|
+
id="description"
|
|
274
|
+
[formField]="roleForm.description"
|
|
275
|
+
[placeholder]="'shared.description.placeholder' | translate"
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<!-- Order -->
|
|
280
|
+
<div class="flex flex-col gap-2">
|
|
281
|
+
<label for="serial" class="font-medium">{{
|
|
282
|
+
'shared.display.order' | translate
|
|
283
|
+
}}</label>
|
|
284
|
+
<input
|
|
285
|
+
fInputText
|
|
286
|
+
id="serial"
|
|
287
|
+
type="number"
|
|
288
|
+
[formField]="roleForm.serial"
|
|
289
|
+
[placeholder]="'shared.display.order.placeholder' | translate"
|
|
290
|
+
/>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
<!-- Is Active -->
|
|
294
|
+
<div class="flex items-end gap-2 pb-1">
|
|
295
|
+
<f-checkbox
|
|
296
|
+
[formField]="roleForm.isActive"
|
|
297
|
+
[binary]="true"
|
|
298
|
+
inputId="isActive"
|
|
299
|
+
/>
|
|
300
|
+
<label for="isActive">{{ 'shared.active' | translate }}</label>
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<!-- Actions -->
|
|
304
|
+
<div class="flex justify-end gap-2 md:col-span-2 pt-4">
|
|
305
|
+
<button
|
|
306
|
+
fButton
|
|
307
|
+
severity="secondary"
|
|
308
|
+
[outlined]="true"
|
|
309
|
+
(click)="onBack()"
|
|
310
|
+
>
|
|
311
|
+
<span pButtonLabel>{{ 'shared.cancel' | translate }}</span>
|
|
312
|
+
</button>
|
|
313
|
+
<button
|
|
314
|
+
fButton
|
|
315
|
+
type="submit"
|
|
316
|
+
[disabled]="!isFormValid() || isLoading()"
|
|
317
|
+
>
|
|
318
|
+
@if (isLoading()) {
|
|
319
|
+
<ui-icon pButtonIcon name="spinner" [spin]="true"></ui-icon>
|
|
320
|
+
}
|
|
321
|
+
<span pButtonLabel>{{
|
|
322
|
+
isEditMode()
|
|
323
|
+
? ('shared.update' | translate)
|
|
324
|
+
: ('shared.create' | translate)
|
|
325
|
+
}}</span>
|
|
326
|
+
</button>
|
|
327
|
+
</div>
|
|
328
|
+
</form>
|
|
329
|
+
</div>
|
|
330
|
+
`,
|
|
331
|
+
}]
|
|
332
|
+
}], ctorParameters: () => [] });
|
|
333
|
+
|
|
334
|
+
export { RoleFormPageComponent };
|
|
335
|
+
//# sourceMappingURL=flusys-ng-iam-role-form-page.component-InsxdriD.mjs.map
|