@classic-homes/gantt-core 0.3.1 → 0.3.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/index.cjs +10 -5
- package/dist/index.js +10 -5
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1031,7 +1031,9 @@ function applyOperation(data, op) {
|
|
|
1031
1031
|
if (doomed.has(t.id)) inverse.push({ type: "add-task", task: t, index });
|
|
1032
1032
|
});
|
|
1033
1033
|
const removedDeps = dependencies.filter((d) => doomed.has(d.from) || doomed.has(d.to));
|
|
1034
|
-
|
|
1034
|
+
dependencies.forEach((d, index) => {
|
|
1035
|
+
if (removedDeps.includes(d)) inverse.push({ type: "add-dependency", dependency: d, index });
|
|
1036
|
+
});
|
|
1035
1037
|
return {
|
|
1036
1038
|
data: {
|
|
1037
1039
|
tasks: tasks.filter((t) => !doomed.has(t.id)),
|
|
@@ -1051,8 +1053,11 @@ function applyOperation(data, op) {
|
|
|
1051
1053
|
fail("These tasks are already linked");
|
|
1052
1054
|
if (wouldCreateCycle(tasks, dependencies, d.from, d.to))
|
|
1053
1055
|
fail("This link would create a circular dependency");
|
|
1056
|
+
const copy = dependencies.slice();
|
|
1057
|
+
const index = op.index === void 0 ? copy.length : Math.max(0, Math.min(op.index, copy.length));
|
|
1058
|
+
copy.splice(index, 0, d);
|
|
1054
1059
|
return {
|
|
1055
|
-
data: { tasks, dependencies:
|
|
1060
|
+
data: { tasks, dependencies: copy },
|
|
1056
1061
|
inverse: [{ type: "remove-dependency", id: d.id }]
|
|
1057
1062
|
};
|
|
1058
1063
|
}
|
|
@@ -1077,11 +1082,11 @@ function applyOperation(data, op) {
|
|
|
1077
1082
|
};
|
|
1078
1083
|
}
|
|
1079
1084
|
case "remove-dependency": {
|
|
1080
|
-
const
|
|
1081
|
-
if (
|
|
1085
|
+
const index = dependencies.findIndex((d) => d.id === op.id);
|
|
1086
|
+
if (index < 0) fail(`Unknown dependency "${op.id}"`);
|
|
1082
1087
|
return {
|
|
1083
1088
|
data: { tasks, dependencies: dependencies.filter((d) => d.id !== op.id) },
|
|
1084
|
-
inverse: [{ type: "add-dependency", dependency:
|
|
1089
|
+
inverse: [{ type: "add-dependency", dependency: dependencies[index], index }]
|
|
1085
1090
|
};
|
|
1086
1091
|
}
|
|
1087
1092
|
}
|
package/dist/index.js
CHANGED
|
@@ -100,7 +100,9 @@ function applyOperation(data, op) {
|
|
|
100
100
|
if (doomed.has(t.id)) inverse.push({ type: "add-task", task: t, index });
|
|
101
101
|
});
|
|
102
102
|
const removedDeps = dependencies.filter((d) => doomed.has(d.from) || doomed.has(d.to));
|
|
103
|
-
|
|
103
|
+
dependencies.forEach((d, index) => {
|
|
104
|
+
if (removedDeps.includes(d)) inverse.push({ type: "add-dependency", dependency: d, index });
|
|
105
|
+
});
|
|
104
106
|
return {
|
|
105
107
|
data: {
|
|
106
108
|
tasks: tasks.filter((t) => !doomed.has(t.id)),
|
|
@@ -120,8 +122,11 @@ function applyOperation(data, op) {
|
|
|
120
122
|
fail("These tasks are already linked");
|
|
121
123
|
if (wouldCreateCycle(tasks, dependencies, d.from, d.to))
|
|
122
124
|
fail("This link would create a circular dependency");
|
|
125
|
+
const copy = dependencies.slice();
|
|
126
|
+
const index = op.index === void 0 ? copy.length : Math.max(0, Math.min(op.index, copy.length));
|
|
127
|
+
copy.splice(index, 0, d);
|
|
123
128
|
return {
|
|
124
|
-
data: { tasks, dependencies:
|
|
129
|
+
data: { tasks, dependencies: copy },
|
|
125
130
|
inverse: [{ type: "remove-dependency", id: d.id }]
|
|
126
131
|
};
|
|
127
132
|
}
|
|
@@ -146,11 +151,11 @@ function applyOperation(data, op) {
|
|
|
146
151
|
};
|
|
147
152
|
}
|
|
148
153
|
case "remove-dependency": {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
154
|
+
const index = dependencies.findIndex((d) => d.id === op.id);
|
|
155
|
+
if (index < 0) fail(`Unknown dependency "${op.id}"`);
|
|
151
156
|
return {
|
|
152
157
|
data: { tasks, dependencies: dependencies.filter((d) => d.id !== op.id) },
|
|
153
|
-
inverse: [{ type: "add-dependency", dependency:
|
|
158
|
+
inverse: [{ type: "add-dependency", dependency: dependencies[index], index }]
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
}
|
package/dist/types/index.d.cts
CHANGED
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED