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