@ieeesa-npm/tenants 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/.eslintrc.json +31 -0
  2. package/ng-package.json +8 -0
  3. package/package.json +12 -25
  4. package/src/lib/assets/constants.json +454 -0
  5. package/src/lib/assets/tenant-validations.ts +18 -0
  6. package/src/lib/assets/tenants-mock.ts +1240 -0
  7. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +15 -0
  8. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +44 -0
  9. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +574 -0
  10. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +602 -0
  11. package/src/lib/components/create-modify-role/create-modify-role.component.html +15 -0
  12. package/src/lib/components/create-modify-role/create-modify-role.component.scss +83 -0
  13. package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +346 -0
  14. package/src/lib/components/create-modify-role/create-modify-role.component.ts +321 -0
  15. package/src/lib/components/create-tenant-application/create-tenant-application.component.html +18 -0
  16. package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +73 -0
  17. package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +775 -0
  18. package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +638 -0
  19. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +22 -0
  20. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +79 -0
  21. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +716 -0
  22. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +504 -0
  23. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +44 -0
  24. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +16 -0
  25. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +115 -0
  26. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +109 -0
  27. package/src/lib/components/view-tenant-details/view-tenant-details.component.html +195 -0
  28. package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +163 -0
  29. package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +1221 -0
  30. package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +876 -0
  31. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +10 -0
  32. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +44 -0
  33. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +410 -0
  34. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +219 -0
  35. package/src/lib/components/view-tenants-list/view-tenants-list.component.html +32 -0
  36. package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +35 -0
  37. package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +464 -0
  38. package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +388 -0
  39. package/src/lib/models/app-type-config.model.ts +14 -0
  40. package/src/lib/models/app-type.model.ts +5 -0
  41. package/src/lib/models/create-group-type-config.model.ts +18 -0
  42. package/src/lib/models/create-group-type.model.ts +46 -0
  43. package/src/lib/models/feature-permission-id.model.ts +6 -0
  44. package/src/lib/models/features.model.ts +15 -0
  45. package/src/lib/models/form-status.model.ts +5 -0
  46. package/src/lib/models/permission-type.model.ts +9 -0
  47. package/src/lib/models/role-menu-action.model.ts +5 -0
  48. package/src/lib/models/role-type.model.ts +34 -0
  49. package/src/lib/models/roles-and-permissions-table-type.model.ts +5 -0
  50. package/src/lib/models/roles-and-permissions.model.ts +113 -0
  51. package/src/lib/models/route-config.model.ts +4 -0
  52. package/src/lib/models/table-column-schema-view-tenant-list.model.ts +21 -0
  53. package/src/lib/models/tenant-function-type.model.ts +10 -0
  54. package/src/lib/models/tenant.model.ts +47 -0
  55. package/src/lib/models/tenants-permission.model.ts +9 -0
  56. package/src/lib/models/update-tenant-status.model.ts +12 -0
  57. package/src/lib/models/view-tenant-group-types.model.ts +34 -0
  58. package/src/lib/services/tenant-applications.service.spec.ts +1245 -0
  59. package/src/lib/services/tenant-applications.service.ts +798 -0
  60. package/src/lib/services/tenant-permissions-map.service.spec.ts +25 -0
  61. package/src/lib/services/tenant-permissions-map.service.ts +28 -0
  62. package/src/lib/services/tenant-permissions.service.spec.ts +62 -0
  63. package/src/lib/services/tenant-permissions.service.ts +49 -0
  64. package/src/lib/tenant-applications.component.html +0 -0
  65. package/src/lib/tenant-applications.component.scss +0 -0
  66. package/src/lib/tenant-applications.component.spec.ts +28 -0
  67. package/src/lib/tenant-applications.component.ts +12 -0
  68. package/src/lib/tenant-applications.module.ts +8 -0
  69. package/{public-api.d.ts → src/public-api.ts} +40 -30
  70. package/tsconfig.lib.json +14 -0
  71. package/tsconfig.lib.prod.json +10 -0
  72. package/tsconfig.spec.json +14 -0
  73. package/esm2022/ieeesa-npm-tenants.mjs +0 -5
  74. package/esm2022/lib/assets/constants.json +0 -390
  75. package/esm2022/lib/assets/tenant-validations.mjs +0 -13
  76. package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +0 -280
  77. package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +0 -512
  78. package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +0 -391
  79. package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +0 -95
  80. package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +0 -708
  81. package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +0 -174
  82. package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +0 -334
  83. package/esm2022/lib/models/app-type-config.model.mjs +0 -2
  84. package/esm2022/lib/models/app-type.model.mjs +0 -7
  85. package/esm2022/lib/models/feature-permission-id.model.mjs +0 -8
  86. package/esm2022/lib/models/features.model.mjs +0 -2
  87. package/esm2022/lib/models/form-status.model.mjs +0 -7
  88. package/esm2022/lib/models/permission-type.model.mjs +0 -12
  89. package/esm2022/lib/models/role-menu-action.model.mjs +0 -7
  90. package/esm2022/lib/models/role-type.model.mjs +0 -2
  91. package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +0 -7
  92. package/esm2022/lib/models/roles-and-permissions.model.mjs +0 -2
  93. package/esm2022/lib/models/route-config.model.mjs +0 -2
  94. package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +0 -16
  95. package/esm2022/lib/models/tenant-function-type.model.mjs +0 -10
  96. package/esm2022/lib/models/tenant.model.mjs +0 -2
  97. package/esm2022/lib/models/tenants-permission.model.mjs +0 -2
  98. package/esm2022/lib/models/update-tenant-status.model.mjs +0 -2
  99. package/esm2022/lib/models/view-tenant-group-types.model.mjs +0 -9
  100. package/esm2022/lib/services/tenant-applications.service.mjs +0 -542
  101. package/esm2022/lib/services/tenant-permissions-map.service.mjs +0 -36
  102. package/esm2022/lib/services/tenant-permissions.service.mjs +0 -38
  103. package/esm2022/lib/tenant-applications.component.mjs +0 -14
  104. package/esm2022/lib/tenant-applications.module.mjs +0 -16
  105. package/esm2022/public-api.mjs +0 -34
  106. package/fesm2022/ieeesa-npm-tenants.mjs +0 -3565
  107. package/fesm2022/ieeesa-npm-tenants.mjs.map +0 -1
  108. package/index.d.ts +0 -5
  109. package/lib/assets/tenant-validations.d.ts +0 -11
  110. package/lib/components/create-modify-role/create-modify-role.component.d.ts +0 -103
  111. package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +0 -128
  112. package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +0 -106
  113. package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +0 -408
  114. package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +0 -216
  115. package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +0 -58
  116. package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +0 -134
  117. package/lib/models/app-type-config.model.d.ts +0 -14
  118. package/lib/models/app-type.model.d.ts +0 -4
  119. package/lib/models/feature-permission-id.model.d.ts +0 -4
  120. package/lib/models/features.model.d.ts +0 -15
  121. package/lib/models/form-status.model.d.ts +0 -4
  122. package/lib/models/permission-type.model.d.ts +0 -8
  123. package/lib/models/role-menu-action.model.d.ts +0 -4
  124. package/lib/models/role-type.model.d.ts +0 -27
  125. package/lib/models/roles-and-permissions-table-type.model.d.ts +0 -4
  126. package/lib/models/roles-and-permissions.model.d.ts +0 -119
  127. package/lib/models/route-config.model.d.ts +0 -4
  128. package/lib/models/table-column-schema-view-tenant-list.model.d.ts +0 -20
  129. package/lib/models/tenant-function-type.model.d.ts +0 -7
  130. package/lib/models/tenant.model.d.ts +0 -51
  131. package/lib/models/tenants-permission.model.d.ts +0 -9
  132. package/lib/models/update-tenant-status.model.d.ts +0 -14
  133. package/lib/models/view-tenant-group-types.model.d.ts +0 -27
  134. package/lib/services/tenant-applications.service.d.ts +0 -357
  135. package/lib/services/tenant-permissions-map.service.d.ts +0 -13
  136. package/lib/services/tenant-permissions.service.d.ts +0 -22
  137. package/lib/tenant-applications.component.d.ts +0 -5
  138. package/lib/tenant-applications.module.d.ts +0 -6
