@tomei/sso 0.38.8 → 0.38.9
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -72,6 +72,10 @@ export class Group extends TreeNodeBase<Group> {
|
|
72
72
|
return this._UpdatedAt;
|
73
73
|
}
|
74
74
|
|
75
|
+
get Path(): string {
|
76
|
+
return this._Path;
|
77
|
+
}
|
78
|
+
|
75
79
|
set Path(value: string) {
|
76
80
|
this._Path = value;
|
77
81
|
}
|
@@ -434,10 +438,12 @@ export class Group extends TreeNodeBase<Group> {
|
|
434
438
|
//Break the path into array with oldGroupCode/ as separator;
|
435
439
|
const path = children.Path.split(`${oldGroupCode}/`);
|
436
440
|
//Retrive the last element of the array
|
437
|
-
const childPath = path[
|
438
|
-
//Combine the childPath with this.Path
|
439
|
-
children.
|
440
|
-
|
441
|
+
const childPath = path[1];
|
442
|
+
//Combine the childPath with this.Path then save it to the children.Path
|
443
|
+
await children.update(
|
444
|
+
{ Path: `${this._Path}/${childPath}` },
|
445
|
+
{ transaction: dbTransaction },
|
446
|
+
);
|
441
447
|
});
|
442
448
|
} catch (error) {
|
443
449
|
throw error;
|
@@ -474,39 +480,38 @@ export class Group extends TreeNodeBase<Group> {
|
|
474
480
|
);
|
475
481
|
}
|
476
482
|
try {
|
477
|
-
const currentGroup = await Group.init(dbTransaction, group.GroupCode);
|
478
483
|
if (group.NewGroupCode) {
|
479
484
|
await Group.checkDuplicateGroupCode(dbTransaction, group.NewGroupCode);
|
480
485
|
}
|
481
486
|
|
482
487
|
const entityValueBefore = {
|
483
|
-
GroupCode:
|
484
|
-
Name:
|
485
|
-
Type:
|
486
|
-
Description:
|
487
|
-
ParentGroupCode:
|
488
|
-
InheritParentPrivilegeYN:
|
489
|
-
InheritParentSystemAccessYN:
|
490
|
-
Path:
|
491
|
-
Status:
|
492
|
-
CreatedById:
|
493
|
-
UpdatedById:
|
494
|
-
CreatedAt:
|
495
|
-
UpdatedAt:
|
488
|
+
GroupCode: this.GroupCode,
|
489
|
+
Name: this.Name,
|
490
|
+
Type: this.Type,
|
491
|
+
Description: this.Description,
|
492
|
+
ParentGroupCode: this.ParentGroupCode,
|
493
|
+
InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
|
494
|
+
InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
|
495
|
+
Path: this.Path,
|
496
|
+
Status: this.Status,
|
497
|
+
CreatedById: this._CreatedById,
|
498
|
+
UpdatedById: this._UpdatedById,
|
499
|
+
CreatedAt: this._CreatedAt,
|
500
|
+
UpdatedAt: this._UpdatedAt,
|
496
501
|
};
|
497
502
|
|
498
503
|
let isPathChanged = false;
|
499
|
-
const oldGroupCode =
|
504
|
+
const oldGroupCode = this.GroupCode;
|
500
505
|
if (group.NewGroupCode) {
|
501
|
-
|
506
|
+
this.GroupCode = group.NewGroupCode;
|
502
507
|
isPathChanged = true;
|
503
508
|
}
|
504
509
|
|
505
510
|
//Check if ParentGroupCode is changed or added
|
506
511
|
if (
|
507
512
|
(group.ParentGroupCode &&
|
508
|
-
|
509
|
-
(group.ParentGroupCode && !
|
513
|
+
this.ParentGroupCode !== group.ParentGroupCode) ||
|
514
|
+
(group.ParentGroupCode && !this.ParentGroupCode)
|
510
515
|
) {
|
511
516
|
const parentGroup = await Group.init(
|
512
517
|
dbTransaction,
|
@@ -519,46 +524,43 @@ export class Group extends TreeNodeBase<Group> {
|
|
519
524
|
'Parent Group Code not found',
|
520
525
|
);
|
521
526
|
}
|
522
|
-
await
|
527
|
+
await this.setParent(parentGroup);
|
523
528
|
//Check if ParentGroupCode is removed
|
524
529
|
isPathChanged = true;
|
525
|
-
} else if (!group.ParentGroupCode &&
|
526
|
-
await
|
530
|
+
} else if (!group.ParentGroupCode && this.ParentGroupCode) {
|
531
|
+
await this.setParent(null);
|
527
532
|
isPathChanged = true;
|
528
533
|
}
|
529
534
|
|
530
535
|
if (isPathChanged) {
|
531
|
-
await
|
536
|
+
await this.updateChildrenPath(oldGroupCode, dbTransaction);
|
532
537
|
}
|
533
538
|
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
currentGroup.Status = group?.Status || currentGroup.Status;
|
546
|
-
currentGroup._UpdatedById = loginUser.UserId;
|
547
|
-
currentGroup._UpdatedAt = new Date();
|
539
|
+
this.Name = group?.Name || this.Name;
|
540
|
+
this.Type = group?.Type || this.Type;
|
541
|
+
this.Description = group?.Description || this.Description;
|
542
|
+
this.ParentGroupCode = group?.ParentGroupCode || this.ParentGroupCode;
|
543
|
+
this.InheritParentPrivilegeYN =
|
544
|
+
group?.InheritParentPrivilegeYN || this.InheritParentPrivilegeYN;
|
545
|
+
this.InheritParentSystemAccessYN =
|
546
|
+
group?.InheritParentSystemAccessYN || this.InheritParentSystemAccessYN;
|
547
|
+
this.Status = group?.Status || this.Status;
|
548
|
+
this._UpdatedById = loginUser.UserId;
|
549
|
+
this._UpdatedAt = new Date();
|
548
550
|
|
549
551
|
await Group._Repo.update(
|
550
552
|
{
|
551
|
-
GroupCode:
|
552
|
-
Name:
|
553
|
-
Type:
|
554
|
-
Description:
|
555
|
-
ParentGroupCode:
|
556
|
-
InheritParentPrivilegeYN:
|
557
|
-
InheritParentSystemAccessYN:
|
558
|
-
Status:
|
559
|
-
Path:
|
560
|
-
UpdatedById:
|
561
|
-
UpdatedAt:
|
553
|
+
GroupCode: this.GroupCode,
|
554
|
+
Name: this.Name,
|
555
|
+
Type: this.Type,
|
556
|
+
Description: this.Description,
|
557
|
+
ParentGroupCode: this.ParentGroupCode,
|
558
|
+
InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
|
559
|
+
InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
|
560
|
+
Status: this.Status,
|
561
|
+
Path: this._Path,
|
562
|
+
UpdatedById: this._UpdatedById,
|
563
|
+
UpdatedAt: this._UpdatedAt,
|
562
564
|
},
|
563
565
|
{
|
564
566
|
where: {
|
@@ -569,19 +571,19 @@ export class Group extends TreeNodeBase<Group> {
|
|
569
571
|
);
|
570
572
|
|
571
573
|
const entityValueAfter = {
|
572
|
-
GroupCode:
|
573
|
-
Name:
|
574
|
-
Type:
|
575
|
-
Description:
|
576
|
-
ParentGroupCode:
|
577
|
-
InheritParentPrivilegeYN:
|
578
|
-
InheritParentSystemAccessYN:
|
579
|
-
Status:
|
580
|
-
Path:
|
581
|
-
CreatedById:
|
582
|
-
UpdatedById:
|
583
|
-
CreatedAt:
|
584
|
-
UpdatedAt:
|
574
|
+
GroupCode: this.GroupCode,
|
575
|
+
Name: this.Name,
|
576
|
+
Type: this.Type,
|
577
|
+
Description: this.Description,
|
578
|
+
ParentGroupCode: this.ParentGroupCode,
|
579
|
+
InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
|
580
|
+
InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
|
581
|
+
Status: this.Status,
|
582
|
+
Path: this._Path,
|
583
|
+
CreatedById: this._CreatedById,
|
584
|
+
UpdatedById: this._UpdatedById,
|
585
|
+
CreatedAt: this._CreatedAt,
|
586
|
+
UpdatedAt: this._UpdatedAt,
|
585
587
|
};
|
586
588
|
|
587
589
|
const activity = new Activity();
|
@@ -594,7 +596,7 @@ export class Group extends TreeNodeBase<Group> {
|
|
594
596
|
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
595
597
|
await activity.create(loginUser.ObjectId, dbTransaction);
|
596
598
|
|
597
|
-
return
|
599
|
+
return this;
|
598
600
|
} catch (error) {
|
599
601
|
throw error;
|
600
602
|
}
|