gantt-lib 0.145.1 → 0.145.2
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/core/scheduling/index.js +17 -7
- package/dist/core/scheduling/index.js.map +1 -1
- package/dist/core/scheduling/index.mjs +17 -7
- package/dist/core/scheduling/index.mjs.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2070,8 +2070,8 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2070
2070
|
}
|
|
2071
2071
|
}
|
|
2072
2072
|
const queue = snapshot.filter((task) => (indegree.get(task.id) ?? 0) === 0).map((task) => task.id);
|
|
2073
|
-
|
|
2074
|
-
const currentId = queue
|
|
2073
|
+
for (let queueIndex = 0; queueIndex < queue.length; queueIndex++) {
|
|
2074
|
+
const currentId = queue[queueIndex];
|
|
2075
2075
|
for (const successorId of successorIdsByTask.get(currentId) ?? []) {
|
|
2076
2076
|
const nextIndegree = (indegree.get(successorId) ?? 0) - 1;
|
|
2077
2077
|
indegree.set(successorId, nextIndegree);
|
|
@@ -2122,7 +2122,13 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2122
2122
|
queue.push(successorId);
|
|
2123
2123
|
}
|
|
2124
2124
|
}
|
|
2125
|
-
const
|
|
2125
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
2126
|
+
for (const task of snapshot) if (task.parentId) {
|
|
2127
|
+
const children = childrenByParent.get(task.parentId) ?? [];
|
|
2128
|
+
children.push(task.id);
|
|
2129
|
+
childrenByParent.set(task.parentId, children);
|
|
2130
|
+
}
|
|
2131
|
+
const parentsByDepth = snapshot.filter((task) => childrenByParent.has(task.id)).map((task) => {
|
|
2126
2132
|
let depth = 0;
|
|
2127
2133
|
let current = task.parentId ? workingMap.get(task.parentId) : void 0;
|
|
2128
2134
|
while (current) {
|
|
@@ -2131,17 +2137,21 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2131
2137
|
}
|
|
2132
2138
|
return { taskId: task.id, depth };
|
|
2133
2139
|
}).sort((left, right) => right.depth - left.depth);
|
|
2134
|
-
const workingTasks = () => Array.from(workingMap.values());
|
|
2135
2140
|
for (const { taskId } of parentsByDepth) {
|
|
2136
2141
|
const parent = workingMap.get(taskId);
|
|
2137
2142
|
if (!parent || parent.locked) {
|
|
2138
2143
|
continue;
|
|
2139
2144
|
}
|
|
2140
|
-
|
|
2145
|
+
let startTime = Infinity, endTime = -Infinity;
|
|
2146
|
+
for (const childId of childrenByParent.get(taskId)) {
|
|
2147
|
+
const child = workingMap.get(childId);
|
|
2148
|
+
startTime = Math.min(startTime, new Date(child.startDate).getTime());
|
|
2149
|
+
endTime = Math.max(endTime, new Date(child.endDate).getTime());
|
|
2150
|
+
}
|
|
2141
2151
|
workingMap.set(taskId, {
|
|
2142
2152
|
...parent,
|
|
2143
|
-
startDate: toIsoDate(
|
|
2144
|
-
endDate: toIsoDate(
|
|
2153
|
+
startDate: toIsoDate(new Date(startTime)),
|
|
2154
|
+
endDate: toIsoDate(new Date(endTime))
|
|
2145
2155
|
});
|
|
2146
2156
|
}
|
|
2147
2157
|
return createChangedResult(snapshot, Array.from(workingMap.values()));
|