@ieeesa-npm/groups 0.1.5 → 0.1.7
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/lib/assets/constants.json +1 -0
- package/esm2022/lib/components/create-group/create-group.component.mjs +47 -24
- package/esm2022/lib/components/tree-view/tree-view.component.mjs +13 -5
- package/esm2022/lib/models/form-status.model.mjs +7 -0
- package/fesm2022/ieeesa-npm-groups.mjs +66 -28
- package/fesm2022/ieeesa-npm-groups.mjs.map +1 -1
- package/lib/components/create-group/create-group.component.d.ts +10 -5
- package/lib/models/form-status.model.d.ts +4 -0
- package/lib/services/groups.service.d.ts +3 -10
- package/package.json +1 -1
|
@@ -166,7 +166,8 @@ var errors = {
|
|
|
166
166
|
"1015": "Group Name contains invalid characters. Please enter alphanumeric, special characters and whitespace only.",
|
|
167
167
|
"1016": "Group Name must not be greater than 500 characters long.",
|
|
168
168
|
"1017": "Group Short Name must not be greater than 15 characters long.",
|
|
169
|
-
"1018": "Group Short Name contains invalid characters. Please enter '.',',', '/'', '-', '_' only."
|
|
169
|
+
"1018": "Group Short Name contains invalid characters. Please enter '.',',', '/'', '-', '_' only.",
|
|
170
|
+
ER1000: "Allowed group types are not found for the selected group!"
|
|
170
171
|
};
|
|
171
172
|
var constants = {
|
|
172
173
|
createGroup: createGroup,
|
|
@@ -194,6 +195,13 @@ const GroupsValidationPatterns = {
|
|
|
194
195
|
groupScope: /^(?=.*[a-zA-Z])[\w\s!"#$%&'()*+,-.\/\:;<=>?@[\]^_`{|}~\\]+$/i
|
|
195
196
|
};
|
|
196
197
|
|
|
198
|
+
/* eslint-disable no-unused-vars */
|
|
199
|
+
var FormStatus;
|
|
200
|
+
(function (FormStatus) {
|
|
201
|
+
FormStatus["VALID"] = "VALID";
|
|
202
|
+
FormStatus["INVALID"] = "INVALID";
|
|
203
|
+
})(FormStatus || (FormStatus = {}));
|
|
204
|
+
|
|
197
205
|
/**
|
|
198
206
|
* Groups service is an abstract layer and responsible for managing groups REST API calls.
|
|
199
207
|
* @class GroupsService
|
|
@@ -370,27 +378,40 @@ class CreateGroupComponent {
|
|
|
370
378
|
.subscribe({
|
|
371
379
|
next: (res) => {
|
|
372
380
|
if (res?.status) {
|
|
373
|
-
this.
|
|
374
|
-
|
|
375
|
-
(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
381
|
+
this.selectedParentGroupInfo = this.groupsService?.getSelectedGroupInfo();
|
|
382
|
+
const configFieldValue = res?.body?.configFieldValue;
|
|
383
|
+
if (this.selectedParentGroupInfo?.groupType) {
|
|
384
|
+
const allowedGroupType = configFieldValue[this.selectedParentGroupInfo?.groupType]
|
|
385
|
+
?.businessRule?.allowedGroupType;
|
|
386
|
+
if (allowedGroupType?.length) {
|
|
387
|
+
this.groupTypes = allowedGroupType.map((groupTypeId) => ({
|
|
388
|
+
id: groupTypeId,
|
|
389
|
+
name: configFieldValue[groupTypeId]?.name,
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
this.showAlertMessage(errors?.ER1000, AlertType.ERROR);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
this.groupTypes = Object.entries(configFieldValue).map(([id, item]) => ({
|
|
398
|
+
id,
|
|
399
|
+
name: item?.name,
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
if (this.groupTypes?.length) {
|
|
380
403
|
this.createFormGroup();
|
|
381
404
|
}
|
|
405
|
+
else {
|
|
406
|
+
this.showAlertMessage(errors?.["1010"], AlertType.ERROR);
|
|
407
|
+
}
|
|
382
408
|
}
|
|
383
409
|
},
|
|
384
410
|
error: (error) => {
|
|
385
411
|
const errorCodes = error?.error?.body?.errorCodes;
|
|
386
412
|
if (Array.isArray(errorCodes)) {
|
|
387
413
|
const errorMessage = this.groupsService.parseErrorMessage(errorCodes);
|
|
388
|
-
this.
|
|
389
|
-
status: "custom",
|
|
390
|
-
message: errorMessage,
|
|
391
|
-
alertType: AlertType.ERROR,
|
|
392
|
-
isCloseNeeded: true,
|
|
393
|
-
});
|
|
414
|
+
this.showAlertMessage(errorMessage, AlertType.ERROR);
|
|
394
415
|
}
|
|
395
416
|
else if (error && error instanceof HttpErrorResponse) {
|
|
396
417
|
this.globalErrorHandlerService.handleError(error);
|
|
@@ -492,7 +513,6 @@ class CreateGroupComponent {
|
|
|
492
513
|
},
|
|
493
514
|
],
|
|
494
515
|
};
|
|
495
|
-
this.selectedParentGroupInfo = this.groupsService.getSelectedGroupInfo();
|
|
496
516
|
if (this.selectedParentGroupInfo?.groupId) {
|
|
497
517
|
this.updateCreateFormGroup(this.selectedParentGroupInfo);
|
|
498
518
|
}
|
|
@@ -523,7 +543,7 @@ class CreateGroupComponent {
|
|
|
523
543
|
*/
|
|
524
544
|
onFormSubmit(form) {
|
|
525
545
|
form[0]?.markAllAsTouched();
|
|
526
|
-
if (form[0].status ===
|
|
546
|
+
if (form[0].status === FormStatus.VALID) {
|
|
527
547
|
const formResponse = form[0].getRawValue();
|
|
528
548
|
const createGroupPayload = {
|
|
529
549
|
payload: {
|
|
@@ -531,8 +551,8 @@ class CreateGroupComponent {
|
|
|
531
551
|
groupShortName: formResponse?.shortName,
|
|
532
552
|
groupType: formResponse?.groupType?.id,
|
|
533
553
|
groupDesc: formResponse?.groupScope,
|
|
534
|
-
groupParentId: this.selectedParentGroupInfo?.groupId ?? null
|
|
535
|
-
}
|
|
554
|
+
groupParentId: this.selectedParentGroupInfo?.groupId ?? null,
|
|
555
|
+
},
|
|
536
556
|
};
|
|
537
557
|
this.groupsService
|
|
538
558
|
.createGroup(createGroupPayload)
|
|
@@ -547,12 +567,7 @@ class CreateGroupComponent {
|
|
|
547
567
|
const errorCodes = error?.error?.body?.errorCodes;
|
|
548
568
|
if (Array.isArray(errorCodes)) {
|
|
549
569
|
const errorMessage = this.groupsService.parseErrorMessage(errorCodes);
|
|
550
|
-
this.
|
|
551
|
-
status: "custom",
|
|
552
|
-
message: errorMessage,
|
|
553
|
-
alertType: AlertType.ERROR,
|
|
554
|
-
isCloseNeeded: true,
|
|
555
|
-
});
|
|
570
|
+
this.showAlertMessage(errorMessage, AlertType.ERROR);
|
|
556
571
|
}
|
|
557
572
|
else if (error && error instanceof HttpErrorResponse) {
|
|
558
573
|
this.globalErrorHandlerService.handleError(error);
|
|
@@ -569,6 +584,21 @@ class CreateGroupComponent {
|
|
|
569
584
|
getFormGroupReference(form) {
|
|
570
585
|
this.form = form[0];
|
|
571
586
|
}
|
|
587
|
+
/**
|
|
588
|
+
* Handles alerts for error, warning.
|
|
589
|
+
* @param {(string | string[])} message -error or warning message
|
|
590
|
+
* @param {AlertType} alertType
|
|
591
|
+
* @return -returns nothing
|
|
592
|
+
* @memberof CreateGroupComponent
|
|
593
|
+
*/
|
|
594
|
+
showAlertMessage(message, alertType) {
|
|
595
|
+
this.alertService.showMessage({
|
|
596
|
+
status: "custom",
|
|
597
|
+
message: message,
|
|
598
|
+
alertType: alertType,
|
|
599
|
+
isCloseNeeded: true,
|
|
600
|
+
});
|
|
601
|
+
}
|
|
572
602
|
/**
|
|
573
603
|
* Emits form cancel event.
|
|
574
604
|
* @return -returns nothing
|
|
@@ -978,10 +1008,18 @@ class TreeViewComponent {
|
|
|
978
1008
|
* @memberof TreeViewComponent
|
|
979
1009
|
*/
|
|
980
1010
|
getFilteredGroupActions(group) {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1011
|
+
const filteredMenu = [];
|
|
1012
|
+
this.menuItems.forEach((e) => {
|
|
1013
|
+
e.isToolTipNeeded = false;
|
|
1014
|
+
if (e.id === GroupAction.VIEW_ROSTER ||
|
|
1015
|
+
e.id === GroupAction.EDIT_GROUP ||
|
|
1016
|
+
(e.id === GroupAction.DELETE_GROUP && !group?.item?.hasChildren) ||
|
|
1017
|
+
(e.id === GroupAction.CREATE_SUB_GROUP &&
|
|
1018
|
+
group?.item?.groupTypeInfo?.businessRule?.allowSubGroup)) {
|
|
1019
|
+
filteredMenu.push(e);
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
return filteredMenu;
|
|
985
1023
|
}
|
|
986
1024
|
/**
|
|
987
1025
|
* Takes the index and the icon button as arguments and needs to return the unique identifier for this icon button.
|