gantt-task-react-powern 0.5.6 → 0.5.8

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