gantt-task-react-powern 0.5.6 → 0.5.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.
@@ -3504,60 +3504,141 @@ function getCriticalPaths(leafTasks) {
3504
3504
  computeCriticalPath(sortedTaskList[_i4], taskMap);
3505
3505
  }
3506
3506
 
3507
- var primaryLeaf;
3508
- var primaryDuration = 0;
3507
+ var taskChainList = [];
3509
3508
 
3510
3509
  for (var _i5 = 0; _i5 < sortedTaskList.length; _i5++) {
3511
- var newDuration = taskMap[sortedTaskList[_i5]].end - taskMap[sortedTaskList[_i5]].task.start.getTime();
3512
-
3513
- if (primaryDuration < newDuration) {
3514
- primaryLeaf = sortedTaskList[_i5];
3515
- primaryDuration = newDuration;
3510
+ for (var _j = 0; _j < taskMap[sortedTaskList[_i5]].paths.length; _j++) {
3511
+ taskChainList.push(taskMap[sortedTaskList[_i5]].paths[_j]);
3516
3512
  }
3517
3513
  }
3518
3514
 
3519
- var primaryPath = [];
3515
+ if (taskChainList.length > 0) {
3516
+ taskChainList.sort(function (a, b) {
3517
+ return b.duration - a.duration;
3518
+ });
3519
+ var primaryLeaf = taskChainList[0].parent;
3520
+ var primaryPath = [];
3521
+
3522
+ while (primaryLeaf !== undefined) {
3523
+ primaryPath.push(taskMap[primaryLeaf].task);
3520
3524
 
3521
- while (primaryLeaf !== undefined) {
3522
- taskMap[primaryLeaf].excluded = true;
3523
- primaryPath.push(taskMap[primaryLeaf].task);
3524
- primaryLeaf = taskMap[primaryLeaf].next;
3525
- }
3525
+ if (taskMap[primaryLeaf].paths.length === 0) {
3526
+ primaryLeaf = undefined;
3527
+ break;
3528
+ }
3529
+
3530
+ var primaryDuration = taskMap[primaryLeaf].paths[0].duration;
3531
+ var nextPath = taskMap[primaryLeaf].paths[0];
3532
+
3533
+ for (var _i6 = 1; _i6 < taskMap[primaryLeaf].paths.length; _i6++) {
3534
+ var newDuration = taskMap[primaryLeaf].paths[_i6].duration;
3526
3535
 
3527
- var secondaryLeaf;
3528
- var secondaryDuration = 0;
3536
+ if (newDuration > primaryDuration) {
3537
+ nextPath = taskMap[primaryLeaf].paths[_i6];
3538
+ primaryDuration = newDuration;
3539
+ }
3540
+ }
3529
3541
 
3530
- for (var _i6 = 0; _i6 < sortedTaskList.length; _i6++) {
3531
- if (taskMap[sortedTaskList[_i6]].excluded) continue;
3542
+ nextPath.visited = true;
3543
+ primaryLeaf = nextPath.task;
3544
+ }
3532
3545
 
3533
- var _newDuration = taskMap[sortedTaskList[_i6]].end - taskMap[sortedTaskList[_i6]].task.start.getTime();
3546
+ var secondaryLeaf = taskChainList[0].parent;
3534
3547
 
3535
- if (secondaryDuration < _newDuration) {
3536
- secondaryLeaf = sortedTaskList[_i6];
3537
- secondaryDuration = _newDuration;
3548
+ for (var _i7 = 0; _i7 < taskChainList.length; _i7++) {
3549
+ if (!taskChainList[_i7].visited) {
3550
+ secondaryLeaf = taskChainList[_i7].parent;
3551
+ break;
3552
+ }
3538
3553
  }
3539
- }
3540
3554
 
3541
- var secondaryPath = [];
3555
+ var secondaryPath = [];
3556
+
3557
+ while (secondaryLeaf !== undefined) {
3558
+ secondaryPath.push(taskMap[secondaryLeaf].task);
3559
+
3560
+ if (taskMap[secondaryLeaf].paths.length === 0) {
3561
+ secondaryLeaf = undefined;
3562
+ break;
3563
+ }
3564
+
3565
+ var secondaryDuration = taskMap[secondaryLeaf].paths[0].duration;
3566
+ var _nextPath = taskMap[secondaryLeaf].paths[0];
3567
+ if (_nextPath.visited) secondaryDuration = 0;
3568
+
3569
+ for (var _i8 = 1; _i8 < taskMap[secondaryLeaf].paths.length; _i8++) {
3570
+ var _newDuration = taskMap[secondaryLeaf].paths[_i8].duration;
3571
+
3572
+ if (_newDuration > secondaryDuration && !taskMap[secondaryLeaf].paths[_i8].visited) {
3573
+ _nextPath = taskMap[secondaryLeaf].paths[_i8];
3574
+ secondaryDuration = _newDuration;
3575
+ }
3576
+ }
3577
+
3578
+ if (_nextPath.visited) {
3579
+ break;
3580
+ }
3581
+
3582
+ _nextPath.visited = true;
3583
+ secondaryLeaf = _nextPath.task;
3584
+ }
3542
3585
 
3543
- while (secondaryLeaf !== undefined) {
3544
- secondaryPath.push(taskMap[secondaryLeaf].task);
3545
- secondaryLeaf = taskMap[secondaryLeaf].next;
3586
+ return [primaryPath, secondaryPath];
3546
3587
  }
3547
3588
 
3548
- return [primaryPath, secondaryPath];
3589
+ return [[], []];
3549
3590
  }
3550
3591
  function computeCriticalPath(taskID, taskMap) {
3551
3592
  var task = taskMap[taskID].task;
3552
3593
  var dependents = taskMap[taskID].dependents;
3594
+ taskMap[taskID].start = task.start.getTime();
3553
3595
  taskMap[taskID].end = task.end.getTime();
3596
+ taskMap[taskID].paths = [];
3554
3597
 
3555
3598
  for (var j = 0; j < dependents.length; j++) {
3556
- var newDependentEnd = taskMap[dependents[j]].end;
3599
+ var duration = taskMap[dependents[j]].task.end.getTime() - taskMap[dependents[j]].task.start.getTime() - Math.max(taskMap[taskID].end - taskMap[dependents[j]].task.start.getTime(), 0);
3600
+ var paths = taskMap[dependents[j]].paths;
3601
+
3602
+ for (var k = 0; k < paths.length; k++) {
3603
+ var totalDuration = taskMap[taskID].end - taskMap[taskID].start + duration + paths[k].duration;
3604
+
3605
+ if (taskMap[taskID].paths.length < 2) {
3606
+ taskMap[taskID].paths.push({
3607
+ duration: totalDuration,
3608
+ task: dependents[j],
3609
+ parent: taskID,
3610
+ visited: false
3611
+ });
3612
+ } else if (totalDuration > taskMap[taskID].paths[0].duration) {
3613
+ taskMap[taskID].paths[0].duration = totalDuration;
3614
+ taskMap[taskID].paths[0].task = dependents[j];
3615
+ taskMap[taskID].paths[0].parent = taskID;
3616
+ taskMap[taskID].paths[0].visited = false;
3617
+ } else if (totalDuration > taskMap[taskID].paths[0].duration) {
3618
+ taskMap[taskID].paths[1].duration = totalDuration;
3619
+ taskMap[taskID].paths[1].task = dependents[j];
3620
+ taskMap[taskID].paths[1].parent = taskID;
3621
+ taskMap[taskID].paths[1].visited = false;
3622
+ }
3623
+ }
3557
3624
 
3558
- if (newDependentEnd > taskMap[taskID].end) {
3559
- taskMap[taskID].next = dependents[j];
3560
- taskMap[taskID].end = newDependentEnd;
3625
+ if (taskMap[taskID].paths.length < 2) {
3626
+ taskMap[taskID].paths.push({
3627
+ duration: duration,
3628
+ task: dependents[j],
3629
+ parent: taskID,
3630
+ visited: false
3631
+ });
3632
+ } else if (duration > taskMap[taskID].paths[0].duration) {
3633
+ taskMap[taskID].paths[0].duration = duration;
3634
+ taskMap[taskID].paths[0].task = dependents[j];
3635
+ taskMap[taskID].paths[0].parent = taskID;
3636
+ taskMap[taskID].paths[0].visited = false;
3637
+ } else if (duration > taskMap[taskID].paths[0].duration) {
3638
+ taskMap[taskID].paths[1].duration = duration;
3639
+ taskMap[taskID].paths[1].task = dependents[j];
3640
+ taskMap[taskID].paths[1].parent = taskID;
3641
+ taskMap[taskID].paths[1].visited = false;
3561
3642
  }
3562
3643
  }
3563
3644
  }
@@ -3594,12 +3675,12 @@ function colorPath(path, color, tasks, criticalPathType) {
3594
3675
  }
3595
3676
  }
3596
3677
 
3597
- var _loop = function _loop(_i7) {
3678
+ var _loop = function _loop(_i9) {
3598
3679
  var taskFromTasks = void 0;
3599
3680
 
3600
- for (var _j = 0; _j < tasks.length; _j++) {
3601
- if (path[_i7].id === tasks[_j].id) {
3602
- taskFromTasks = tasks[_j];
3681
+ for (var _j2 = 0; _j2 < tasks.length; _j2++) {
3682
+ if (path[_i9].id === tasks[_j2].id) {
3683
+ taskFromTasks = tasks[_j2];
3603
3684
  break;
3604
3685
  }
3605
3686
  }
@@ -3608,14 +3689,14 @@ function colorPath(path, color, tasks, criticalPathType) {
3608
3689
  var arrows = taskFromTasks.criticalPathArrows;
3609
3690
  if (!arrows) arrows = [];
3610
3691
  var arrow = arrows.find(function (arrow) {
3611
- return arrow.taskId === path[_i7 + 1].id;
3692
+ return arrow.taskId === path[_i9 + 1].id;
3612
3693
  });
3613
3694
 
3614
3695
  if (arrow) {
3615
3696
  arrow.arrowColor = color;
3616
3697
  arrow.criticalPathType = criticalPathType;
3617
3698
  } else arrows.push({
3618
- taskId: path[_i7 + 1].id,
3699
+ taskId: path[_i9 + 1].id,
3619
3700
  arrowColor: color,
3620
3701
  criticalPathType: criticalPathType
3621
3702
  });
@@ -3624,8 +3705,8 @@ function colorPath(path, color, tasks, criticalPathType) {
3624
3705
  }
3625
3706
  };
3626
3707
 
3627
- for (var _i7 = 0; _i7 + 1 < path.length; _i7++) {
3628
- _loop(_i7);
3708
+ for (var _i9 = 0; _i9 + 1 < path.length; _i9++) {
3709
+ _loop(_i9);
3629
3710
  }
3630
3711
  }
3631
3712
  var getParentWbs = function getParentWbs(wbs) {