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.js
CHANGED
|
@@ -2233,8 +2233,8 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
const queue = snapshot.filter((task) => (indegree.get(task.id) ?? 0) === 0).map((task) => task.id);
|
|
2236
|
-
|
|
2237
|
-
const currentId = queue
|
|
2236
|
+
for (let queueIndex = 0; queueIndex < queue.length; queueIndex++) {
|
|
2237
|
+
const currentId = queue[queueIndex];
|
|
2238
2238
|
for (const successorId of successorIdsByTask.get(currentId) ?? []) {
|
|
2239
2239
|
const nextIndegree = (indegree.get(successorId) ?? 0) - 1;
|
|
2240
2240
|
indegree.set(successorId, nextIndegree);
|
|
@@ -2285,7 +2285,13 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2285
2285
|
queue.push(successorId);
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
2288
|
-
const
|
|
2288
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
2289
|
+
for (const task of snapshot) if (task.parentId) {
|
|
2290
|
+
const children = childrenByParent.get(task.parentId) ?? [];
|
|
2291
|
+
children.push(task.id);
|
|
2292
|
+
childrenByParent.set(task.parentId, children);
|
|
2293
|
+
}
|
|
2294
|
+
const parentsByDepth = snapshot.filter((task) => childrenByParent.has(task.id)).map((task) => {
|
|
2289
2295
|
let depth = 0;
|
|
2290
2296
|
let current = task.parentId ? workingMap.get(task.parentId) : void 0;
|
|
2291
2297
|
while (current) {
|
|
@@ -2294,17 +2300,21 @@ function recalculateProjectSchedule(snapshot, options) {
|
|
|
2294
2300
|
}
|
|
2295
2301
|
return { taskId: task.id, depth };
|
|
2296
2302
|
}).sort((left, right) => right.depth - left.depth);
|
|
2297
|
-
const workingTasks = () => Array.from(workingMap.values());
|
|
2298
2303
|
for (const { taskId } of parentsByDepth) {
|
|
2299
2304
|
const parent = workingMap.get(taskId);
|
|
2300
2305
|
if (!parent || parent.locked) {
|
|
2301
2306
|
continue;
|
|
2302
2307
|
}
|
|
2303
|
-
|
|
2308
|
+
let startTime = Infinity, endTime = -Infinity;
|
|
2309
|
+
for (const childId of childrenByParent.get(taskId)) {
|
|
2310
|
+
const child = workingMap.get(childId);
|
|
2311
|
+
startTime = Math.min(startTime, new Date(child.startDate).getTime());
|
|
2312
|
+
endTime = Math.max(endTime, new Date(child.endDate).getTime());
|
|
2313
|
+
}
|
|
2304
2314
|
workingMap.set(taskId, {
|
|
2305
2315
|
...parent,
|
|
2306
|
-
startDate: toIsoDate(
|
|
2307
|
-
endDate: toIsoDate(
|
|
2316
|
+
startDate: toIsoDate(new Date(startTime)),
|
|
2317
|
+
endDate: toIsoDate(new Date(endTime))
|
|
2308
2318
|
});
|
|
2309
2319
|
}
|
|
2310
2320
|
return createChangedResult(snapshot, Array.from(workingMap.values()));
|