@@ -0,0 +1,602 @@
1
+ import {
2
+ Component,
3
+ ComponentRef,
4
+ ElementRef,
5
+ EventEmitter,
6
+ OnDestroy,
7
+ OnInit,
8
+ Output,
9
+ Renderer2,
10
+ ViewChild,
11
+ ViewContainerRef,
12
+ ViewEncapsulation,
13
+ } from '@angular/core';
14
+ import { CommonModule } from '@angular/common';
15
+ import { FormGroup, Validators } from '@angular/forms';
16
+ import { Subject, takeUntil } from 'rxjs';
17
+ import { SharedService, LOV, FormUtilityService } from '@ieeesa-npm/shared';
18
+ import {
19
+ AlignType,
20
+ CheckboxOption,
21
+ FieldConfig,
22
+ FormControlType,
23
+ FormGrid,
24
+ FormModel,
25
+ RadioOption,
26
+ CheckboxComponent,
27
+ DynamicFormComponent,
28
+ } from '@ieeesa-npm/presentation';
29
+ import { GroupRosterType, RoleType } from '@ieeesa-npm/groups';
30
+ import { AlertType } from '@ieeesa-npm/utility';
31
+ import * as screenTexts from '../../assets/constants.json';
32
+ import { GroupTypeValidation } from '../../assets/tenant-validations';
33
+ import { TenantApplicationsService } from '../../services/tenant-applications.service';
34
+ import {
35
+ Settings,
36
+ RosterTypeLOVCode,
37
+ } from '../../models/create-group-type-config.model';
38
+ import { Role } from '../../models/roles-and-permissions.model';
39
+ import { TenantFunctionType } from '../../models/tenant-function-type.model';
40
+ import {
41
+ ViewGroupTypeResponse,
42
+ ViewGroupTypesConfiguration,
43
+ } from '../../models/view-tenant-group-types.model';
44
+ import {
45
+ ConfigFieldValue,
46
+ CreateGroupTypeRequestPayload,
47
+ CreateGroupTypeResponse,
48
+ CreatedOrModifiedGroupTypeInfo,
49
+ GetRosterTypeOrSettingsResponse,
50
+ } from '../../models/create-group-type.model';
51
+ import { FormStatus } from '../../models/form-status.model';
52
+
53
+ /**
54
+ * CreateModifyGroupTypeComponent uses DynamicFormComponent to build create add group type form or edit group type form and implement the functionalities of submission of form and handling success and error scenarios.
55
+ * @class CreateModifyGroupTypeComponent
56
+ * @implements {OnInit}
57
+ * @implements {OnDestroy}
58
+ */
59
+ @Component({
60
+ selector: 'ieeesa-create-modify-group-type',
61
+ standalone: true,
62
+ imports: [CommonModule, DynamicFormComponent],
63
+ templateUrl: './create-modify-group-type.component.html',
64
+ styleUrls: ['./create-modify-group-type.component.scss'],
65
+ encapsulation: ViewEncapsulation.None,
66
+ })
67
+ export class CreateModifyGroupTypeComponent implements OnInit, OnDestroy {
68
+ destroy$ = new Subject<boolean>();
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ constants: any = screenTexts;
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ createGroupTypeScreenTexts: any = this.constants?.createGroupType;
73
+ leftButtonLabel = this.createGroupTypeScreenTexts?.label?.leftButtonLabel;
74
+ rightButtonLabel = this.createGroupTypeScreenTexts?.label?.rightButtonLabel;
75
+ colWidth: FormGrid = { xs: 12, xl: 12, sm: 12, md: 12, lg: 12 };
76
+ createGroupTypeFormGroup!: FormModel;
77
+ createModifyGroupTypeFormGroupRef!: FormGroup;
78
+ actionButtonAlign = AlignType.LEFT;
79
+ tenantFunctionType!: TenantFunctionType;
80
+ isRootGroupOptions = [
81
+ {
82
+ id: 1,
83
+ label: this.createGroupTypeScreenTexts?.isRootGroupOptions?.yes,
84
+ checked: false,
85
+ },
86
+ {
87
+ id: 2,
88
+ label: this.createGroupTypeScreenTexts?.isRootGroupOptions?.no,
89
+ checked: true,
90
+ },
91
+ ];
92
+ rosterTypeOptions: RadioOption[] = [];
93
+ settingOptions: CheckboxOption[] = [];
94
+ officerRolesOptions: CheckboxOption[] = [];
95
+ memberLevelOptions: CheckboxOption[] = [];
96
+ allowedSubGroupTypesOptions: CheckboxOption[] = [];
97
+ allowedSubGroupTypesFieldConfig!: FieldConfig;
98
+ appId!: string;
99
+ groupTypeDetails!: ViewGroupTypeResponse;
100
+ selectedGroupTypeInfo!: CreatedOrModifiedGroupTypeInfo;
101
+ @ViewChild(DynamicFormComponent)
102
+ dynamicFormComponent!: DynamicFormComponent;
103
+ @ViewChild(DynamicFormComponent, { read: ViewContainerRef })
104
+ dynamicFormComponentViewRef!: ViewContainerRef;
105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
+ componentRef!: ComponentRef<any>;
107
+ /**
108
+ * Event emitter for form submission response.
109
+ * @memberof CreateModifyGroupTypeComponent
110
+ */
111
+ @Output() submitFormResponse = new EventEmitter();
112
+ /**
113
+ * Event emitter for form cancel action.
114
+ * @memberof CreateModifyGroupTypeComponent
115
+ */
116
+ @Output() formCancel = new EventEmitter();
117
+ constructor(
118
+ // eslint-disable-next-line no-unused-vars
119
+ private tenantAppService: TenantApplicationsService,
120
+ // eslint-disable-next-line no-unused-vars
121
+ private sharedService: SharedService,
122
+ // eslint-disable-next-line no-unused-vars
123
+ private renderer: Renderer2,
124
+ // eslint-disable-next-line no-unused-vars
125
+ private elementRef: ElementRef,
126
+ // eslint-disable-next-line no-unused-vars
127
+ private formUtilityService: FormUtilityService // eslint-disable-next-line no-empty-function,
128
+ ) {}
129
+ /**
130
+ * Sets appId, tenantFunctionType and calls getGroupTypes() & getRosterTypes() to get group and roster types.
131
+ * @memberof CreateModifyGroupTypeComponent
132
+ */
133
+ ngOnInit(): void {
134
+ this.appId = this.tenantAppService.getSelectedTenantInformation()
135
+ ?.appId as string;
136
+ this.tenantFunctionType = this.tenantAppService?.getTenantFunctionType();
137
+ this.selectedGroupTypeInfo =
138
+ this.tenantAppService?.getNewlyCreatedGroupTypeInfo();
139
+ this.getGroupTypes();
140
+ this.getRosterTypes();
141
+ }
142
+ /**
143
+ * Gets the list of roster types and updates the form control.
144
+ * @memberof CreateModifyGroupTypeComponent
145
+ */
146
+ getRosterTypes(): void {
147
+ this.tenantAppService
148
+ .getRosterType()
149
+ .pipe(takeUntil(this.destroy$))
150
+ .subscribe({
151
+ next: (response: GetRosterTypeOrSettingsResponse) => {
152
+ if (response?.status) {
153
+ this.getSettings();
154
+ const rosterTypeList = response.body as LOV[];
155
+ rosterTypeList.map((rosterType: LOV) =>
156
+ this.rosterTypeOptions.push({
157
+ id: rosterType.lovId,
158
+ label: rosterType.lovDesc,
159
+ checked: rosterType.lovCode === RosterTypeLOVCode.INDIVIDUAL,
160
+ })
161
+ );
162
+ }
163
+ },
164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
+ error: (error: any) => {
166
+ this.sharedService.handleErrors(
167
+ error,
168
+ this.createGroupTypeScreenTexts.errors
169
+ );
170
+ },
171
+ });
172
+ }
173
+ /**
174
+ * Gets the list of settings and updates the form control.
175
+ * @memberof CreateModifyGroupTypeComponent
176
+ */
177
+ getSettings(): void {
178
+ this.tenantAppService
179
+ .getGroupTypeSettings()
180
+ .pipe(takeUntil(this.destroy$))
181
+ .subscribe({
182
+ next: (response: GetRosterTypeOrSettingsResponse) => {
183
+ if (response.status) {
184
+ this.getRoles();
185
+ const settingsList = response.body as LOV[];
186
+ settingsList.map((setting: LOV) => {
187
+ this.settingOptions.push({
188
+ id: setting.lovId,
189
+ name: setting.lovDesc,
190
+ checked: false,
191
+ disabled: false,
192
+ });
193
+ });
194
+ }
195
+ },
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ error: (error: any) => {
198
+ this.sharedService.handleErrors(
199
+ error,
200
+ this.createGroupTypeScreenTexts.errors
201
+ );
202
+ },
203
+ });
204
+ }
205
+ /**
206
+ * Gets the list of roles and updates the form control.
207
+ * @memberof CreateModifyGroupTypeComponent
208
+ */
209
+ getRoles(): void {
210
+ this.tenantAppService
211
+ .getRoles(this.appId)
212
+ .pipe(takeUntil(this.destroy$))
213
+ .subscribe({
214
+ next: (response) => {
215
+ if (response?.status) {
216
+ const rolesList = response?.body as Role[];
217
+ rolesList.map((role: Role) => {
218
+ if (role.roleTypeName === RoleType.OFFICER) {
219
+ this.officerRolesOptions.push({
220
+ id: role.roleId,
221
+ name: role.roleName,
222
+ checked: false,
223
+ disabled: false,
224
+ });
225
+ } else if (role.roleTypeName === RoleType.MEMBER_LEVEL) {
226
+ this.memberLevelOptions.push({
227
+ id: role.roleId,
228
+ name: role.roleName,
229
+ checked: false,
230
+ disabled: false,
231
+ });
232
+ }
233
+ });
234
+ if (
235
+ this.memberLevelOptions.length === 0 ||
236
+ this.officerRolesOptions.length === 0
237
+ ) {
238
+ this.sharedService.showAlertMessage(
239
+ AlertType.ERROR,
240
+ this.createGroupTypeScreenTexts.errors['3019']
241
+ );
242
+ } else {
243
+ this.initializeCreateGroupTypeFormGroup();
244
+ }
245
+ }
246
+ },
247
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
248
+ error: (error: any) => {
249
+ this.sharedService.handleErrors(
250
+ error,
251
+ this.createGroupTypeScreenTexts.errors
252
+ );
253
+ },
254
+ });
255
+ }
256
+ /**
257
+ * Gets and filters non SYSTEM_USER group types, constructs allowed sub-group types options and form field config.
258
+ * @memberof CreateModifyGroupTypeComponent
259
+ */
260
+ getGroupTypes(): void {
261
+ this.groupTypeDetails = this.tenantAppService.getGroupTypeDetails();
262
+ this.groupTypeDetails?.body?.forEach(
263
+ (item: ViewGroupTypesConfiguration) => {
264
+ if (
265
+ item?.configFieldValue?.businessRule?.rosterType !==
266
+ GroupRosterType?.SYSTEM_USER
267
+ ) {
268
+ this.allowedSubGroupTypesOptions.push({
269
+ id: item?.configFieldId,
270
+ name: item?.configFieldValue?.name,
271
+ checked: false,
272
+ disabled: false,
273
+ });
274
+ }
275
+ }
276
+ );
277
+ this.allowedSubGroupTypesFieldConfig = {
278
+ type: FormControlType.CHECKBOX,
279
+ label: this.createGroupTypeScreenTexts?.label?.allowedSubGroupTypes,
280
+ controlName: 'allowedSubGroupTypes',
281
+ checkboxOptions: this.allowedSubGroupTypesOptions,
282
+ ariaLabel:
283
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.allowedSubGroupTypes,
284
+ ariaDescribedById:
285
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
286
+ ?.allowedSubGroupTypes,
287
+ };
288
+ }
289
+ /**
290
+ * Initialize the create/edit group type form group array.
291
+ * @param {*} [formValue]
292
+ * @memberof CreateModifyGroupTypeComponent
293
+ */
294
+ initializeCreateGroupTypeFormGroup(): void {
295
+ this.createGroupTypeFormGroup = {
296
+ formGroup: [
297
+ {
298
+ legend: '',
299
+ controls: [
300
+ {
301
+ type: FormControlType?.INPUT,
302
+ label: this.createGroupTypeScreenTexts?.label?.groupType + '*',
303
+ controlName: 'groupType',
304
+ value: '',
305
+ validation: [
306
+ Validators.required,
307
+ Validators.maxLength(GroupTypeValidation.groupTypeMaxLength),
308
+ ],
309
+ supportMessage:
310
+ this.createGroupTypeScreenTexts?.supportText?.groupType,
311
+ requiredErrorMessage:
312
+ this.createGroupTypeScreenTexts?.message?.error?.required,
313
+ maxErrorMessage:
314
+ this.createGroupTypeScreenTexts?.message?.error?.limit
315
+ ?.groupTypeMaxChars,
316
+ ariaLabel:
317
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.groupType,
318
+ ariaDescribedById:
319
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
320
+ ?.groupType,
321
+ },
322
+ {
323
+ type: FormControlType?.TEXT_AREA,
324
+ label: this.createGroupTypeScreenTexts?.label?.description + '*',
325
+ controlName: 'description',
326
+ value: '',
327
+ validation: [
328
+ Validators.required,
329
+ Validators.maxLength(GroupTypeValidation.descriptionMaxLength),
330
+ ],
331
+ supportMessage:
332
+ this.createGroupTypeScreenTexts?.supportText?.description,
333
+ requiredErrorMessage:
334
+ this.createGroupTypeScreenTexts?.message?.error?.required,
335
+ maxCharCount: GroupTypeValidation.descriptionMaxLength,
336
+ maxErrorMessage:
337
+ this.createGroupTypeScreenTexts?.message?.error?.limit
338
+ ?.descriptionMaxChars,
339
+ ariaLabel:
340
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.description,
341
+ ariaDescribedById:
342
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
343
+ ?.description,
344
+ ariaMultiline: true,
345
+ isResize: true,
346
+ },
347
+ {
348
+ type: FormControlType.RADIO,
349
+ label: this.createGroupTypeScreenTexts?.label?.rosterType + '*',
350
+ controlName: 'rosterType',
351
+ value:
352
+ this.tenantFunctionType === TenantFunctionType.EDIT_GROUP_TYPE
353
+ ? this.selectedGroupTypeInfo.configFieldValue.businessRule
354
+ .rosterType
355
+ : this.rosterTypeOptions[0].label,
356
+ disabled:
357
+ this.tenantFunctionType === TenantFunctionType.EDIT_GROUP_TYPE,
358
+ radioOptions: this.rosterTypeOptions,
359
+ validation: [Validators.required],
360
+ requiredErrorMessage:
361
+ this.createGroupTypeScreenTexts?.message?.error?.required,
362
+ ariaLabel:
363
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.rosterType,
364
+ ariaDescribedById:
365
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
366
+ ?.rosterType,
367
+ },
368
+ {
369
+ type: FormControlType.CHECKBOX,
370
+ label: this.createGroupTypeScreenTexts?.label?.settings + '*',
371
+ controlName: 'settings',
372
+ checkboxOptions: this.settingOptions,
373
+ minSelectionRequired: 1,
374
+ ariaLabel:
375
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.settings,
376
+ ariaDescribedById:
377
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
378
+ ?.settings,
379
+ requiredErrorMessage:
380
+ this.createGroupTypeScreenTexts?.message?.error?.required,
381
+ validation: [Validators.required],
382
+ },
383
+ {
384
+ type: FormControlType.CHECKBOX,
385
+ label:
386
+ this.createGroupTypeScreenTexts?.label?.appOfficerRoles + '*',
387
+ controlName: 'appOfficerRoles',
388
+ checkboxOptions: this.officerRolesOptions,
389
+ minSelectionRequired: 1,
390
+ ariaLabel:
391
+ this.createGroupTypeScreenTexts?.label?.ariaLabel
392
+ ?.appOfficerRoles,
393
+ ariaDescribedById:
394
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
395
+ ?.appOfficerRoles,
396
+ requiredErrorMessage:
397
+ this.createGroupTypeScreenTexts?.message?.error?.required,
398
+ validation: [Validators.required],
399
+ },
400
+ {
401
+ type: FormControlType.CHECKBOX,
402
+ label:
403
+ this.createGroupTypeScreenTexts?.label?.appMemberLevel + '*',
404
+ controlName: 'appMemberLevel',
405
+ checkboxOptions: this.memberLevelOptions,
406
+ minSelectionRequired: 1,
407
+ ariaLabel:
408
+ this.createGroupTypeScreenTexts?.label?.ariaLabel
409
+ ?.appMemberLevel,
410
+ ariaDescribedById:
411
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
412
+ ?.appMemberLevel,
413
+ requiredErrorMessage:
414
+ this.createGroupTypeScreenTexts?.message?.error?.required,
415
+ validation: [Validators.required],
416
+ },
417
+ {
418
+ type: FormControlType.RADIO,
419
+ label: this.createGroupTypeScreenTexts?.label?.isRootGroup + '*',
420
+ controlName: 'isRootGroup',
421
+ value:
422
+ this.tenantFunctionType === TenantFunctionType.EDIT_GROUP_TYPE
423
+ ? this.selectedGroupTypeInfo.configFieldValue.businessRule
424
+ .isRootGroup
425
+ ? this.isRootGroupOptions[0].label
426
+ : this.isRootGroupOptions[1].label
427
+ : this.isRootGroupOptions[1].label,
428
+ disabled:
429
+ this.tenantFunctionType === TenantFunctionType.EDIT_GROUP_TYPE,
430
+ radioOptions: this.isRootGroupOptions,
431
+ validation: [Validators.required],
432
+ requiredErrorMessage:
433
+ this.createGroupTypeScreenTexts?.message?.error?.required,
434
+ ariaLabel:
435
+ this.createGroupTypeScreenTexts?.label?.ariaLabel?.isRootGroup,
436
+ ariaDescribedById:
437
+ this.createGroupTypeScreenTexts?.label?.ariaDescribedById
438
+ ?.isRootGroup,
439
+ },
440
+ ],
441
+ },
442
+ ],
443
+ };
444
+ }
445
+ /**
446
+ * Add or removes allowed sub groups form control (checkbox group control and options) as when allow sub group selection and updates the form state.
447
+ * @param {*} selectedCheckbox
448
+ * @memberof CreateModifyGroupTypeComponent
449
+ */
450
+ onCheckboxSelectionChange(selectedCheckbox: CheckboxOption): void {
451
+ if (selectedCheckbox.name === Settings.ALLOW_SUB_GROUPS) {
452
+ if (selectedCheckbox.checked) {
453
+ this.componentRef = this.formUtilityService.addFormControl(
454
+ this.dynamicFormComponentViewRef,
455
+ CheckboxComponent,
456
+ this.createModifyGroupTypeFormGroupRef,
457
+ this.allowedSubGroupTypesFieldConfig,
458
+ this.renderer,
459
+ this.elementRef,
460
+ 'is-root-group',
461
+ this.dynamicFormComponent
462
+ );
463
+ } else {
464
+ this.allowedSubGroupTypesOptions.forEach(
465
+ (allowedSubGroupTypes: CheckboxOption) =>
466
+ (allowedSubGroupTypes.checked = false)
467
+ );
468
+ this.formUtilityService.removeFormControl(
469
+ this.createModifyGroupTypeFormGroupRef,
470
+ this.allowedSubGroupTypesFieldConfig,
471
+ this.componentRef,
472
+ this.renderer,
473
+ this.elementRef
474
+ );
475
+ }
476
+ }
477
+ }
478
+ /**
479
+ * Sets create/modify group type reactive form group reference.
480
+ * @param {FormGroup[]} form -The form group array containing the form to be referenced.
481
+ * @memberof CreateModifyGroupTypeComponent
482
+ */
483
+ getCreateModifyGroupTypeFormGroupRef(form: FormGroup[]): void {
484
+ this.createModifyGroupTypeFormGroupRef = form[0];
485
+ }
486
+ /**
487
+ * Find the provided setting name in setting option and return the boolean value.
488
+ * @param {string} settingName
489
+ * @return {*} {boolean}
490
+ * @memberof CreateModifyGroupTypeComponent
491
+ */
492
+ isSettingSelectedByName(settingName: string): boolean {
493
+ return this.settingOptions.find(
494
+ (setting: CheckboxOption) => setting.name === settingName
495
+ )?.checked as boolean;
496
+ }
497
+ /**
498
+ * Creates a new group type on form submission and the form is valid.
499
+ * @param {FormGroup[]} form
500
+ * @memberof CreateModifyGroupTypeComponent
501
+ */
502
+ onCreateModifyGroupTypeFormSubmit(form: FormGroup[]): void {
503
+ form[0]?.markAllAsTouched();
504
+ if (form[0].status === FormStatus.VALID) {
505
+ const selectedGroupTypes = this.allowedSubGroupTypesOptions
506
+ .filter((subGroupType: CheckboxOption) => subGroupType.checked)
507
+ .map(
508
+ (selectedGroupType: CheckboxOption) => selectedGroupType.id as string
509
+ );
510
+ const selectedRoles = [
511
+ ...this.memberLevelOptions.filter(
512
+ (memberLevel: CheckboxOption) => memberLevel.checked
513
+ ),
514
+ ...this.officerRolesOptions.filter(
515
+ (officerRole: CheckboxOption) => officerRole.checked
516
+ ),
517
+ ].map((selectedRole: CheckboxOption) => {
518
+ return {
519
+ roleId: selectedRole.id as string,
520
+ };
521
+ });
522
+ const configFieldValue: ConfigFieldValue = {
523
+ name: form[0].get('groupType')?.value,
524
+ description: form[0].get('description')?.value,
525
+ businessRule: {
526
+ rosterType: form[0].get('rosterType')?.value,
527
+ allowEdit: this.isSettingSelectedByName(Settings.ALLOW_EDIT),
528
+ allowRoster: this.isSettingSelectedByName(Settings.ALLOW_ROSTERS),
529
+ allowAlternateVoting: this.isSettingSelectedByName(
530
+ Settings.ALLOW_ALTERNATE_VOTING
531
+ ),
532
+ allowDelete: this.isSettingSelectedByName(Settings.ALLOW_DELETE),
533
+ allowSubGroup: this.isSettingSelectedByName(
534
+ Settings.ALLOW_SUB_GROUPS
535
+ ),
536
+ hasClassification: this.isSettingSelectedByName(
537
+ Settings.HAS_CLASSIFICATION
538
+ ),
539
+ allowedGroupType: selectedGroupTypes,
540
+ isRootGroup:
541
+ form[0].get('isRootGroup')?.value ===
542
+ this.isRootGroupOptions[0].label,
543
+ },
544
+ };
545
+ if (
546
+ form[0].get('isRootGroup')?.value === this.isRootGroupOptions[0].label
547
+ )
548
+ configFieldValue.hierarchy = 0;
549
+ const createGroupTypePayload: CreateGroupTypeRequestPayload = {
550
+ payload: {
551
+ appId: this.appId,
552
+ roles: selectedRoles,
553
+ configFieldName: 'group_type',
554
+ configFieldValue: JSON.stringify(configFieldValue),
555
+ },
556
+ };
557
+ this.tenantAppService
558
+ .createGroupType(createGroupTypePayload)
559
+ .pipe(takeUntil(this.destroy$))
560
+ .subscribe({
561
+ next: (response: CreateGroupTypeResponse) => {
562
+ if (response.status) {
563
+ const { appId, roles, configFieldName } =
564
+ createGroupTypePayload.payload;
565
+ const configFieldValue = JSON.parse(
566
+ createGroupTypePayload.payload.configFieldValue
567
+ );
568
+ this.tenantAppService.setNewlyCreatedGroupTypeInfo({
569
+ appId,
570
+ roles,
571
+ configFieldName,
572
+ configFieldValue,
573
+ });
574
+ this.submitFormResponse.emit(response);
575
+ }
576
+ },
577
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
578
+ error: (error: any) => {
579
+ this.sharedService.handleErrors(
580
+ error,
581
+ this.createGroupTypeScreenTexts.errors
582
+ );
583
+ },
584
+ });
585
+ }
586
+ }
587
+ /**
588
+ * Emits form cancel event.
589
+ * @memberof CreateModifyGroupTypeComponent
590
+ */
591
+ onFormCancel(): void {
592
+ this.formCancel.emit();
593
+ }
594
+ /**
595
+ * Implementation of ngOnDestroy lifecycle hook method to unsubscribe the open observable subscriptions.
596
+ * @memberof CreateModifyGroupTypeComponent
597
+ */
598
+ ngOnDestroy(): void {
599
+ this.destroy$.next(true);
600
+ this.destroy$.unsubscribe();
601
+ }
602
+ }
@@ -0,0 +1,15 @@
1
+ <ieeesa-dynamic-form
2
+ *ngIf="createRoleFormGroup"
3
+ class="ieeesa-create-role-form"
4
+ [leftButtonLabel]="leftButtonLabel"
5
+ [rightButtonLabel]="rightButtonLabel"
6
+ [isLegendVisible]="false"
7
+ [colWidth]="colWidth"
8
+ [actionButtonAlign]="actionButtonAlign"
9
+ [formGroups]="createRoleFormGroup"
10
+ [isLeftButtonNeeded]="true"
11
+ (formSubmit)="onCreateModifyRoleFormSubmit($event)"
12
+ (formChange)="onCreateModifyRoleFormChange($event)"
13
+ (formLeftButtonClicked)="onFormCancel()"
14
+ (formGroupsReference)="getCreateModifyRoleFormGroupRef($event)"
15
+ ></ieeesa-dynamic-form>
@@ -0,0 +1,83 @@
1
+ @import "styles.scss";
2
+ $ieeesa-desktop-width90: 90%;
3
+ $ieeesa-mobile-width: 100%;
4
+ .ieeesa-modal-dialog.ieeesa-create-modify-role {
5
+ width: 40vw !important;
6
+ .mat-mdc-dialog-container {
7
+ box-shadow: none;
8
+ }
9
+ .mat-mdc-dialog-surface {
10
+ border-radius: 0;
11
+ margin: 1em 0 1em;
12
+ }
13
+ .ieeesa-modal {
14
+ box-shadow: $ieeesa-box-shadow-8;
15
+ padding-bottom: 0.5em;
16
+ .mat-mdc-dialog-content {
17
+ padding: 0.5em 1em 0.75em 1em !important;
18
+ }
19
+ .ieeesa-dynamic-form {
20
+ .mat-mdc-form-field {
21
+ .mat-mdc-form-field-subscript-wrapper {
22
+ display: none !important;
23
+ }
24
+ }
25
+ &__actions {
26
+ flex-direction: row-reverse;
27
+ gap: 0.5em;
28
+ padding: 2em 1em 0.75em 1em;
29
+ }
30
+ &__form-field {
31
+ margin-bottom: 1em;
32
+ padding-top: 0 !important;
33
+ .ieeesa-select-field {
34
+ &__label-top {
35
+ min-height: 6.25em !important;
36
+ }
37
+ }
38
+ .ieeesa-select-field,
39
+ .ieeesa-input-field,
40
+ .ieeesa-text-area-field {
41
+ width: 70%;
42
+
43
+ .mat-mdc-form-field {
44
+ display: flex;
45
+ .mat-mdc-form-field-subscript-wrapper {
46
+ display: none !important;
47
+ }
48
+ }
49
+ }
50
+ }
51
+ .app-title,
52
+ .role-type {
53
+ &.ieeesa-dynamic-form {
54
+ &__form-field:has(.mat-mdc-input-element[readonly="true"]) {
55
+ padding-top: 0;
56
+ margin-bottom: 0;
57
+ @include textarea-readonly();
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ .ieeesa-input-field {
64
+ .mat-mdc-form-field {
65
+ display: flex;
66
+ }
67
+ .mat-mdc-form-field-subscript-wrapper {
68
+ display: none !important;
69
+ }
70
+ }
71
+ @media (max-width: $ieeesa-mobile-min-width) {
72
+ .ieeesa-dynamic-form {
73
+ &__form-field {
74
+ width: $ieeesa-mobile-width;
75
+ }
76
+ .ieeesa-select-field,
77
+ .ieeesa-input-field,
78
+ .mat-mdc-form-field-flex {
79
+ width: $ieeesa-mobile-width !important;
80
+ }
81
+ }
82
+ }
83
+ }