@tomei/sso 0.38.7 → 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
|
}
|
@@ -167,7 +171,8 @@ export class Group extends TreeNodeBase<Group> {
|
|
167
171
|
}
|
168
172
|
|
169
173
|
if (this.parent) {
|
170
|
-
this._Path =
|
174
|
+
this._Path =
|
175
|
+
(await this.parent.getPath(dbTransaction)) + '/' + this.GroupCode;
|
171
176
|
return this._Path;
|
172
177
|
}
|
173
178
|
this._Path = this.GroupCode;
|
@@ -433,10 +438,12 @@ export class Group extends TreeNodeBase<Group> {
|
|
433
438
|
//Break the path into array with oldGroupCode/ as separator;
|
434
439
|
const path = children.Path.split(`${oldGroupCode}/`);
|
435
440
|
//Retrive the last element of the array
|
436
|
-
const childPath = path[
|
437
|
-
//Combine the childPath with this.Path
|
438
|
-
children.
|
439
|
-
|
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
|
+
);
|
440
447
|
});
|
441
448
|
} catch (error) {
|
442
449
|
throw error;
|
@@ -473,39 +480,38 @@ export class Group extends TreeNodeBase<Group> {
|
|
473
480
|
);
|
474
481
|
}
|
475
482
|
try {
|
476
|
-
const currentGroup = await Group.init(dbTransaction, group.GroupCode);
|
477
483
|
if (group.NewGroupCode) {
|
478
484
|
await Group.checkDuplicateGroupCode(dbTransaction, group.NewGroupCode);
|
479
485
|
}
|
480
486
|
|
481
487
|
const entityValueBefore = {
|
482
|
-
GroupCode:
|
483
|
-
Name:
|
484
|
-
Type:
|
485
|
-
Description:
|
486
|
-
ParentGroupCode:
|
487
|
-
InheritParentPrivilegeYN:
|
488
|
-
InheritParentSystemAccessYN:
|
489
|
-
Path:
|
490
|
-
Status:
|
491
|
-
CreatedById:
|
492
|
-
UpdatedById:
|
493
|
-
CreatedAt:
|
494
|
-
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,
|
495
501
|
};
|
496
502
|
|
497
503
|
let isPathChanged = false;
|
498
|
-
const oldGroupCode =
|
504
|
+
const oldGroupCode = this.GroupCode;
|
499
505
|
if (group.NewGroupCode) {
|
500
|
-
|
506
|
+
this.GroupCode = group.NewGroupCode;
|
501
507
|
isPathChanged = true;
|
502
508
|
}
|
503
509
|
|
504
510
|
//Check if ParentGroupCode is changed or added
|
505
511
|
if (
|
506
512
|
(group.ParentGroupCode &&
|
507
|
-
|
508
|
-
(group.ParentGroupCode && !
|
513
|
+
this.ParentGroupCode !== group.ParentGroupCode) ||
|
514
|
+
(group.ParentGroupCode && !this.ParentGroupCode)
|
509
515
|
) {
|
510
516
|
const parentGroup = await Group.init(
|
511
517
|
dbTransaction,
|
@@ -518,46 +524,43 @@ export class Group extends TreeNodeBase<Group> {
|
|
518
524
|
'Parent Group Code not found',
|
519
525
|
);
|
520
526
|
}
|
521
|
-
await
|
527
|
+
await this.setParent(parentGroup);
|
522
528
|
//Check if ParentGroupCode is removed
|
523
529
|
isPathChanged = true;
|
524
|
-
} else if (!group.ParentGroupCode &&
|
525
|
-
await
|
530
|
+
} else if (!group.ParentGroupCode && this.ParentGroupCode) {
|
531
|
+
await this.setParent(null);
|
526
532
|
isPathChanged = true;
|
527
533
|
}
|
528
534
|
|
529
535
|
if (isPathChanged) {
|
530
|
-
await
|
536
|
+
await this.updateChildrenPath(oldGroupCode, dbTransaction);
|
531
537
|
}
|
532
538
|
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
currentGroup.Status = group?.Status || currentGroup.Status;
|
545
|
-
currentGroup._UpdatedById = loginUser.UserId;
|
546
|
-
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();
|
547
550
|
|
548
551
|
await Group._Repo.update(
|
549
552
|
{
|
550
|
-
GroupCode:
|
551
|
-
Name:
|
552
|
-
Type:
|
553
|
-
Description:
|
554
|
-
ParentGroupCode:
|
555
|
-
InheritParentPrivilegeYN:
|
556
|
-
InheritParentSystemAccessYN:
|
557
|
-
Status:
|
558
|
-
Path:
|
559
|
-
UpdatedById:
|
560
|
-
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,
|
561
564
|
},
|
562
565
|
{
|
563
566
|
where: {
|
@@ -568,19 +571,19 @@ export class Group extends TreeNodeBase<Group> {
|
|
568
571
|
);
|
569
572
|
|
570
573
|
const entityValueAfter = {
|
571
|
-
GroupCode:
|
572
|
-
Name:
|
573
|
-
Type:
|
574
|
-
Description:
|
575
|
-
ParentGroupCode:
|
576
|
-
InheritParentPrivilegeYN:
|
577
|
-
InheritParentSystemAccessYN:
|
578
|
-
Status:
|
579
|
-
Path:
|
580
|
-
CreatedById:
|
581
|
-
UpdatedById:
|
582
|
-
CreatedAt:
|
583
|
-
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,
|
584
587
|
};
|
585
588
|
|
586
589
|
const activity = new Activity();
|
@@ -593,7 +596,7 @@ export class Group extends TreeNodeBase<Group> {
|
|
593
596
|
activity.EntityValueAfter = JSON.stringify(entityValueAfter);
|
594
597
|
await activity.create(loginUser.ObjectId, dbTransaction);
|
595
598
|
|
596
|
-
return
|
599
|
+
return this;
|
597
600
|
} catch (error) {
|
598
601
|
throw error;
|
599
602
|
}
|