@ieeesa-npm/tenants 0.4.4 → 0.5.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/esm2022/ieeesa-npm-tenants.mjs +5 -0
- package/esm2022/lib/assets/constants.json +454 -0
- package/esm2022/lib/assets/tenant-validations.mjs +17 -0
- package/esm2022/lib/components/create-modify-group-type/create-modify-group-type.component.mjs +476 -0
- package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +279 -0
- package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +512 -0
- package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +391 -0
- package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +94 -0
- package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +733 -0
- package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +194 -0
- package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +335 -0
- package/esm2022/lib/models/app-type-config.model.mjs +2 -0
- package/esm2022/lib/models/app-type.model.mjs +7 -0
- package/esm2022/lib/models/create-group-type-config.model.mjs +22 -0
- package/esm2022/lib/models/create-group-type.model.mjs +2 -0
- package/esm2022/lib/models/feature-permission-id.model.mjs +8 -0
- package/esm2022/lib/models/features.model.mjs +2 -0
- package/esm2022/lib/models/permission-type.model.mjs +12 -0
- package/esm2022/lib/models/role-menu-action.model.mjs +7 -0
- package/esm2022/lib/models/role-type.model.mjs +2 -0
- package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +7 -0
- package/esm2022/lib/models/roles-and-permissions.model.mjs +2 -0
- package/esm2022/lib/models/route-config.model.mjs +2 -0
- package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +16 -0
- package/esm2022/lib/models/tenant-function-type.model.mjs +12 -0
- package/esm2022/lib/models/tenant.model.mjs +2 -0
- package/esm2022/lib/models/tenants-permission.model.mjs +2 -0
- package/esm2022/lib/models/update-tenant-status.model.mjs +2 -0
- package/esm2022/lib/models/view-tenant-group-types.model.mjs +11 -0
- package/esm2022/lib/services/tenant-applications.service.mjs +618 -0
- package/esm2022/lib/services/tenant-permissions-map.service.mjs +36 -0
- package/esm2022/lib/services/tenant-permissions.service.mjs +38 -0
- package/esm2022/lib/tenant-applications.component.mjs +14 -0
- package/esm2022/lib/tenant-applications.module.mjs +16 -0
- package/esm2022/public-api.mjs +36 -0
- package/fesm2022/ieeesa-npm-tenants.mjs +4233 -0
- package/fesm2022/ieeesa-npm-tenants.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/assets/tenant-validations.d.ts +15 -0
- package/lib/components/create-modify-group-type/create-modify-group-type.component.d.ts +129 -0
- package/lib/components/create-modify-role/create-modify-role.component.d.ts +103 -0
- package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +128 -0
- package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +106 -0
- package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +471 -0
- package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +223 -0
- package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +63 -0
- package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +134 -0
- package/lib/models/app-type-config.model.d.ts +14 -0
- package/lib/models/app-type.model.d.ts +4 -0
- package/lib/models/create-group-type-config.model.d.ts +16 -0
- package/lib/models/create-group-type.model.d.ts +49 -0
- package/lib/models/feature-permission-id.model.d.ts +4 -0
- package/lib/models/features.model.d.ts +15 -0
- package/lib/models/permission-type.model.d.ts +8 -0
- package/lib/models/role-menu-action.model.d.ts +4 -0
- package/lib/models/role-type.model.d.ts +27 -0
- package/lib/models/roles-and-permissions-table-type.model.d.ts +4 -0
- package/lib/models/roles-and-permissions.model.d.ts +119 -0
- package/lib/models/route-config.model.d.ts +4 -0
- package/lib/models/table-column-schema-view-tenant-list.model.d.ts +20 -0
- package/lib/models/tenant-function-type.model.d.ts +9 -0
- package/lib/models/tenant.model.d.ts +51 -0
- package/lib/models/tenants-permission.model.d.ts +9 -0
- package/lib/models/update-tenant-status.model.d.ts +14 -0
- package/lib/models/view-tenant-group-types.model.d.ts +29 -0
- package/lib/services/tenant-applications.service.d.ts +399 -0
- package/lib/services/tenant-permissions-map.service.d.ts +13 -0
- package/lib/services/tenant-permissions.service.d.ts +22 -0
- package/lib/tenant-applications.component.d.ts +5 -0
- package/lib/tenant-applications.module.d.ts +6 -0
- package/package.json +25 -12
- package/{src/public-api.ts → public-api.d.ts} +32 -40
- package/.eslintrc.json +0 -31
- package/ng-package.json +0 -8
- package/src/lib/assets/constants.json +0 -454
- package/src/lib/assets/tenant-validations.ts +0 -18
- package/src/lib/assets/tenants-mock.ts +0 -1240
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +0 -15
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +0 -44
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +0 -574
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +0 -602
- package/src/lib/components/create-modify-role/create-modify-role.component.html +0 -15
- package/src/lib/components/create-modify-role/create-modify-role.component.scss +0 -83
- package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +0 -346
- package/src/lib/components/create-modify-role/create-modify-role.component.ts +0 -321
- package/src/lib/components/create-tenant-application/create-tenant-application.component.html +0 -18
- package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +0 -73
- package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +0 -775
- package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +0 -638
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +0 -22
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +0 -79
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +0 -716
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +0 -504
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +0 -44
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +0 -16
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +0 -115
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +0 -109
- package/src/lib/components/view-tenant-details/view-tenant-details.component.html +0 -195
- package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +0 -163
- package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +0 -1221
- package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +0 -876
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +0 -10
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +0 -44
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +0 -410
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +0 -219
- package/src/lib/components/view-tenants-list/view-tenants-list.component.html +0 -32
- package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +0 -35
- package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +0 -464
- package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +0 -388
- package/src/lib/models/app-type-config.model.ts +0 -14
- package/src/lib/models/app-type.model.ts +0 -5
- package/src/lib/models/create-group-type-config.model.ts +0 -18
- package/src/lib/models/create-group-type.model.ts +0 -46
- package/src/lib/models/feature-permission-id.model.ts +0 -6
- package/src/lib/models/features.model.ts +0 -15
- package/src/lib/models/form-status.model.ts +0 -5
- package/src/lib/models/permission-type.model.ts +0 -9
- package/src/lib/models/role-menu-action.model.ts +0 -5
- package/src/lib/models/role-type.model.ts +0 -34
- package/src/lib/models/roles-and-permissions-table-type.model.ts +0 -5
- package/src/lib/models/roles-and-permissions.model.ts +0 -113
- package/src/lib/models/route-config.model.ts +0 -4
- package/src/lib/models/table-column-schema-view-tenant-list.model.ts +0 -21
- package/src/lib/models/tenant-function-type.model.ts +0 -10
- package/src/lib/models/tenant.model.ts +0 -47
- package/src/lib/models/tenants-permission.model.ts +0 -9
- package/src/lib/models/update-tenant-status.model.ts +0 -12
- package/src/lib/models/view-tenant-group-types.model.ts +0 -34
- package/src/lib/services/tenant-applications.service.spec.ts +0 -1245
- package/src/lib/services/tenant-applications.service.ts +0 -798
- package/src/lib/services/tenant-permissions-map.service.spec.ts +0 -25
- package/src/lib/services/tenant-permissions-map.service.ts +0 -28
- package/src/lib/services/tenant-permissions.service.spec.ts +0 -62
- package/src/lib/services/tenant-permissions.service.ts +0 -49
- package/src/lib/tenant-applications.component.html +0 -0
- package/src/lib/tenant-applications.component.scss +0 -0
- package/src/lib/tenant-applications.component.spec.ts +0 -28
- package/src/lib/tenant-applications.component.ts +0 -12
- package/src/lib/tenant-applications.module.ts +0 -8
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<div class="ieeesa-view-tenant-group-types">
|
|
2
|
-
<ieeesa-data-table
|
|
3
|
-
*ngIf="columnSchema.length"
|
|
4
|
-
[headerElementClassName]="headerElementClassName"
|
|
5
|
-
[customStickyHeaderNeeded]="true"
|
|
6
|
-
[isCellTextOverflowEllipsis]="true"
|
|
7
|
-
[tableDataInfo]="groupTypes"
|
|
8
|
-
[columnSchemaInfo]="columnSchema"
|
|
9
|
-
></ieeesa-data-table>
|
|
10
|
-
</div>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
@import "styles.scss";
|
|
2
|
-
|
|
3
|
-
.ieeesa-view-tenant-group-types {
|
|
4
|
-
.ieeesa-data-table {
|
|
5
|
-
padding-top: 2.5em;
|
|
6
|
-
&__content {
|
|
7
|
-
margin-top: 0px !important;
|
|
8
|
-
.mdc-data-table {
|
|
9
|
-
&__header-cell {
|
|
10
|
-
padding: 14px 12px;
|
|
11
|
-
box-shadow: $ieeesa-box-shadow-17 !important;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
.mdc-data-table {
|
|
15
|
-
&__cell {
|
|
16
|
-
padding: 4px 14px;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
.cdk-column-groupType {
|
|
20
|
-
min-width: 10em;
|
|
21
|
-
max-width: 10em;
|
|
22
|
-
}
|
|
23
|
-
.cdk-column-description {
|
|
24
|
-
min-width: 12em;
|
|
25
|
-
max-width: 12em;
|
|
26
|
-
}
|
|
27
|
-
.cdk-column-rosterType {
|
|
28
|
-
min-width: 6em;
|
|
29
|
-
max-width: 6em;
|
|
30
|
-
}
|
|
31
|
-
.cdk-column-applicableRoles,
|
|
32
|
-
.cdk-column-settings {
|
|
33
|
-
min-width: 10em;
|
|
34
|
-
max-width: 10em;
|
|
35
|
-
}
|
|
36
|
-
.mat-mdc-icon-button {
|
|
37
|
-
color: $ieeesa-blue;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
@media (max-width: $ieeesa-mobile-min-width) {
|
|
41
|
-
padding-top: 1em;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HttpClient,
|
|
3
|
-
HttpErrorResponse,
|
|
4
|
-
HttpHandler,
|
|
5
|
-
} from '@angular/common/http';
|
|
6
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
7
|
-
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
8
|
-
import { DataTableComponent, TableColumnType } from '@ieeesa-npm/presentation';
|
|
9
|
-
import { SharedService } from '@ieeesa-npm/shared';
|
|
10
|
-
import { GlobalErrorHandlerService } from '@ieeesa-npm/utility';
|
|
11
|
-
import { TenantsMocks } from '@tenants/assets/tenants-mock';
|
|
12
|
-
import { TenantApplicationsService } from '@tenants/services/tenant-applications.service';
|
|
13
|
-
import { Observable } from 'rxjs';
|
|
14
|
-
import { ViewTenantGroupTypesComponent } from './view-tenant-group-types.component';
|
|
15
|
-
|
|
16
|
-
describe('ViewTenantGroupTypesComponent', () => {
|
|
17
|
-
let component: ViewTenantGroupTypesComponent;
|
|
18
|
-
let fixture: ComponentFixture<ViewTenantGroupTypesComponent>;
|
|
19
|
-
let tenantsService: TenantApplicationsService;
|
|
20
|
-
let sharedService: SharedService;
|
|
21
|
-
let globalErrorHandlerService: GlobalErrorHandlerService;
|
|
22
|
-
|
|
23
|
-
const mockFormattedData = [
|
|
24
|
-
{
|
|
25
|
-
name: 'Admin',
|
|
26
|
-
description:
|
|
27
|
-
'Lorem ipsum dolor sit amet, eos probo brute nostro at, in senserit definitiones per. An mei conceptam delicatissimi',
|
|
28
|
-
rosterType: 'Individual',
|
|
29
|
-
businessRule: 'Enable Rosters',
|
|
30
|
-
roles: 'Admin, Editor, NESC Secretary',
|
|
31
|
-
hasGroup: true,
|
|
32
|
-
menuAction: [
|
|
33
|
-
{
|
|
34
|
-
id: 1,
|
|
35
|
-
label: 'Edit Group Type',
|
|
36
|
-
ariaLabel: 'Edit Group Type',
|
|
37
|
-
iconURL: '',
|
|
38
|
-
toolTip: '',
|
|
39
|
-
isToolTipNeeded: false,
|
|
40
|
-
isDisabled: false,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: 2,
|
|
44
|
-
label: 'Delete Group Type',
|
|
45
|
-
ariaLabel: 'Delete Group Type',
|
|
46
|
-
iconURL: '',
|
|
47
|
-
toolTip: '',
|
|
48
|
-
isToolTipNeeded: false,
|
|
49
|
-
isDisabled: true,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'Main Committee',
|
|
55
|
-
description: 'Main Committee',
|
|
56
|
-
rosterType: 'Individual',
|
|
57
|
-
businessRule: 'Allow Sub-Groups, Enable Rosters, Has Classification',
|
|
58
|
-
roles: 'Chair, Vice Chair, Past Chair, Secretary',
|
|
59
|
-
hasGroup: false,
|
|
60
|
-
menuAction: [
|
|
61
|
-
{
|
|
62
|
-
id: 1,
|
|
63
|
-
label: 'Edit Group Type',
|
|
64
|
-
ariaLabel: 'Edit Group Type',
|
|
65
|
-
iconURL: '',
|
|
66
|
-
toolTip: '',
|
|
67
|
-
isToolTipNeeded: false,
|
|
68
|
-
isDisabled: false,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: 2,
|
|
72
|
-
label: 'Delete Group Type',
|
|
73
|
-
ariaLabel: 'Delete Group Type',
|
|
74
|
-
iconURL: '',
|
|
75
|
-
toolTip: '',
|
|
76
|
-
isToolTipNeeded: false,
|
|
77
|
-
isDisabled: false,
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
];
|
|
82
|
-
const mockColumnSchema = [
|
|
83
|
-
{
|
|
84
|
-
id: 1,
|
|
85
|
-
columnDef: 'groupType',
|
|
86
|
-
heading: 'Group Type',
|
|
87
|
-
columnType: 'TEXT',
|
|
88
|
-
cellData: () => {
|
|
89
|
-
return;
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 2,
|
|
94
|
-
columnDef: 'rosterType',
|
|
95
|
-
heading: 'Roster Type',
|
|
96
|
-
columnType: 'TEXT',
|
|
97
|
-
cellData: () => {
|
|
98
|
-
return;
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: 3,
|
|
103
|
-
columnDef: 'description',
|
|
104
|
-
heading: 'Description',
|
|
105
|
-
columnType: 'TEXT',
|
|
106
|
-
cellData: () => {
|
|
107
|
-
return;
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 4,
|
|
112
|
-
columnDef: 'applicableRoles',
|
|
113
|
-
heading: 'Applicable Roles',
|
|
114
|
-
columnType: 'TEXT',
|
|
115
|
-
cellData: () => {
|
|
116
|
-
return;
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: 5,
|
|
121
|
-
columnDef: 'settings',
|
|
122
|
-
heading: 'Settings',
|
|
123
|
-
columnType: 'TEXT',
|
|
124
|
-
cellData: () => {
|
|
125
|
-
return;
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 6,
|
|
130
|
-
columnDef: 'action',
|
|
131
|
-
heading: 'Actions',
|
|
132
|
-
columnType: 'ACTIONS',
|
|
133
|
-
cellData: () => {
|
|
134
|
-
return;
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
];
|
|
138
|
-
|
|
139
|
-
const mockTenantInfo = {
|
|
140
|
-
appId: 'testAppId',
|
|
141
|
-
appTitle: '',
|
|
142
|
-
appLogo: '',
|
|
143
|
-
appHeading: '',
|
|
144
|
-
appDescription: '',
|
|
145
|
-
status: true,
|
|
146
|
-
features: [
|
|
147
|
-
{
|
|
148
|
-
featureId: '',
|
|
149
|
-
featureName: '',
|
|
150
|
-
isDefault: false,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
beforeEach(() => {
|
|
156
|
-
TestBed.configureTestingModule({
|
|
157
|
-
imports: [
|
|
158
|
-
ViewTenantGroupTypesComponent,
|
|
159
|
-
DataTableComponent,
|
|
160
|
-
MatDialogModule,
|
|
161
|
-
],
|
|
162
|
-
providers: [
|
|
163
|
-
TenantApplicationsService,
|
|
164
|
-
SharedService,
|
|
165
|
-
MatDialog,
|
|
166
|
-
HttpClient,
|
|
167
|
-
HttpHandler,
|
|
168
|
-
GlobalErrorHandlerService,
|
|
169
|
-
],
|
|
170
|
-
});
|
|
171
|
-
fixture = TestBed.createComponent(ViewTenantGroupTypesComponent);
|
|
172
|
-
component = fixture.componentInstance;
|
|
173
|
-
tenantsService = TestBed.inject(TenantApplicationsService);
|
|
174
|
-
sharedService = TestBed.inject(SharedService);
|
|
175
|
-
globalErrorHandlerService = TestBed.inject(GlobalErrorHandlerService);
|
|
176
|
-
fixture.detectChanges();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should create', () => {
|
|
180
|
-
expect(component).toBeTruthy();
|
|
181
|
-
});
|
|
182
|
-
describe('#ngOnInit', () => {
|
|
183
|
-
it('should fetch group types on initialization', () => {
|
|
184
|
-
spyOn(tenantsService, 'getSelectedTenantInformation').and.returnValue(
|
|
185
|
-
mockTenantInfo
|
|
186
|
-
);
|
|
187
|
-
spyOn(tenantsService, 'getGroupTypes').and.returnValue(
|
|
188
|
-
new Observable((subscriber) => {
|
|
189
|
-
subscriber.next(TenantsMocks.mockGroupTypeResponse);
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
component.ngOnInit();
|
|
193
|
-
expect(tenantsService.getGroupTypes).toHaveBeenCalledWith('testAppId');
|
|
194
|
-
expect(component.groupTypes).toEqual(mockFormattedData);
|
|
195
|
-
expect(component.columnSchema.length).toEqual(mockColumnSchema.length);
|
|
196
|
-
expect(component.columnSchema[0].columnDef).toEqual(
|
|
197
|
-
mockColumnSchema[0].columnDef
|
|
198
|
-
);
|
|
199
|
-
expect(component.columnSchema[1].columnDef).toEqual(
|
|
200
|
-
mockColumnSchema[1].columnDef
|
|
201
|
-
);
|
|
202
|
-
});
|
|
203
|
-
it('should call get group types if isGroupTypeAddedOrModified', () => {
|
|
204
|
-
const getGroupTypesSpyOn = spyOn(component, 'getGroupTypes');
|
|
205
|
-
component['tenantAppService'].isGroupTypeAddedOrModified.next(true);
|
|
206
|
-
expect(getGroupTypesSpyOn).toHaveBeenCalledTimes(1);
|
|
207
|
-
});
|
|
208
|
-
it('should show a custom error while appId is missing in the payload', () => {
|
|
209
|
-
const mockGroupTypesErrorResponse = {
|
|
210
|
-
error: {
|
|
211
|
-
status: false,
|
|
212
|
-
message: 'Tenant Details not found.',
|
|
213
|
-
body: { errorCodes: ['2050'] },
|
|
214
|
-
},
|
|
215
|
-
status: false,
|
|
216
|
-
statusText: 'OK',
|
|
217
|
-
};
|
|
218
|
-
spyOn(tenantsService, 'getGroupTypes').and.returnValue(
|
|
219
|
-
new Observable((subscriber) => {
|
|
220
|
-
subscriber.error(mockGroupTypesErrorResponse);
|
|
221
|
-
})
|
|
222
|
-
);
|
|
223
|
-
spyOn(sharedService, 'handleErrors').and.callThrough();
|
|
224
|
-
component.ngOnInit();
|
|
225
|
-
expect(tenantsService.getGroupTypes).toHaveBeenCalled();
|
|
226
|
-
expect(sharedService.handleErrors).toHaveBeenCalled();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('should throw and handle global error in retrieving getGroupTypes', () => {
|
|
230
|
-
const mockServerErrorResponse = new HttpErrorResponse({
|
|
231
|
-
error: 'test',
|
|
232
|
-
});
|
|
233
|
-
spyOn(tenantsService, 'getGroupTypes').and.returnValue(
|
|
234
|
-
new Observable((subscriber) => {
|
|
235
|
-
subscriber.error(mockServerErrorResponse);
|
|
236
|
-
})
|
|
237
|
-
);
|
|
238
|
-
spyOn(globalErrorHandlerService, 'handleError');
|
|
239
|
-
component.ngOnInit();
|
|
240
|
-
expect(globalErrorHandlerService.handleError).toHaveBeenCalledWith(
|
|
241
|
-
mockServerErrorResponse
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
describe('#initializeColumnSchema', () => {
|
|
247
|
-
it('should return elements groupType attribute value', () => {
|
|
248
|
-
component.initializeColumnSchema();
|
|
249
|
-
const response = component.columnSchema[0]?.cellData({
|
|
250
|
-
name: 'Main Committee',
|
|
251
|
-
});
|
|
252
|
-
expect(response).toEqual('Main Committee');
|
|
253
|
-
});
|
|
254
|
-
it('should initialize column schema with correct properties', () => {
|
|
255
|
-
component.initializeColumnSchema();
|
|
256
|
-
expect(component.columnSchema.length).toBe(6);
|
|
257
|
-
expect(component.columnSchema[0].columnDef).toBe('groupType');
|
|
258
|
-
expect(component.columnSchema[0].heading).toBeDefined();
|
|
259
|
-
expect(component.columnSchema[0].columnType).toBe(TableColumnType.TEXT);
|
|
260
|
-
expect(component.columnSchema[0].cellData({ name: 'Test Group' })).toBe(
|
|
261
|
-
'Test Group'
|
|
262
|
-
);
|
|
263
|
-
expect(component.columnSchema[1].columnDef).toBe('rosterType');
|
|
264
|
-
expect(component.columnSchema[1].heading).toBeDefined();
|
|
265
|
-
expect(component.columnSchema[1].columnType).toBe(TableColumnType.TEXT);
|
|
266
|
-
expect(
|
|
267
|
-
component.columnSchema[1].cellData({ rosterType: 'Test Roster' })
|
|
268
|
-
).toBe('Test Roster');
|
|
269
|
-
});
|
|
270
|
-
it('should return elements rosterType attribute value', () => {
|
|
271
|
-
component.initializeColumnSchema();
|
|
272
|
-
const response = component.columnSchema[1]?.cellData({
|
|
273
|
-
rosterType: 'User',
|
|
274
|
-
});
|
|
275
|
-
expect(response).toEqual('User');
|
|
276
|
-
});
|
|
277
|
-
it('should return elements description attribute value', () => {
|
|
278
|
-
component.initializeColumnSchema();
|
|
279
|
-
const response = component.columnSchema[2]?.cellData({
|
|
280
|
-
description: 'test description',
|
|
281
|
-
});
|
|
282
|
-
expect(response).toBe('test description');
|
|
283
|
-
});
|
|
284
|
-
it('should return elements roles attribute value', () => {
|
|
285
|
-
component.initializeColumnSchema();
|
|
286
|
-
const response = component.columnSchema[3]?.cellData({
|
|
287
|
-
roles: 'Editor',
|
|
288
|
-
});
|
|
289
|
-
expect(response).toBe('Editor');
|
|
290
|
-
});
|
|
291
|
-
it('should return elements businessRule attribute value', () => {
|
|
292
|
-
component.initializeColumnSchema();
|
|
293
|
-
const response = component.columnSchema[4]?.cellData({
|
|
294
|
-
businessRule: 'Allow Sub-Group',
|
|
295
|
-
});
|
|
296
|
-
expect(response).toBe('Allow Sub-Group');
|
|
297
|
-
});
|
|
298
|
-
it('should return elements menuAction attribute value', () => {
|
|
299
|
-
component.initializeColumnSchema();
|
|
300
|
-
const response = component.columnSchema[5]?.cellData({
|
|
301
|
-
menuAction: 'Test menu action',
|
|
302
|
-
});
|
|
303
|
-
expect(response).toBe('Test menu action');
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe('#formatGroupTypesTableData', () => {
|
|
308
|
-
it('should format group types data correctly', () => {
|
|
309
|
-
const formattedData = component.formatGroupTypesTableData(
|
|
310
|
-
TenantsMocks.mockGroupTypeResponse
|
|
311
|
-
);
|
|
312
|
-
expect(formattedData).toEqual(mockFormattedData);
|
|
313
|
-
});
|
|
314
|
-
it('should format group types data correctly if roles are null', () => {
|
|
315
|
-
const mockGroupTypeResponse = {
|
|
316
|
-
status: true,
|
|
317
|
-
message: 'SUCCESS',
|
|
318
|
-
body: [
|
|
319
|
-
{
|
|
320
|
-
configFieldId: 'GT_NESC_ae99d4a7-4e31-4a6f-b30a-8102121f8833',
|
|
321
|
-
configFieldValue: {
|
|
322
|
-
name: 'Admin',
|
|
323
|
-
hierarchy: 0,
|
|
324
|
-
description:
|
|
325
|
-
'Lorem ipsum dolor sit amet, eos probo brute nostro at, in senserit definitiones per. An mei conceptam delicatissimi',
|
|
326
|
-
businessRule: {
|
|
327
|
-
allowSubGroup: false,
|
|
328
|
-
allowRoster: true,
|
|
329
|
-
rosterType: 'Individual',
|
|
330
|
-
allowAlternateVoting: false,
|
|
331
|
-
manageRosterInApp: true,
|
|
332
|
-
allowedGroupType: [],
|
|
333
|
-
isAdmin: true,
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
roles: null,
|
|
337
|
-
hasGroup: true,
|
|
338
|
-
},
|
|
339
|
-
],
|
|
340
|
-
};
|
|
341
|
-
const mockFormattedData = [
|
|
342
|
-
{
|
|
343
|
-
name: 'Admin',
|
|
344
|
-
description:
|
|
345
|
-
'Lorem ipsum dolor sit amet, eos probo brute nostro at, in senserit definitiones per. An mei conceptam delicatissimi',
|
|
346
|
-
rosterType: 'Individual',
|
|
347
|
-
businessRule: 'Enable Rosters',
|
|
348
|
-
roles: '',
|
|
349
|
-
hasGroup: true,
|
|
350
|
-
menuAction: [
|
|
351
|
-
{
|
|
352
|
-
id: 1,
|
|
353
|
-
label: 'Edit Group Type',
|
|
354
|
-
ariaLabel: 'Edit Group Type',
|
|
355
|
-
iconURL: '',
|
|
356
|
-
toolTip: '',
|
|
357
|
-
isToolTipNeeded: false,
|
|
358
|
-
isDisabled: false,
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
id: 2,
|
|
362
|
-
label: 'Delete Group Type',
|
|
363
|
-
ariaLabel: 'Delete Group Type',
|
|
364
|
-
iconURL: '',
|
|
365
|
-
toolTip: '',
|
|
366
|
-
isToolTipNeeded: false,
|
|
367
|
-
isDisabled: true,
|
|
368
|
-
},
|
|
369
|
-
],
|
|
370
|
-
},
|
|
371
|
-
];
|
|
372
|
-
const formattedData = component.formatGroupTypesTableData(
|
|
373
|
-
mockGroupTypeResponse
|
|
374
|
-
);
|
|
375
|
-
expect(formattedData).toEqual(mockFormattedData);
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
describe('#transformBusinessRule', () => {
|
|
380
|
-
it('should transform business rule keys with true value to required strings', () => {
|
|
381
|
-
const businessRule = {
|
|
382
|
-
allowSubGroup: true,
|
|
383
|
-
allowRoster: true,
|
|
384
|
-
rosterType: 'Individual',
|
|
385
|
-
allowAlternateVoting: false,
|
|
386
|
-
manageRosterInApp: true,
|
|
387
|
-
allowedGroupType: [
|
|
388
|
-
'GT_NESC_e88d7458-f805-49ad-af28-6ac645ac5a92',
|
|
389
|
-
'GT_NESC_6645f6e6-a033-4fa4-9b30-724a7e6a6971',
|
|
390
|
-
'GT_NESC_27242ca1-0fd8-4470-9a54-67f5445884c1',
|
|
391
|
-
],
|
|
392
|
-
hasClassification: true,
|
|
393
|
-
};
|
|
394
|
-
const businessRuleString = component.transformBusinessRule(businessRule);
|
|
395
|
-
expect(businessRuleString).toBe(
|
|
396
|
-
'Allow Sub-Groups, Enable Rosters, Has Classification'
|
|
397
|
-
);
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
describe('#ngOnDestroy', () => {
|
|
402
|
-
it('should unsubscribe onDestroy', () => {
|
|
403
|
-
spyOn(component.destroy$, 'next');
|
|
404
|
-
spyOn(component.destroy$, 'unsubscribe');
|
|
405
|
-
component.ngOnDestroy();
|
|
406
|
-
expect(component.destroy$.next).toHaveBeenCalledWith(true);
|
|
407
|
-
expect(component.destroy$.unsubscribe).toHaveBeenCalled();
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
});
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import {
|
|
4
|
-
DataTableComponent,
|
|
5
|
-
Menu,
|
|
6
|
-
TableColumnSchema,
|
|
7
|
-
TableColumnType,
|
|
8
|
-
} from '@ieeesa-npm/presentation';
|
|
9
|
-
import { Subject, takeUntil } from 'rxjs';
|
|
10
|
-
import * as screenText from '../../assets/constants.json';
|
|
11
|
-
import { TenantApplicationsService } from '../../services/tenant-applications.service';
|
|
12
|
-
import { SharedService } from '@ieeesa-npm/shared';
|
|
13
|
-
import {
|
|
14
|
-
GroupTypeDetails,
|
|
15
|
-
GroupTypeSettings,
|
|
16
|
-
ViewGroupTypeResponse,
|
|
17
|
-
ViewGroupTypesConfiguration,
|
|
18
|
-
} from '../../models/view-tenant-group-types.model';
|
|
19
|
-
import { Role } from '../../models/roles-and-permissions.model';
|
|
20
|
-
import { GroupRosterType } from '@ieeesa-npm/groups';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Component for viewing and managing tenant group types. Fetches the configured group types associated to the selected tenant and displays in tabular view.
|
|
24
|
-
* @export
|
|
25
|
-
* @class ViewTenantGroupTypesComponent
|
|
26
|
-
* @implements {OnInit}
|
|
27
|
-
*/
|
|
28
|
-
@Component({
|
|
29
|
-
selector: 'ieeesa-view-tenant-group-types',
|
|
30
|
-
standalone: true,
|
|
31
|
-
imports: [CommonModule, DataTableComponent],
|
|
32
|
-
templateUrl: './view-tenant-group-types.component.html',
|
|
33
|
-
styleUrls: ['./view-tenant-group-types.component.scss'],
|
|
34
|
-
encapsulation: ViewEncapsulation.None,
|
|
35
|
-
})
|
|
36
|
-
export class ViewTenantGroupTypesComponent implements OnInit, OnDestroy {
|
|
37
|
-
destroy$: Subject<boolean> = new Subject<boolean>();
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
constants: any = screenText;
|
|
40
|
-
columnHeading = this.constants?.viewGroupTypes?.tableColumns?.heading;
|
|
41
|
-
settings = this.constants?.viewGroupTypes?.settings;
|
|
42
|
-
tableRowActions: Menu[] = this.constants?.viewGroupTypes?.actionMenuItems;
|
|
43
|
-
columnSchema: TableColumnSchema[] = [];
|
|
44
|
-
groupTypes: GroupTypeDetails[] = [];
|
|
45
|
-
appId = '';
|
|
46
|
-
headerElementClassName = '.ieeesa-header';
|
|
47
|
-
constructor(
|
|
48
|
-
// eslint-disable-next-line no-unused-vars
|
|
49
|
-
private tenantAppService: TenantApplicationsService,
|
|
50
|
-
// eslint-disable-next-line no-unused-vars
|
|
51
|
-
private sharedService: SharedService // eslint-disable-next-line no-empty-function
|
|
52
|
-
) {}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Fetches group types data from the server and initializes column schema.
|
|
56
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
57
|
-
*/
|
|
58
|
-
ngOnInit(): void {
|
|
59
|
-
this.appId = this.tenantAppService.getSelectedTenantInformation()
|
|
60
|
-
?.appId as string;
|
|
61
|
-
this.getGroupTypes();
|
|
62
|
-
this.tenantAppService.isGroupTypeAddedOrModified
|
|
63
|
-
.pipe(takeUntil(this.destroy$))
|
|
64
|
-
.subscribe((value) => {
|
|
65
|
-
if (value) {
|
|
66
|
-
this.getGroupTypes();
|
|
67
|
-
this.tenantAppService.isGroupTypeAddedOrModified.next(false);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get group types from tenant application service.
|
|
73
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
74
|
-
*/
|
|
75
|
-
getGroupTypes(): void {
|
|
76
|
-
this.tenantAppService
|
|
77
|
-
.getGroupTypes(this.appId)
|
|
78
|
-
.pipe(takeUntil(this.destroy$))
|
|
79
|
-
.subscribe({
|
|
80
|
-
next: (response: ViewGroupTypeResponse) => {
|
|
81
|
-
this.initializeColumnSchema();
|
|
82
|
-
this.groupTypes = this.formatGroupTypesTableData(response);
|
|
83
|
-
this.tenantAppService.setGroupTypeDetails(response);
|
|
84
|
-
},
|
|
85
|
-
error: (error) => {
|
|
86
|
-
this.sharedService.handleErrors(
|
|
87
|
-
error,
|
|
88
|
-
this.constants?.viewGroupTypes?.errors
|
|
89
|
-
);
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Formats raw group types data into a required format for display.
|
|
96
|
-
* @param {ViewGroupTypeResponse} groupTypeRes
|
|
97
|
-
* @return {GroupTypeDetails[]}
|
|
98
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
99
|
-
*/
|
|
100
|
-
formatGroupTypesTableData(
|
|
101
|
-
groupTypeRes: ViewGroupTypeResponse
|
|
102
|
-
): GroupTypeDetails[] {
|
|
103
|
-
const formattedData: GroupTypeDetails[] = [];
|
|
104
|
-
groupTypeRes?.body?.forEach((item: ViewGroupTypesConfiguration) => {
|
|
105
|
-
if (
|
|
106
|
-
item?.configFieldValue?.businessRule?.rosterType !==
|
|
107
|
-
GroupRosterType?.SYSTEM_USER
|
|
108
|
-
) {
|
|
109
|
-
const { configFieldValue, roles, hasGroup } = item;
|
|
110
|
-
const { name, description, businessRule } = configFieldValue;
|
|
111
|
-
const { rosterType, ...restBusinessRule } = businessRule as {
|
|
112
|
-
rosterType: string;
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
};
|
|
116
|
-
const businessRuleString = this.transformBusinessRule(restBusinessRule);
|
|
117
|
-
const roleNames = roles
|
|
118
|
-
? roles?.map((role: Role) => role?.roleName).join(', ')
|
|
119
|
-
: '';
|
|
120
|
-
const menuAction = JSON.parse(JSON.stringify(this.tableRowActions));
|
|
121
|
-
menuAction[1].isDisabled = hasGroup;
|
|
122
|
-
|
|
123
|
-
formattedData.push({
|
|
124
|
-
name,
|
|
125
|
-
description,
|
|
126
|
-
rosterType,
|
|
127
|
-
businessRule: businessRuleString,
|
|
128
|
-
roles: roleNames,
|
|
129
|
-
hasGroup: item.hasGroup,
|
|
130
|
-
menuAction,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return formattedData;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Transforms business rule to required format in string.
|
|
139
|
-
* @param {*} rule
|
|
140
|
-
* @return {string}
|
|
141
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
142
|
-
*/
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
transformBusinessRule(rule: any): string {
|
|
145
|
-
const ruleStringArray: string[] = [];
|
|
146
|
-
for (const setting of Object.values(GroupTypeSettings)) {
|
|
147
|
-
if (rule[setting] === true) {
|
|
148
|
-
ruleStringArray.push(this.settings[setting]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return ruleStringArray.join(', ');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Initializes table column schema to display group types in tabular view.
|
|
156
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
157
|
-
*/
|
|
158
|
-
initializeColumnSchema(): void {
|
|
159
|
-
this.columnSchema = [
|
|
160
|
-
{
|
|
161
|
-
id: 1,
|
|
162
|
-
columnDef: 'groupType',
|
|
163
|
-
heading: this.columnHeading?.groupType,
|
|
164
|
-
columnType: TableColumnType.TEXT,
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
-
cellData: (element: any) => `${element.name}`,
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
id: 2,
|
|
170
|
-
columnDef: 'rosterType',
|
|
171
|
-
heading: this.columnHeading?.rosterType,
|
|
172
|
-
columnType: TableColumnType.TEXT,
|
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
-
cellData: (element: any) => `${element.rosterType}`,
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
id: 3,
|
|
178
|
-
columnDef: 'description',
|
|
179
|
-
heading: this.columnHeading?.description,
|
|
180
|
-
columnType: TableColumnType.TEXT,
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
-
cellData: (element: any) => `${element.description}`,
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
id: 4,
|
|
186
|
-
columnDef: 'applicableRoles',
|
|
187
|
-
heading: this.columnHeading?.applicableRoles,
|
|
188
|
-
columnType: TableColumnType.TEXT,
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
-
cellData: (element: any) => `${element.roles}`,
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: 5,
|
|
194
|
-
columnDef: 'settings',
|
|
195
|
-
heading: this.columnHeading?.settings,
|
|
196
|
-
columnType: TableColumnType.TEXT,
|
|
197
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
-
cellData: (element: any) => `${element.businessRule}`,
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: 6,
|
|
202
|
-
columnDef: 'action',
|
|
203
|
-
heading: this.columnHeading?.action,
|
|
204
|
-
columnType: TableColumnType.ACTIONS,
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
-
cellData: (element: any) => `${element.menuAction}`,
|
|
207
|
-
},
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Performs necessary cleanup tasks, such as unsubscribing from subscription when the component is being destroyed.
|
|
213
|
-
* @memberof ViewTenantGroupTypesComponent
|
|
214
|
-
*/
|
|
215
|
-
ngOnDestroy(): void {
|
|
216
|
-
this.destroy$?.next(true);
|
|
217
|
-
this.destroy$?.unsubscribe();
|
|
218
|
-
}
|
|
219
|
-
}
|