gantt-task-react-powern 0.6.37 → 0.6.39
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/helpers/calendar-helper.d.ts +0 -4
- package/dist/index.js +340 -184
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +340 -184
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -358,7 +358,7 @@ var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
|
|
|
358
358
|
}
|
|
359
359
|
}), {
|
|
360
360
|
resizable: false
|
|
361
|
-
}), cell("id", 0.8, "ID"), cell("wbs", 0.8, "WBS Code / Activity ID"), cell("name", 1.8, "
|
|
361
|
+
}), cell("id", 0.8, "ID"), cell("wbs", 0.8, "WBS Code / Activity ID"), cell("name", 1.8, "IM TESTING"), cell("plannedStart", 0.6, "Planned Start", {
|
|
362
362
|
title: "Planned Start"
|
|
363
363
|
}), cell("plannedEnd", 0.6, "Planned End", {
|
|
364
364
|
title: "Planned End"
|
|
@@ -750,6 +750,43 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
750
750
|
type: type
|
|
751
751
|
}));
|
|
752
752
|
};
|
|
753
|
+
|
|
754
|
+
function getOffTime(task, taskStart, taskEnd, _message) {
|
|
755
|
+
var start = taskStart.getTime();
|
|
756
|
+
var end = taskEnd.getTime();
|
|
757
|
+
var startWeek = Math.floor((start / 86400000 + 4) / 7);
|
|
758
|
+
var endWeek = Math.floor((end / 86400000 + 4) / 7);
|
|
759
|
+
var offTime = 0;
|
|
760
|
+
|
|
761
|
+
if (task.calendar) {
|
|
762
|
+
if (task.calendar.off_days && task.calendar.off_days.length) {
|
|
763
|
+
for (var d = 0; d < task.calendar.off_days.length || 0; d++) {
|
|
764
|
+
for (var w = startWeek; w <= endWeek; w++) {
|
|
765
|
+
var dayOfTheWeek = task.calendar.off_days[d];
|
|
766
|
+
var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
|
|
767
|
+
|
|
768
|
+
if (offDay >= start && offDay <= end) {
|
|
769
|
+
offTime += 86400000;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (task.calendar.holidays && task.calendar.holidays.length) {
|
|
776
|
+
for (var h = 0; h < task.calendar.holidays.length || 0; h++) {
|
|
777
|
+
var holiday = task.calendar.holidays[h];
|
|
778
|
+
var holiday_timestamp = new Date(holiday).getTime();
|
|
779
|
+
|
|
780
|
+
if (holiday_timestamp >= start && holiday_timestamp <= end) {
|
|
781
|
+
offTime += 86400000;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
return offTime;
|
|
788
|
+
}
|
|
789
|
+
|
|
753
790
|
var StandardTooltipContent = function StandardTooltipContent(_ref2) {
|
|
754
791
|
var _task$plannedDuration, _task$actualDuration;
|
|
755
792
|
|
|
@@ -761,8 +798,8 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
|
|
|
761
798
|
fontSize: fontSize,
|
|
762
799
|
fontFamily: fontFamily
|
|
763
800
|
};
|
|
764
|
-
var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime()) / (1000 * 60 * 60 * 24))) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
|
|
765
|
-
var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime()) / (1000 * 60 * 60 * 24))) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
|
|
801
|
+
var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime() - getOffTime(task, task.start, task.end)) / (1000 * 60 * 60 * 24))) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
|
|
802
|
+
var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime() - getOffTime(task, task.actualStart, task.actualEnd)) / (1000 * 60 * 60 * 24))) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
|
|
766
803
|
if (type == "planned") return React__default.createElement("div", {
|
|
767
804
|
className: styles$2.tooltipDefaultContainer,
|
|
768
805
|
style: style
|
|
@@ -990,7 +1027,38 @@ var TaskList = function TaskList(_ref) {
|
|
|
990
1027
|
setPendingTaskSelect = _useState3[1];
|
|
991
1028
|
|
|
992
1029
|
var prevSelectedTasksRef = React.useRef([]);
|
|
993
|
-
var expandedTasks = React.useRef(
|
|
1030
|
+
var expandedTasks = React.useRef(new Set());
|
|
1031
|
+
var taskIndex = React.useMemo(function () {
|
|
1032
|
+
var byId = new Map();
|
|
1033
|
+
var childrenOf = new Map();
|
|
1034
|
+
var roots = [];
|
|
1035
|
+
tasks.forEach(function (task) {
|
|
1036
|
+
return byId.set(task.id, task);
|
|
1037
|
+
});
|
|
1038
|
+
tasks.forEach(function (task) {
|
|
1039
|
+
var parent = getParentWbs(task.id);
|
|
1040
|
+
|
|
1041
|
+
if (parent === undefined) {
|
|
1042
|
+
roots.push(task.id);
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
var siblings = childrenOf.get(parent);
|
|
1047
|
+
if (siblings) siblings.push(task.id);else childrenOf.set(parent, [task.id]);
|
|
1048
|
+
});
|
|
1049
|
+
return {
|
|
1050
|
+
byId: byId,
|
|
1051
|
+
childrenOf: childrenOf,
|
|
1052
|
+
roots: roots
|
|
1053
|
+
};
|
|
1054
|
+
}, [tasks]);
|
|
1055
|
+
|
|
1056
|
+
var sameIds = function sameIds(a, b) {
|
|
1057
|
+
return a.length === b.length && a.every(function (id, i) {
|
|
1058
|
+
return id === b[i];
|
|
1059
|
+
});
|
|
1060
|
+
};
|
|
1061
|
+
|
|
994
1062
|
var virtualizer = reactVirtual.useVirtualizer({
|
|
995
1063
|
count: tasks.length,
|
|
996
1064
|
getScrollElement: function getScrollElement() {
|
|
@@ -1007,13 +1075,15 @@ var TaskList = function TaskList(_ref) {
|
|
|
1007
1075
|
}
|
|
1008
1076
|
}, [scrollY]);
|
|
1009
1077
|
React.useEffect(function () {
|
|
1010
|
-
if (onMultiSelect
|
|
1011
|
-
|
|
1012
|
-
return selectedTasks.includes(task.id);
|
|
1013
|
-
});
|
|
1014
|
-
prevSelectedTasksRef.current = [].concat(selectedTasks);
|
|
1015
|
-
onMultiSelect(selectedTaskObjects);
|
|
1078
|
+
if (!onMultiSelect || sameIds(prevSelectedTasksRef.current, selectedTasks)) {
|
|
1079
|
+
return;
|
|
1016
1080
|
}
|
|
1081
|
+
|
|
1082
|
+
var selected = new Set(selectedTasks);
|
|
1083
|
+
prevSelectedTasksRef.current = selectedTasks;
|
|
1084
|
+
onMultiSelect(tasks.filter(function (task) {
|
|
1085
|
+
return selected.has(task.id);
|
|
1086
|
+
}));
|
|
1017
1087
|
}, [selectedTasks, tasks, onMultiSelect]);
|
|
1018
1088
|
React.useEffect(function () {
|
|
1019
1089
|
if (pendingTaskSelect.length === 0) return;
|
|
@@ -1023,14 +1093,14 @@ var TaskList = function TaskList(_ref) {
|
|
|
1023
1093
|
selected = _ref2.selected;
|
|
1024
1094
|
|
|
1025
1095
|
if (selected) {
|
|
1026
|
-
recursiveOpen(taskId
|
|
1027
|
-
var descendants = getDescendants(taskId
|
|
1096
|
+
recursiveOpen(taskId);
|
|
1097
|
+
var descendants = getDescendants(taskId);
|
|
1028
1098
|
newSelected.add(taskId);
|
|
1029
1099
|
descendants.forEach(function (d) {
|
|
1030
1100
|
return newSelected.add(d);
|
|
1031
1101
|
});
|
|
1032
1102
|
} else {
|
|
1033
|
-
var _descendants = getDescendants(taskId
|
|
1103
|
+
var _descendants = getDescendants(taskId);
|
|
1034
1104
|
|
|
1035
1105
|
newSelected["delete"](taskId);
|
|
1036
1106
|
|
|
@@ -1043,63 +1113,60 @@ var TaskList = function TaskList(_ref) {
|
|
|
1043
1113
|
setPendingTaskSelect([]);
|
|
1044
1114
|
}, [pendingTaskSelect]);
|
|
1045
1115
|
React.useEffect(function () {
|
|
1046
|
-
expandedTasks.current
|
|
1047
|
-
var
|
|
1048
|
-
|
|
1049
|
-
});
|
|
1050
|
-
return t && !t.hideChildren;
|
|
1116
|
+
expandedTasks.current.forEach(function (id) {
|
|
1117
|
+
var task = taskIndex.byId.get(id);
|
|
1118
|
+
if (!task || task.hideChildren) expandedTasks.current["delete"](id);
|
|
1051
1119
|
});
|
|
1052
1120
|
if (selectedTasks.length === 0) return;
|
|
1053
1121
|
var newSelected = new Set();
|
|
1054
1122
|
selectedTasks.forEach(function (taskId) {
|
|
1055
|
-
if (
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
newSelected.add(
|
|
1060
|
-
|
|
1061
|
-
descendants.forEach(function (d) {
|
|
1062
|
-
return newSelected.add(d);
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1123
|
+
if (!taskIndex.byId.has(taskId)) return;
|
|
1124
|
+
recursiveOpen(taskId);
|
|
1125
|
+
newSelected.add(taskId);
|
|
1126
|
+
getDescendants(taskId).forEach(function (d) {
|
|
1127
|
+
return newSelected.add(d);
|
|
1128
|
+
});
|
|
1065
1129
|
});
|
|
1066
1130
|
var newSelectedArray = Array.from(newSelected);
|
|
1067
1131
|
|
|
1068
|
-
if (
|
|
1132
|
+
if (!sameIds(newSelectedArray, selectedTasks)) {
|
|
1069
1133
|
setSelectedTasks(newSelectedArray);
|
|
1070
1134
|
}
|
|
1071
1135
|
}, [tasks.length]);
|
|
1072
1136
|
|
|
1073
|
-
var getDescendants = function getDescendants(taskId
|
|
1074
|
-
var
|
|
1075
|
-
return t.id === taskId;
|
|
1076
|
-
});
|
|
1077
|
-
if (!task) return [];
|
|
1078
|
-
var children = allTasks.filter(function (t) {
|
|
1079
|
-
return getParentWbs(t.id) === taskId;
|
|
1080
|
-
});
|
|
1081
|
-
return children.flatMap(function (child) {
|
|
1082
|
-
return [child.id].concat(getDescendants(child.id, allTasks));
|
|
1083
|
-
});
|
|
1084
|
-
};
|
|
1137
|
+
var getDescendants = function getDescendants(taskId) {
|
|
1138
|
+
var _taskIndex$childrenOf;
|
|
1085
1139
|
|
|
1086
|
-
|
|
1087
|
-
var
|
|
1088
|
-
|
|
1089
|
-
});
|
|
1090
|
-
if (!task) return;
|
|
1140
|
+
if (!taskIndex.byId.has(taskId)) return [];
|
|
1141
|
+
var out = [];
|
|
1142
|
+
var stack = [].concat((_taskIndex$childrenOf = taskIndex.childrenOf.get(taskId)) != null ? _taskIndex$childrenOf : []).reverse();
|
|
1091
1143
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1144
|
+
while (stack.length) {
|
|
1145
|
+
var id = stack.pop();
|
|
1146
|
+
out.push(id);
|
|
1147
|
+
var children = taskIndex.childrenOf.get(id);
|
|
1148
|
+
if (children) stack.push.apply(stack, [].concat(children).reverse());
|
|
1095
1149
|
}
|
|
1096
1150
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1151
|
+
return out;
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
var recursiveOpen = function recursiveOpen(taskId) {
|
|
1155
|
+
var stack = [taskId];
|
|
1156
|
+
|
|
1157
|
+
while (stack.length) {
|
|
1158
|
+
var id = stack.pop();
|
|
1159
|
+
var task = taskIndex.byId.get(id);
|
|
1160
|
+
var children = taskIndex.childrenOf.get(id);
|
|
1161
|
+
if (!task || !children) continue;
|
|
1162
|
+
|
|
1163
|
+
if (task.hideChildren && !expandedTasks.current.has(id)) {
|
|
1164
|
+
onExpanderClick(task);
|
|
1165
|
+
expandedTasks.current.add(id);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
stack.push.apply(stack, children);
|
|
1169
|
+
}
|
|
1103
1170
|
};
|
|
1104
1171
|
|
|
1105
1172
|
var handleTaskSelect = function handleTaskSelect(taskId, selected) {
|
|
@@ -1113,12 +1180,9 @@ var TaskList = function TaskList(_ref) {
|
|
|
1113
1180
|
|
|
1114
1181
|
var handleSelectAll = function handleSelectAll(selected) {
|
|
1115
1182
|
if (selected) {
|
|
1116
|
-
|
|
1117
|
-
return !getParentWbs(task.id);
|
|
1118
|
-
});
|
|
1119
|
-
setPendingTaskSelect(topLevelTasks.map(function (task) {
|
|
1183
|
+
setPendingTaskSelect(taskIndex.roots.map(function (taskId) {
|
|
1120
1184
|
return {
|
|
1121
|
-
taskId:
|
|
1185
|
+
taskId: taskId,
|
|
1122
1186
|
selected: true
|
|
1123
1187
|
};
|
|
1124
1188
|
}));
|
|
@@ -1220,16 +1284,52 @@ function isOffDay(date, cal) {
|
|
|
1220
1284
|
return false;
|
|
1221
1285
|
}
|
|
1222
1286
|
}
|
|
1287
|
+
var parsedShiftsCache = new WeakMap();
|
|
1288
|
+
var offDayCache = new WeakMap();
|
|
1289
|
+
|
|
1290
|
+
function parsedShifts(cal) {
|
|
1291
|
+
var shifts = parsedShiftsCache.get(cal);
|
|
1292
|
+
|
|
1293
|
+
if (!shifts) {
|
|
1294
|
+
var _cal$shifts;
|
|
1295
|
+
|
|
1296
|
+
shifts = ((_cal$shifts = cal.shifts) != null ? _cal$shifts : []).map(function (_ref) {
|
|
1297
|
+
var s = _ref[0],
|
|
1298
|
+
e = _ref[1];
|
|
1299
|
+
return {
|
|
1300
|
+
start: parseTimeToMinutes(s),
|
|
1301
|
+
end: parseTimeToMinutes(e)
|
|
1302
|
+
};
|
|
1303
|
+
});
|
|
1304
|
+
parsedShiftsCache.set(cal, shifts);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
return shifts;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function isOffDayCached(date, cal) {
|
|
1311
|
+
var perCal = offDayCache.get(cal);
|
|
1312
|
+
|
|
1313
|
+
if (!perCal) {
|
|
1314
|
+
perCal = new Map();
|
|
1315
|
+
offDayCache.set(cal, perCal);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
var key = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate();
|
|
1319
|
+
var off = perCal.get(key);
|
|
1320
|
+
|
|
1321
|
+
if (off === undefined) {
|
|
1322
|
+
off = isOffDay(date, cal);
|
|
1323
|
+
perCal.set(key, off);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
return off;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
var NO_SHIFTS = [];
|
|
1223
1330
|
function getShiftsForDay(date, cal) {
|
|
1224
|
-
if (
|
|
1225
|
-
return cal
|
|
1226
|
-
var s = _ref[0],
|
|
1227
|
-
e = _ref[1];
|
|
1228
|
-
return {
|
|
1229
|
-
start: parseTimeToMinutes(s),
|
|
1230
|
-
end: parseTimeToMinutes(e)
|
|
1231
|
-
};
|
|
1232
|
-
});
|
|
1331
|
+
if (!cal.shifts || isOffDayCached(date, cal)) return NO_SHIFTS;
|
|
1332
|
+
return parsedShifts(cal);
|
|
1233
1333
|
}
|
|
1234
1334
|
function getWorkingIntervals(start, end, cal) {
|
|
1235
1335
|
if (start >= end) return [];
|
|
@@ -1346,7 +1446,7 @@ var GridBody = function GridBody(_ref) {
|
|
|
1346
1446
|
viewMode = _ref.viewMode;
|
|
1347
1447
|
var visibleHeight = visibleEndY - visibleStartY;
|
|
1348
1448
|
var now = new Date();
|
|
1349
|
-
var items = virtualItems
|
|
1449
|
+
var items = virtualItems != null ? virtualItems : tasks.map(function (_, i) {
|
|
1350
1450
|
return {
|
|
1351
1451
|
index: i,
|
|
1352
1452
|
start: i * rowHeight,
|
|
@@ -2218,25 +2318,25 @@ var convertToBarTasks = function convertToBarTasks(tasks, dates, columnWidth, ro
|
|
|
2218
2318
|
var barTasks = tasks.map(function (t, i) {
|
|
2219
2319
|
return convertToBarTask(t, i, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor);
|
|
2220
2320
|
});
|
|
2321
|
+
var indexById = new Map();
|
|
2322
|
+
|
|
2323
|
+
for (var i = 0; i < barTasks.length; i++) {
|
|
2324
|
+
indexById.set(barTasks[i].id, i);
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2221
2327
|
barTasks = barTasks.map(function (task) {
|
|
2222
2328
|
var dependencies = task.dependencies || [];
|
|
2223
2329
|
|
|
2224
|
-
var
|
|
2225
|
-
var dependence =
|
|
2226
|
-
return value.id === dependencies[j].id;
|
|
2227
|
-
});
|
|
2330
|
+
for (var j = 0; j < dependencies.length; j++) {
|
|
2331
|
+
var dependence = indexById.get(dependencies[j].id);
|
|
2228
2332
|
|
|
2229
|
-
if (dependence !==
|
|
2333
|
+
if (dependence !== undefined && task.start.getTime() > 0 && task.end.getTime() > 0) {
|
|
2230
2334
|
var barchild = _extends({}, task, {
|
|
2231
2335
|
dependencyType: dependencies[j].type
|
|
2232
2336
|
});
|
|
2233
2337
|
|
|
2234
2338
|
barTasks[dependence].barChildren.push(barchild);
|
|
2235
2339
|
}
|
|
2236
|
-
};
|
|
2237
|
-
|
|
2238
|
-
for (var j = 0; j < dependencies.length; j++) {
|
|
2239
|
-
_loop(j);
|
|
2240
2340
|
}
|
|
2241
2341
|
|
|
2242
2342
|
return task;
|
|
@@ -2394,10 +2494,33 @@ var convertToMilestone = function convertToMilestone(task, index, dates, columnW
|
|
|
2394
2494
|
});
|
|
2395
2495
|
};
|
|
2396
2496
|
|
|
2497
|
+
var dateTimesCache = new WeakMap();
|
|
2498
|
+
|
|
2499
|
+
var getDateTimes = function getDateTimes(dates) {
|
|
2500
|
+
var times = dateTimesCache.get(dates);
|
|
2501
|
+
|
|
2502
|
+
if (!times) {
|
|
2503
|
+
times = dates.map(function (d) {
|
|
2504
|
+
return d.getTime();
|
|
2505
|
+
});
|
|
2506
|
+
dateTimesCache.set(dates, times);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
return times;
|
|
2510
|
+
};
|
|
2511
|
+
|
|
2397
2512
|
var taskXCoordinate = function taskXCoordinate(xDate, dates, columnWidth) {
|
|
2398
|
-
var
|
|
2399
|
-
|
|
2400
|
-
|
|
2513
|
+
var times = getDateTimes(dates);
|
|
2514
|
+
var target = xDate.getTime();
|
|
2515
|
+
var lo = 0;
|
|
2516
|
+
var hi = times.length - 1;
|
|
2517
|
+
|
|
2518
|
+
while (lo <= hi) {
|
|
2519
|
+
var mid = lo + hi >> 1;
|
|
2520
|
+
if (times[mid] >= target) hi = mid - 1;else lo = mid + 1;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
var index = (lo === times.length ? -1 : lo) - 1;
|
|
2401
2524
|
|
|
2402
2525
|
if (index < 0) {
|
|
2403
2526
|
if (dates[dates.length - 1].getTime() <= xDate.getTime()) {
|
|
@@ -3675,58 +3798,73 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3675
3798
|
}
|
|
3676
3799
|
};
|
|
3677
3800
|
|
|
3678
|
-
var
|
|
3679
|
-
|
|
3680
|
-
var a = ganttEvent.action;
|
|
3681
|
-
var isDraggingThis = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id;
|
|
3682
|
-
|
|
3683
|
-
var _live = isDraggingThis ? _extends({}, ganttEvent.changedTask, {
|
|
3684
|
-
y: _task.y
|
|
3685
|
-
}) : _task;
|
|
3801
|
+
var arrowIndex = React__default.useMemo(function () {
|
|
3802
|
+
var entries = [];
|
|
3686
3803
|
|
|
3687
|
-
|
|
3804
|
+
for (var i = 0; i < tasks.length; i++) {
|
|
3805
|
+
var task = tasks[i];
|
|
3806
|
+
var yFrom = task.y + taskHeight / 2;
|
|
3688
3807
|
|
|
3689
|
-
|
|
3690
|
-
|
|
3808
|
+
for (var _iterator = _createForOfIteratorHelperLoose(task.barChildren), _step; !(_step = _iterator()).done;) {
|
|
3809
|
+
var child = _step.value;
|
|
3810
|
+
var taskTo = tasks[child.index];
|
|
3811
|
+
if (!taskTo) continue;
|
|
3812
|
+
var yTo = taskTo.y + taskHeight / 2;
|
|
3813
|
+
entries.push({
|
|
3814
|
+
from: i,
|
|
3815
|
+
to: child.index,
|
|
3816
|
+
minY: Math.min(yFrom, yTo),
|
|
3817
|
+
maxY: Math.max(yFrom, yTo),
|
|
3818
|
+
dependencyType: child.dependencyType
|
|
3819
|
+
});
|
|
3691
3820
|
}
|
|
3821
|
+
}
|
|
3692
3822
|
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
var fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
|
|
3696
|
-
var toDrawable = !!taskTo && (taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1);
|
|
3823
|
+
return entries;
|
|
3824
|
+
}, [tasks, taskHeight]);
|
|
3697
3825
|
|
|
3698
|
-
|
|
3699
|
-
|
|
3826
|
+
var getArrows = function getArrows(isCritical, criticalPathType) {
|
|
3827
|
+
var out = [];
|
|
3828
|
+
var a = ganttEvent.action;
|
|
3829
|
+
var dragging = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask;
|
|
3700
3830
|
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
});
|
|
3704
|
-
var yFrom = task.y + taskHeight / 2;
|
|
3705
|
-
var yTo = taskTo.y + taskHeight / 2;
|
|
3706
|
-
var minY = Math.min(yFrom, yTo);
|
|
3707
|
-
var maxY = Math.max(yFrom, yTo);
|
|
3831
|
+
var _loop = function _loop() {
|
|
3832
|
+
var _task$criticalPathArr;
|
|
3708
3833
|
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3834
|
+
var e = _step2.value;
|
|
3835
|
+
if (e.maxY < visibleStartY || e.minY > visibleEndY) return "continue";
|
|
3836
|
+
var _task = tasks[e.from];
|
|
3837
|
+
var task = dragging && ganttEvent.changedTask.id === _task.id ? _extends({}, ganttEvent.changedTask, {
|
|
3838
|
+
y: _task.y
|
|
3839
|
+
}) : _task;
|
|
3840
|
+
if (!(task.start.getTime() > 0 && task.end.getTime() > 0)) return "continue";
|
|
3841
|
+
var taskTo = tasks[e.to];
|
|
3842
|
+
var fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
|
|
3843
|
+
var toDrawable = taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1;
|
|
3844
|
+
if (!fromDrawable || !toDrawable) return "continue";
|
|
3845
|
+
var criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(function (arrow) {
|
|
3846
|
+
return arrow.taskId === taskTo.id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
|
|
3847
|
+
});
|
|
3848
|
+
if (!!criticalTask !== isCritical) return "continue";
|
|
3849
|
+
out.push(React__default.createElement(Arrow, {
|
|
3850
|
+
key: "Arrow from " + task.id + " to " + taskTo.id + (isCritical ? "-critical" : ""),
|
|
3851
|
+
taskFrom: task,
|
|
3852
|
+
taskTo: taskTo,
|
|
3853
|
+
rowHeight: rowHeight,
|
|
3854
|
+
dependencyType: e.dependencyType,
|
|
3855
|
+
taskHeight: taskHeight,
|
|
3856
|
+
arrowIndent: arrowIndent,
|
|
3857
|
+
arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
|
|
3858
|
+
}));
|
|
3859
|
+
};
|
|
3712
3860
|
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
key: "Arrow from " + task.id + " to " + taskTo.id + (isCritical ? "-critical" : ""),
|
|
3716
|
-
taskFrom: task,
|
|
3717
|
-
taskTo: taskTo,
|
|
3718
|
-
rowHeight: rowHeight,
|
|
3719
|
-
dependencyType: child.dependencyType,
|
|
3720
|
-
taskHeight: taskHeight,
|
|
3721
|
-
arrowIndent: arrowIndent,
|
|
3722
|
-
arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
|
|
3723
|
-
});
|
|
3724
|
-
}
|
|
3725
|
-
}
|
|
3861
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(arrowIndex), _step2; !(_step2 = _iterator2()).done;) {
|
|
3862
|
+
var _ret = _loop();
|
|
3726
3863
|
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3864
|
+
if (_ret === "continue") continue;
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
return out;
|
|
3730
3868
|
};
|
|
3731
3869
|
|
|
3732
3870
|
var lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
|
|
@@ -3910,7 +4048,7 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3910
4048
|
var GANTT_MIN_WIDTH_RATIO = 0.4;
|
|
3911
4049
|
var TABLE_GANTT_DIVIDER_WIDTH = 20;
|
|
3912
4050
|
var Gantt = function Gantt(_ref) {
|
|
3913
|
-
var
|
|
4051
|
+
var _ref3;
|
|
3914
4052
|
|
|
3915
4053
|
var tasks = _ref.tasks,
|
|
3916
4054
|
primaryPath = _ref.primaryPath,
|
|
@@ -4024,9 +4162,9 @@ var Gantt = function Gantt(_ref) {
|
|
|
4024
4162
|
setTableContentWidth = _useState2[1];
|
|
4025
4163
|
|
|
4026
4164
|
var _useState3 = React.useState(function () {
|
|
4027
|
-
var
|
|
4028
|
-
startDateRange =
|
|
4029
|
-
endDateRange =
|
|
4165
|
+
var _ref2 = tasks ? ganttDateRange(tasks, viewMode, preStepsCount) : [new Date(), new Date()],
|
|
4166
|
+
startDateRange = _ref2[0],
|
|
4167
|
+
endDateRange = _ref2[1];
|
|
4030
4168
|
|
|
4031
4169
|
if (scheduleType === "lookAhead") {
|
|
4032
4170
|
return {
|
|
@@ -4178,7 +4316,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
4178
4316
|
setComputedColumnWidth(next);
|
|
4179
4317
|
}
|
|
4180
4318
|
}, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
|
|
4181
|
-
var columnWidth = (
|
|
4319
|
+
var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
|
|
4182
4320
|
var effectiveColumnWidth = React.useMemo(function () {
|
|
4183
4321
|
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
4184
4322
|
|
|
@@ -4250,9 +4388,9 @@ var Gantt = function Gantt(_ref) {
|
|
|
4250
4388
|
filteredTasks = removeHiddenTasks(tasks);
|
|
4251
4389
|
filteredTasks = filteredTasks.sort(sortTasks);
|
|
4252
4390
|
|
|
4253
|
-
var
|
|
4254
|
-
startDateRange =
|
|
4255
|
-
endDateRange =
|
|
4391
|
+
var _ganttDateRange = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0),
|
|
4392
|
+
startDateRange = _ganttDateRange[0],
|
|
4393
|
+
endDateRange = _ganttDateRange[1];
|
|
4256
4394
|
|
|
4257
4395
|
var newDates = seedDates(startDateRange, endDateRange, viewMode);
|
|
4258
4396
|
|
|
@@ -4282,7 +4420,8 @@ var Gantt = function Gantt(_ref) {
|
|
|
4282
4420
|
colorPath(primaryPath, "#ff0000", tasks, "primary");
|
|
4283
4421
|
}
|
|
4284
4422
|
|
|
4285
|
-
|
|
4423
|
+
var nextBarTasks = convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor);
|
|
4424
|
+
setBarTasks(nextBarTasks);
|
|
4286
4425
|
setIsProcessing(false);
|
|
4287
4426
|
}, delayToRender);
|
|
4288
4427
|
}, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, projectCalendar]);
|
|
@@ -4854,6 +4993,7 @@ function getCriticalPaths(leafTasks) {
|
|
|
4854
4993
|
taskChainList.sort(function (a, b) {
|
|
4855
4994
|
return b.duration - a.duration;
|
|
4856
4995
|
});
|
|
4996
|
+
console.debug(taskChainList);
|
|
4857
4997
|
var primaryLeaf = taskChainList[0].parent;
|
|
4858
4998
|
var primaryPath = [];
|
|
4859
4999
|
|
|
@@ -4921,59 +5061,76 @@ function getCriticalPaths(leafTasks) {
|
|
|
4921
5061
|
secondaryLeaf = _nextPath.task;
|
|
4922
5062
|
}
|
|
4923
5063
|
|
|
4924
|
-
console.debug("Primary", primaryPath);
|
|
4925
|
-
console.debug("Secondary", secondaryPath);
|
|
5064
|
+
console.debug("Primary ", primaryPath);
|
|
5065
|
+
console.debug("Secondary ", secondaryPath);
|
|
4926
5066
|
return [primaryPath, secondaryPath];
|
|
4927
5067
|
}
|
|
4928
5068
|
|
|
4929
5069
|
return [[], []];
|
|
4930
5070
|
}
|
|
5071
|
+
|
|
5072
|
+
function getOffTime$1(tIndex, taskMap, start, end) {
|
|
5073
|
+
var startWeek = Math.floor((start / 86400000 + 4) / 7);
|
|
5074
|
+
var endWeek = Math.floor((end / 86400000 + 4) / 7);
|
|
5075
|
+
var offTime = [];
|
|
5076
|
+
|
|
5077
|
+
if (taskMap[tIndex].task.calendar) {
|
|
5078
|
+
if (taskMap[tIndex].task.calendar.off_days && taskMap[tIndex].task.calendar.off_days.length) {
|
|
5079
|
+
for (var d = 0; d < taskMap[tIndex].task.calendar.off_days.length || 0; d++) {
|
|
5080
|
+
for (var w = startWeek; w <= endWeek; w++) {
|
|
5081
|
+
var dayOfTheWeek = taskMap[tIndex].task.calendar.off_days[d];
|
|
5082
|
+
var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
|
|
5083
|
+
|
|
5084
|
+
if (offDay >= start && offDay <= end) {
|
|
5085
|
+
offTime.push(offDay);
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
if (taskMap[tIndex].task.calendar.holidays && taskMap[tIndex].task.calendar.holidays.length) {
|
|
5092
|
+
for (var h = 0; h < taskMap[tIndex].task.calendar.holidays.length || 0; h++) {
|
|
5093
|
+
var holiday = taskMap[tIndex].task.calendar.holidays[h];
|
|
5094
|
+
var holiday_timestamp = new Date(holiday).getTime();
|
|
5095
|
+
|
|
5096
|
+
if (holiday_timestamp >= start && holiday_timestamp <= end) {
|
|
5097
|
+
offTime.push(holiday_timestamp);
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
return offTime;
|
|
5104
|
+
}
|
|
5105
|
+
|
|
4931
5106
|
function computeCriticalPath(taskID, taskMap) {
|
|
4932
5107
|
var task = taskMap[taskID].task;
|
|
4933
5108
|
var dependents = taskMap[taskID].dependents;
|
|
4934
5109
|
taskMap[taskID].start = task.start.getTime();
|
|
4935
5110
|
taskMap[taskID].end = task.end.getTime();
|
|
4936
5111
|
taskMap[taskID].paths = [];
|
|
5112
|
+
var parent_off_time = getOffTime$1(taskID, taskMap, taskMap[taskID].start, taskMap[taskID].end);
|
|
4937
5113
|
|
|
4938
5114
|
for (var j = 0; j < dependents.length; j++) {
|
|
4939
5115
|
var depStart = taskMap[dependents[j]].task.start.getTime();
|
|
4940
5116
|
var depEnd = taskMap[dependents[j]].task.end.getTime();
|
|
4941
5117
|
var depDuration = depEnd - depStart;
|
|
4942
|
-
var
|
|
4943
|
-
var
|
|
4944
|
-
var offTime = 0;
|
|
4945
|
-
|
|
4946
|
-
if (taskMap[dependents[j]].task.calendar) {
|
|
4947
|
-
if (taskMap[dependents[j]].task.calendar.off_days && taskMap[dependents[j]].task.calendar.off_days.length) {
|
|
4948
|
-
for (var d = 0; d < taskMap[dependents[j]].task.calendar.off_days.length || 0; d++) {
|
|
4949
|
-
for (var w = startWeek; w <= endWeek; w++) {
|
|
4950
|
-
var dayOfTheWeek = taskMap[dependents[j]].task.calendar.off_days[d];
|
|
4951
|
-
var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
|
|
4952
|
-
|
|
4953
|
-
if (offDay >= depStart && offDay <= depEnd && (offDay > taskMap[taskID].end || taskMap[taskID].task.calendar.off_days.includes(dayOfTheWeek))) {
|
|
4954
|
-
offTime += 86400000;
|
|
4955
|
-
}
|
|
4956
|
-
}
|
|
4957
|
-
}
|
|
4958
|
-
}
|
|
4959
|
-
|
|
4960
|
-
if (taskMap[dependents[j]].task.calendar.holidays && taskMap[dependents[j]].task.calendar.holidays.length) {
|
|
4961
|
-
for (var h = 0; h < taskMap[dependents[j]].task.calendar.holidays.length || 0; h++) {
|
|
4962
|
-
var holiday = taskMap[dependents[j]].task.calendar.holidays[h];
|
|
5118
|
+
var child_off_time = getOffTime$1(dependents[j], taskMap, depStart, depEnd);
|
|
5119
|
+
var overlap = Math.max(taskMap[taskID].end - depStart, 0);
|
|
4963
5120
|
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
5121
|
+
for (var t = 0; t < parent_off_time.length; t++) {
|
|
5122
|
+
if (child_off_time.includes(parent_off_time[t])) {
|
|
5123
|
+
parent_off_time.splice(t, 1);
|
|
5124
|
+
t -= 1;
|
|
4968
5125
|
}
|
|
4969
5126
|
}
|
|
4970
5127
|
|
|
4971
|
-
var
|
|
5128
|
+
var offTime = parent_off_time.length + child_off_time.length;
|
|
4972
5129
|
var paths = taskMap[dependents[j]].paths;
|
|
4973
5130
|
|
|
4974
5131
|
if (paths && paths.length) {
|
|
4975
5132
|
for (var k = 0; k < paths.length; k++) {
|
|
4976
|
-
var totalDuration = taskMap[taskID].end - taskMap[taskID].start - overlap -
|
|
5133
|
+
var totalDuration = taskMap[taskID].end - taskMap[taskID].start - overlap - parent_off_time.length * 86400000 + paths[k].duration;
|
|
4977
5134
|
|
|
4978
5135
|
if (taskMap[taskID].paths.length < 2) {
|
|
4979
5136
|
taskMap[taskID].paths.push({
|
|
@@ -4995,7 +5152,7 @@ function computeCriticalPath(taskID, taskMap) {
|
|
|
4995
5152
|
}
|
|
4996
5153
|
}
|
|
4997
5154
|
} else {
|
|
4998
|
-
var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime;
|
|
5155
|
+
var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime * 86400000;
|
|
4999
5156
|
|
|
5000
5157
|
if (taskMap[taskID].paths.length < 2) {
|
|
5001
5158
|
taskMap[taskID].paths.push({
|
|
@@ -5025,22 +5182,28 @@ function uncolorAll(tasks) {
|
|
|
5025
5182
|
});
|
|
5026
5183
|
}
|
|
5027
5184
|
function colorPath(path, color, tasks, criticalPathType) {
|
|
5028
|
-
|
|
5029
|
-
var longestIDLength = 0;
|
|
5030
|
-
var longestTask = void 0;
|
|
5185
|
+
var byId = new Map();
|
|
5031
5186
|
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
}
|
|
5187
|
+
for (var _iterator = _createForOfIteratorHelperLoose(tasks), _step; !(_step = _iterator()).done;) {
|
|
5188
|
+
var task = _step.value;
|
|
5189
|
+
byId.set(task.id, task);
|
|
5190
|
+
}
|
|
5037
5191
|
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5192
|
+
var nearest = function nearest(id) {
|
|
5193
|
+
var exact = byId.get(id);
|
|
5194
|
+
if (exact) return exact;
|
|
5195
|
+
|
|
5196
|
+
for (var cut = id.lastIndexOf("."); cut > 0; cut = id.lastIndexOf(".", cut - 1)) {
|
|
5197
|
+
var ancestor = byId.get(id.slice(0, cut));
|
|
5198
|
+
if (ancestor) return ancestor;
|
|
5042
5199
|
}
|
|
5043
5200
|
|
|
5201
|
+
return undefined;
|
|
5202
|
+
};
|
|
5203
|
+
|
|
5204
|
+
for (var i = 0; i < path.length; i++) {
|
|
5205
|
+
var longestTask = nearest(path[i].id);
|
|
5206
|
+
|
|
5044
5207
|
if (longestTask) {
|
|
5045
5208
|
var _longestTask$styles;
|
|
5046
5209
|
|
|
@@ -5052,14 +5215,7 @@ function colorPath(path, color, tasks, criticalPathType) {
|
|
|
5052
5215
|
}
|
|
5053
5216
|
|
|
5054
5217
|
var _loop = function _loop(_i9) {
|
|
5055
|
-
var taskFromTasks =
|
|
5056
|
-
|
|
5057
|
-
for (var _j2 = 0; _j2 < tasks.length; _j2++) {
|
|
5058
|
-
if (path[_i9].id === tasks[_j2].id) {
|
|
5059
|
-
taskFromTasks = tasks[_j2];
|
|
5060
|
-
break;
|
|
5061
|
-
}
|
|
5062
|
-
}
|
|
5218
|
+
var taskFromTasks = byId.get(path[_i9].id);
|
|
5063
5219
|
|
|
5064
5220
|
if (taskFromTasks) {
|
|
5065
5221
|
var arrows = taskFromTasks.criticalPathArrows;
|