@workiom/frappe-gantt 1.0.21 → 1.0.23
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/README.md +65 -0
- package/dist/frappe-gantt.css +1 -1
- package/dist/frappe-gantt.es.js +753 -512
- package/dist/frappe-gantt.umd.js +92 -35
- package/package.json +1 -1
- package/src/arrow.js +205 -14
- package/src/bar.js +44 -0
- package/src/defaults.js +1 -0
- package/src/index.js +262 -2
- package/src/styles/dark.css +27 -0
- package/src/styles/gantt.css +69 -0
- package/src/styles/light.css +6 -0
package/dist/frappe-gantt.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = "year", A = "month", H = "day", S = "hour", Y = "minute", X = "second", F = "millisecond", g = {
|
|
2
2
|
parse_duration(r) {
|
|
3
3
|
const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(r);
|
|
4
4
|
if (e !== null) {
|
|
@@ -24,15 +24,15 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
24
24
|
if (typeof r == "string") {
|
|
25
25
|
let i, s;
|
|
26
26
|
const n = r.split(" ");
|
|
27
|
-
i = n[0].split(t).map((
|
|
28
|
-
let
|
|
29
|
-
return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3),
|
|
27
|
+
i = n[0].split(t).map((o) => parseInt(o, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
|
|
28
|
+
let a = i;
|
|
29
|
+
return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), a = a.concat(s)), new Date(...a);
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
to_string(r, t = !1) {
|
|
33
33
|
if (!(r instanceof Date))
|
|
34
34
|
throw new TypeError("Invalid argument type");
|
|
35
|
-
const e = this.get_date_values(r).map((n,
|
|
35
|
+
const e = this.get_date_values(r).map((n, a) => (a === 1 && (n = n + 1), a === 6 ? L(n + "", 3, "0") : L(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
|
|
36
36
|
return i + (t ? " " + s : "");
|
|
37
37
|
},
|
|
38
38
|
format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
|
|
@@ -40,39 +40,39 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
40
40
|
month: "long"
|
|
41
41
|
}), s = new Intl.DateTimeFormat(e, {
|
|
42
42
|
month: "short"
|
|
43
|
-
}), n = i.format(r),
|
|
44
|
-
YYYY:
|
|
45
|
-
MM: L(+
|
|
46
|
-
DD:
|
|
47
|
-
HH:
|
|
48
|
-
mm:
|
|
49
|
-
ss:
|
|
50
|
-
SSS:
|
|
51
|
-
D:
|
|
52
|
-
MMMM:
|
|
43
|
+
}), n = i.format(r), a = n.charAt(0).toUpperCase() + n.slice(1), o = this.get_date_values(r).map((l) => L(l, 2, 0)), d = {
|
|
44
|
+
YYYY: o[0],
|
|
45
|
+
MM: L(+o[1] + 1, 2, 0),
|
|
46
|
+
DD: o[2],
|
|
47
|
+
HH: o[3],
|
|
48
|
+
mm: o[4],
|
|
49
|
+
ss: o[5],
|
|
50
|
+
SSS: o[6],
|
|
51
|
+
D: o[2],
|
|
52
|
+
MMMM: a,
|
|
53
53
|
MMM: s.format(r)
|
|
54
54
|
};
|
|
55
|
-
let
|
|
55
|
+
let h = t;
|
|
56
56
|
const _ = [];
|
|
57
|
-
return Object.keys(
|
|
58
|
-
|
|
59
|
-
}), _.forEach((
|
|
60
|
-
|
|
61
|
-
}),
|
|
57
|
+
return Object.keys(d).sort((l, p) => p.length - l.length).forEach((l) => {
|
|
58
|
+
h.includes(l) && (h = h.replaceAll(l, `$${_.length}`), _.push(d[l]));
|
|
59
|
+
}), _.forEach((l, p) => {
|
|
60
|
+
h = h.replaceAll(`$${p}`, l);
|
|
61
|
+
}), h;
|
|
62
62
|
},
|
|
63
63
|
diff(r, t, e = "day") {
|
|
64
|
-
let i, s, n, o,
|
|
65
|
-
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3,
|
|
66
|
-
let _ = r.getFullYear() - t.getFullYear(),
|
|
67
|
-
return
|
|
64
|
+
let i, s, n, a, o, d, h;
|
|
65
|
+
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, a = s / 60, n = a / 60, o = n / 24;
|
|
66
|
+
let _ = r.getFullYear() - t.getFullYear(), l = r.getMonth() - t.getMonth();
|
|
67
|
+
return l += o % 30 / 30, d = _ * 12 + l, r.getDate() < t.getDate() && d--, h = d / 12, e.endsWith("s") || (e += "s"), Math.round(
|
|
68
68
|
{
|
|
69
69
|
milliseconds: i,
|
|
70
70
|
seconds: s,
|
|
71
|
-
minutes:
|
|
71
|
+
minutes: a,
|
|
72
72
|
hours: n,
|
|
73
|
-
days:
|
|
74
|
-
months:
|
|
75
|
-
years:
|
|
73
|
+
days: o,
|
|
74
|
+
months: d,
|
|
75
|
+
years: h
|
|
76
76
|
}[e] * 100
|
|
77
77
|
) / 100;
|
|
78
78
|
},
|
|
@@ -86,37 +86,37 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
86
86
|
add(r, t, e) {
|
|
87
87
|
t = parseInt(t, 10);
|
|
88
88
|
const i = [
|
|
89
|
-
r.getFullYear() + (e ===
|
|
90
|
-
r.getMonth() + (e ===
|
|
91
|
-
r.getDate() + (e ===
|
|
89
|
+
r.getFullYear() + (e === E ? t : 0),
|
|
90
|
+
r.getMonth() + (e === A ? t : 0),
|
|
91
|
+
r.getDate() + (e === H ? t : 0),
|
|
92
92
|
r.getHours() + (e === S ? t : 0),
|
|
93
|
-
r.getMinutes() + (e ===
|
|
93
|
+
r.getMinutes() + (e === Y ? t : 0),
|
|
94
94
|
r.getSeconds() + (e === X ? t : 0),
|
|
95
|
-
r.getMilliseconds() + (e ===
|
|
95
|
+
r.getMilliseconds() + (e === F ? t : 0)
|
|
96
96
|
];
|
|
97
97
|
return new Date(...i);
|
|
98
98
|
},
|
|
99
99
|
start_of(r, t) {
|
|
100
100
|
const e = {
|
|
101
|
-
[
|
|
102
|
-
[
|
|
103
|
-
[
|
|
101
|
+
[E]: 6,
|
|
102
|
+
[A]: 5,
|
|
103
|
+
[H]: 4,
|
|
104
104
|
[S]: 3,
|
|
105
|
-
[
|
|
105
|
+
[Y]: 2,
|
|
106
106
|
[X]: 1,
|
|
107
|
-
[
|
|
107
|
+
[F]: 0
|
|
108
108
|
};
|
|
109
109
|
function i(n) {
|
|
110
|
-
const
|
|
111
|
-
return e[n] <=
|
|
110
|
+
const a = e[t];
|
|
111
|
+
return e[n] <= a;
|
|
112
112
|
}
|
|
113
113
|
const s = [
|
|
114
114
|
r.getFullYear(),
|
|
115
|
-
i(
|
|
116
|
-
i(
|
|
117
|
-
i(
|
|
115
|
+
i(E) ? 0 : r.getMonth(),
|
|
116
|
+
i(A) ? 1 : r.getDate(),
|
|
117
|
+
i(H) ? 0 : r.getHours(),
|
|
118
118
|
i(S) ? 0 : r.getMinutes(),
|
|
119
|
-
i(
|
|
119
|
+
i(Y) ? 0 : r.getSeconds(),
|
|
120
120
|
i(X) ? 0 : r.getMilliseconds()
|
|
121
121
|
];
|
|
122
122
|
return new Date(...s);
|
|
@@ -161,26 +161,26 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
161
161
|
function L(r, t, e) {
|
|
162
162
|
return r = r + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), r.length > t ? String(r) : (t = t - r.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(r));
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function u(r, t) {
|
|
165
165
|
return typeof r == "string" ? (t || document).querySelector(r) : r || null;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function $(r, t) {
|
|
168
168
|
const e = document.createElementNS("http://www.w3.org/2000/svg", r);
|
|
169
169
|
for (let i in t)
|
|
170
170
|
i === "append_to" ? t.append_to.appendChild(e) : i === "innerHTML" ? e.innerHTML = t.innerHTML : i === "clipPath" ? e.setAttribute("clip-path", "url(#" + t[i] + ")") : e.setAttribute(i, t[i]);
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
173
|
function z(r, t, e, i) {
|
|
174
|
-
const s =
|
|
174
|
+
const s = R(r, t, e, i);
|
|
175
175
|
if (s === r) {
|
|
176
176
|
const n = document.createEvent("HTMLEvents");
|
|
177
177
|
n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
180
|
+
function R(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
181
|
+
const a = r.querySelector("animate");
|
|
182
|
+
if (a)
|
|
183
|
+
return u.attr(a, {
|
|
184
184
|
attributeName: t,
|
|
185
185
|
from: e,
|
|
186
186
|
to: i,
|
|
@@ -188,7 +188,7 @@ function B(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
|
188
188
|
begin: "click + " + n
|
|
189
189
|
// artificial click
|
|
190
190
|
}), r;
|
|
191
|
-
const
|
|
191
|
+
const o = $("animate", {
|
|
192
192
|
attributeName: t,
|
|
193
193
|
from: e,
|
|
194
194
|
to: i,
|
|
@@ -199,7 +199,7 @@ function B(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
|
199
199
|
keyTimes: "0; 1",
|
|
200
200
|
keySplines: G("ease-out")
|
|
201
201
|
});
|
|
202
|
-
return r.appendChild(
|
|
202
|
+
return r.appendChild(o), r;
|
|
203
203
|
}
|
|
204
204
|
function G(r) {
|
|
205
205
|
return {
|
|
@@ -210,30 +210,30 @@ function G(r) {
|
|
|
210
210
|
"ease-in-out": ".42 0 .58 1"
|
|
211
211
|
}[r];
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
i ?
|
|
213
|
+
u.on = (r, t, e, i) => {
|
|
214
|
+
i ? u.delegate(r, t, e, i) : (i = e, u.bind(r, t, i));
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
u.off = (r, t, e) => {
|
|
217
217
|
r.removeEventListener(t, e);
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
u.bind = (r, t, e) => {
|
|
220
220
|
t.split(/\s+/).forEach(function(i) {
|
|
221
221
|
r.addEventListener(i, e);
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
|
-
|
|
224
|
+
u.delegate = (r, t, e, i) => {
|
|
225
225
|
r.addEventListener(t, function(s) {
|
|
226
226
|
const n = s.target.closest(e);
|
|
227
227
|
n && (s.delegatedTarget = n, i.call(this, s, n));
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
u.closest = (r, t) => t ? t.matches(r) ? t : u.closest(r, t.parentNode) : null;
|
|
231
|
+
u.attr = (r, t, e) => {
|
|
232
232
|
if (!e && typeof t == "string")
|
|
233
233
|
return r.getAttribute(t);
|
|
234
234
|
if (typeof t == "object") {
|
|
235
235
|
for (let i in t)
|
|
236
|
-
|
|
236
|
+
u.attr(r, i, t[i]);
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
r.setAttribute(t, e);
|
|
@@ -241,92 +241,92 @@ m.attr = (r, t, e) => {
|
|
|
241
241
|
function I(r, t, e, i, s = "downstream") {
|
|
242
242
|
if (i === "none" || e === 0) return /* @__PURE__ */ new Map();
|
|
243
243
|
["upstream", "downstream", "both"].includes(s) || (console.warn(`[frappe-gantt] compute_dependency_shifts: unknown direction "${s}", falling back to "downstream"`), s = "downstream");
|
|
244
|
-
const n = /* @__PURE__ */ new Map(),
|
|
245
|
-
for (const
|
|
246
|
-
|
|
247
|
-
for (const
|
|
248
|
-
if (!
|
|
249
|
-
for (const
|
|
250
|
-
if (!n.has(
|
|
251
|
-
const _ =
|
|
252
|
-
|
|
244
|
+
const n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const d of r)
|
|
246
|
+
d._has_no_dates || (n.set(d.id, d), a.set(d.id, []), o.set(d.id, []));
|
|
247
|
+
for (const d of r)
|
|
248
|
+
if (!d._has_no_dates)
|
|
249
|
+
for (const h of d.dependencies || []) {
|
|
250
|
+
if (!n.has(h.id)) continue;
|
|
251
|
+
const _ = h.type || "finish-to-start";
|
|
252
|
+
a.get(d.id).push({ id: h.id, type: _ }), o.get(h.id).push({ id: d.id, type: _ });
|
|
253
253
|
}
|
|
254
|
-
return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e,
|
|
254
|
+
return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e, a, o, s === "both", s === "upstream") : i === "consume_buffer" ? U(t, e, n, a, o, s) : /* @__PURE__ */ new Map();
|
|
255
255
|
}
|
|
256
256
|
function q(r, t, e, i, s, n) {
|
|
257
|
-
const
|
|
258
|
-
for (const { id:
|
|
259
|
-
|
|
257
|
+
const a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([r]), d = [], h = (_) => {
|
|
258
|
+
for (const { id: l } of _)
|
|
259
|
+
o.has(l) || (o.add(l), d.push(l));
|
|
260
260
|
};
|
|
261
|
-
for (n && !s ?
|
|
262
|
-
const _ =
|
|
263
|
-
|
|
261
|
+
for (n && !s ? h(e.get(r) || []) : (h(i.get(r) || []), s && h(e.get(r) || [])); d.length > 0; ) {
|
|
262
|
+
const _ = d.shift();
|
|
263
|
+
a.set(_, t), n && !s ? h(e.get(_) || []) : (h(i.get(_) || []), s && h(e.get(_) || []));
|
|
264
264
|
}
|
|
265
|
-
return
|
|
265
|
+
return a;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
const
|
|
269
|
-
for (const [
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
for (const [
|
|
273
|
-
|
|
274
|
-
for (;
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
for (const { id:
|
|
278
|
-
const
|
|
279
|
-
|
|
267
|
+
function U(r, t, e, i, s, n) {
|
|
268
|
+
const a = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const [c] of e)
|
|
270
|
+
a.set(c, (i.get(c) || []).length);
|
|
271
|
+
const o = [], d = [];
|
|
272
|
+
for (const [c, m] of a)
|
|
273
|
+
m === 0 && d.push(c);
|
|
274
|
+
for (; d.length > 0; ) {
|
|
275
|
+
const c = d.shift();
|
|
276
|
+
o.push(c);
|
|
277
|
+
for (const { id: m } of s.get(c) || []) {
|
|
278
|
+
const f = a.get(m) - 1;
|
|
279
|
+
a.set(m, f), f === 0 && d.push(m);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
282
|
+
const h = /* @__PURE__ */ new Map([[r, 0]]), _ = (c) => e.get(c)._start.getTime() + (h.get(c) || 0), l = (c) => e.get(c)._end.getTime() + (h.get(c) || 0);
|
|
283
283
|
if (n === "downstream" || n === "both")
|
|
284
|
-
for (const
|
|
285
|
-
if (
|
|
286
|
-
let
|
|
287
|
-
for (const { id:
|
|
288
|
-
const y =
|
|
289
|
-
y >
|
|
284
|
+
for (const c of o) {
|
|
285
|
+
if (c === r) continue;
|
|
286
|
+
let m = 0;
|
|
287
|
+
for (const { id: f, type: w } of i.get(c) || []) {
|
|
288
|
+
const y = W(f, c, w, _, l);
|
|
289
|
+
y > m && (m = y);
|
|
290
290
|
}
|
|
291
|
-
|
|
291
|
+
m > 0 && h.set(c, (h.get(c) || 0) + m);
|
|
292
292
|
}
|
|
293
293
|
if (n === "upstream" || n === "both")
|
|
294
|
-
for (let
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
297
|
-
let
|
|
298
|
-
for (const { id:
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
const
|
|
302
|
-
|
|
294
|
+
for (let c = o.length - 1; c >= 0; c--) {
|
|
295
|
+
const m = o[c];
|
|
296
|
+
if (m === r) continue;
|
|
297
|
+
let f = 0;
|
|
298
|
+
for (const { id: w, type: y } of s.get(m) || []) {
|
|
299
|
+
const x = W(m, w, y, _, l);
|
|
300
|
+
if (x > 0) {
|
|
301
|
+
const b = -x;
|
|
302
|
+
b < f && (f = b);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
f < 0 && h.set(m, (h.get(m) || 0) + f);
|
|
306
306
|
}
|
|
307
307
|
const p = /* @__PURE__ */ new Map();
|
|
308
|
-
for (const [
|
|
309
|
-
|
|
308
|
+
for (const [c, m] of h)
|
|
309
|
+
c !== r && m !== 0 && p.set(c, m);
|
|
310
310
|
return p;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
const n = i(r),
|
|
312
|
+
function W(r, t, e, i, s) {
|
|
313
|
+
const n = i(r), a = s(r), o = i(t), d = s(t);
|
|
314
314
|
switch (e) {
|
|
315
315
|
case "finish-to-start":
|
|
316
|
-
return
|
|
316
|
+
return a > o ? a - o : 0;
|
|
317
317
|
case "start-to-start":
|
|
318
|
-
return n >
|
|
318
|
+
return n > o ? n - o : 0;
|
|
319
319
|
case "finish-to-finish":
|
|
320
|
-
return
|
|
320
|
+
return a > d ? a - d : 0;
|
|
321
321
|
case "start-to-finish":
|
|
322
|
-
return n >
|
|
322
|
+
return n > d ? n - d : 0;
|
|
323
323
|
default:
|
|
324
|
-
return
|
|
324
|
+
return a > o ? a - o : 0;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
class
|
|
327
|
+
class Q {
|
|
328
328
|
constructor(t, e, i, s) {
|
|
329
|
-
this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.calculate_path(), this.draw();
|
|
329
|
+
this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.is_active = !1, this.calculate_path(), this.draw();
|
|
330
330
|
}
|
|
331
331
|
check_critical_path() {
|
|
332
332
|
return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
|
|
@@ -346,128 +346,185 @@ class U {
|
|
|
346
346
|
return !1;
|
|
347
347
|
}
|
|
348
348
|
calculate_path() {
|
|
349
|
-
const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(),
|
|
349
|
+
const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(), a = this.from_task.$bar.getX(), o = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), d = this.to_task.$bar.getX(), h = (c) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * c.task._index + t.padding / 2, _ = h(this.from_task), l = h(this.to_task), p = (_ + l) / 2;
|
|
350
350
|
switch (this.dependency_type) {
|
|
351
351
|
case "finish-to-start":
|
|
352
352
|
this.path = this._path_finish_to_start(
|
|
353
353
|
n,
|
|
354
|
-
o,
|
|
355
354
|
a,
|
|
356
|
-
|
|
355
|
+
o,
|
|
356
|
+
d,
|
|
357
357
|
_,
|
|
358
|
-
|
|
358
|
+
l,
|
|
359
359
|
p,
|
|
360
360
|
s,
|
|
361
361
|
i
|
|
362
|
-
);
|
|
362
|
+
), this.label_pos = { x: d, y: l, side: "left" };
|
|
363
363
|
break;
|
|
364
364
|
case "start-to-start":
|
|
365
365
|
this.path = this._path_start_to_start(
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
a,
|
|
367
|
+
d,
|
|
368
368
|
_,
|
|
369
|
-
|
|
369
|
+
l,
|
|
370
370
|
s,
|
|
371
371
|
i
|
|
372
|
-
);
|
|
372
|
+
), this.label_pos = { x: d, y: l, side: "left" };
|
|
373
373
|
break;
|
|
374
374
|
case "finish-to-finish":
|
|
375
375
|
this.path = this._path_finish_to_finish(
|
|
376
376
|
n,
|
|
377
|
-
|
|
377
|
+
o,
|
|
378
378
|
_,
|
|
379
|
-
|
|
379
|
+
l,
|
|
380
380
|
s,
|
|
381
381
|
i
|
|
382
|
-
);
|
|
382
|
+
), this.label_pos = { x: o, y: l, side: "right" };
|
|
383
383
|
break;
|
|
384
384
|
case "start-to-finish":
|
|
385
385
|
this.path = this._path_start_to_finish(
|
|
386
|
-
o,
|
|
387
386
|
a,
|
|
387
|
+
o,
|
|
388
388
|
_,
|
|
389
|
-
|
|
389
|
+
l,
|
|
390
390
|
p,
|
|
391
391
|
s,
|
|
392
392
|
i
|
|
393
|
-
);
|
|
393
|
+
), this.label_pos = { x: o, y: l, side: "right" };
|
|
394
394
|
break;
|
|
395
395
|
default:
|
|
396
396
|
this.path = this._path_finish_to_start(
|
|
397
397
|
n,
|
|
398
|
-
o,
|
|
399
398
|
a,
|
|
400
|
-
|
|
399
|
+
o,
|
|
400
|
+
d,
|
|
401
401
|
_,
|
|
402
|
-
|
|
402
|
+
l,
|
|
403
403
|
p,
|
|
404
404
|
s,
|
|
405
405
|
i
|
|
406
|
-
);
|
|
406
|
+
), this.label_pos = { x: d, y: l, side: "left" };
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
_path_finish_to_start(t, e, i, s, n, o,
|
|
410
|
-
const _ = t +
|
|
409
|
+
_path_finish_to_start(t, e, i, s, n, a, o, d, h) {
|
|
410
|
+
const _ = t + d, l = a < n;
|
|
411
411
|
if (_ < s)
|
|
412
|
-
return `
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
412
|
+
return l ? `
|
|
413
|
+
M ${t} ${n}
|
|
414
|
+
H ${_ - h}
|
|
415
|
+
a ${h} ${h} 0 0 0 ${h} ${-h}
|
|
416
|
+
V ${a + h}
|
|
417
|
+
a ${h} ${h} 0 0 1 ${h} ${-h}
|
|
418
|
+
H ${s}
|
|
419
|
+
m -5 -5 l 5 5 l -5 5` : `
|
|
420
|
+
M ${t} ${n}
|
|
421
|
+
H ${_ - h}
|
|
422
|
+
a ${h} ${h} 0 0 1 ${h} ${h}
|
|
423
|
+
V ${a - h}
|
|
424
|
+
a ${h} ${h} 0 0 0 ${h} ${h}
|
|
425
|
+
H ${s}
|
|
426
|
+
m -5 -5 l 5 5 l -5 5`;
|
|
427
|
+
const p = s - d;
|
|
428
|
+
return l ? `
|
|
429
|
+
M ${t} ${n}
|
|
430
|
+
H ${_ - h}
|
|
431
|
+
a ${h} ${h} 0 0 0 ${h} ${-h}
|
|
432
|
+
V ${o + h}
|
|
433
|
+
a ${h} ${h} 0 0 0 ${-h} ${-h}
|
|
434
|
+
H ${p + h}
|
|
435
|
+
a ${h} ${h} 0 0 1 ${-h} ${-h}
|
|
436
|
+
V ${a + h}
|
|
437
|
+
a ${h} ${h} 0 0 1 ${h} ${-h}
|
|
438
|
+
H ${s}
|
|
439
|
+
m -5 -5 l 5 5 l -5 5` : `
|
|
422
440
|
M ${t} ${n}
|
|
423
|
-
H ${_ -
|
|
424
|
-
a ${
|
|
425
|
-
V ${
|
|
426
|
-
a ${
|
|
427
|
-
H ${
|
|
428
|
-
a ${
|
|
429
|
-
V ${
|
|
430
|
-
a ${
|
|
441
|
+
H ${_ - h}
|
|
442
|
+
a ${h} ${h} 0 0 1 ${h} ${h}
|
|
443
|
+
V ${o - h}
|
|
444
|
+
a ${h} ${h} 0 0 1 ${-h} ${h}
|
|
445
|
+
H ${p + h}
|
|
446
|
+
a ${h} ${h} 0 0 0 ${-h} ${h}
|
|
447
|
+
V ${a - h}
|
|
448
|
+
a ${h} ${h} 0 0 0 ${h} ${h}
|
|
431
449
|
H ${s}
|
|
432
450
|
m -5 -5 l 5 5 l -5 5`;
|
|
433
451
|
}
|
|
434
|
-
_path_start_to_start(t, e, i, s, n,
|
|
435
|
-
const
|
|
436
|
-
return `
|
|
452
|
+
_path_start_to_start(t, e, i, s, n, a) {
|
|
453
|
+
const o = Math.min(t, e) - n;
|
|
454
|
+
return s < i ? `
|
|
437
455
|
M ${t} ${i}
|
|
438
|
-
H ${
|
|
439
|
-
a ${
|
|
440
|
-
V ${s
|
|
441
|
-
a ${
|
|
456
|
+
H ${o + a}
|
|
457
|
+
a ${a} ${a} 0 0 1 ${-a} ${-a}
|
|
458
|
+
V ${s + a}
|
|
459
|
+
a ${a} ${a} 0 0 1 ${a} ${-a}
|
|
460
|
+
H ${e}
|
|
461
|
+
m -5 -5 l 5 5 l -5 5` : `
|
|
462
|
+
M ${t} ${i}
|
|
463
|
+
H ${o + a}
|
|
464
|
+
a ${a} ${a} 0 0 0 ${-a} ${a}
|
|
465
|
+
V ${s - a}
|
|
466
|
+
a ${a} ${a} 0 0 0 ${a} ${a}
|
|
442
467
|
H ${e}
|
|
443
468
|
m -5 -5 l 5 5 l -5 5`;
|
|
444
469
|
}
|
|
445
|
-
_path_finish_to_finish(t, e, i, s, n,
|
|
446
|
-
const
|
|
447
|
-
return `
|
|
470
|
+
_path_finish_to_finish(t, e, i, s, n, a) {
|
|
471
|
+
const o = Math.max(t, e) + n;
|
|
472
|
+
return s < i ? `
|
|
448
473
|
M ${t} ${i}
|
|
449
|
-
H ${
|
|
450
|
-
a ${
|
|
451
|
-
V ${s
|
|
452
|
-
a ${
|
|
474
|
+
H ${o - a}
|
|
475
|
+
a ${a} ${a} 0 0 0 ${a} ${-a}
|
|
476
|
+
V ${s + a}
|
|
477
|
+
a ${a} ${a} 0 0 0 ${-a} ${-a}
|
|
453
478
|
H ${e}
|
|
454
|
-
m 5 -5 l -5 5 l 5 5
|
|
455
|
-
}
|
|
456
|
-
_path_start_to_finish(t, e, i, s, n, o, a) {
|
|
457
|
-
const h = t - o, d = e + o;
|
|
458
|
-
return `
|
|
479
|
+
m 5 -5 l -5 5 l 5 5` : `
|
|
459
480
|
M ${t} ${i}
|
|
460
|
-
H ${
|
|
461
|
-
a ${a} ${a} 0 0 0 ${-a} ${a}
|
|
462
|
-
V ${n - a}
|
|
463
|
-
a ${a} ${a} 0 0 0 ${a} ${a}
|
|
464
|
-
H ${d - a}
|
|
481
|
+
H ${o - a}
|
|
465
482
|
a ${a} ${a} 0 0 1 ${a} ${a}
|
|
466
483
|
V ${s - a}
|
|
467
484
|
a ${a} ${a} 0 0 1 ${-a} ${a}
|
|
468
485
|
H ${e}
|
|
469
486
|
m 5 -5 l -5 5 l 5 5`;
|
|
470
487
|
}
|
|
488
|
+
_path_start_to_finish(t, e, i, s, n, a, o) {
|
|
489
|
+
const d = t - a, h = e + a, _ = s < i;
|
|
490
|
+
return h < d + 2 * o ? _ ? `
|
|
491
|
+
M ${t} ${i}
|
|
492
|
+
H ${d + o}
|
|
493
|
+
a ${o} ${o} 0 0 1 ${-o} ${-o}
|
|
494
|
+
V ${s + o}
|
|
495
|
+
a ${o} ${o} 0 0 0 ${-o} ${-o}
|
|
496
|
+
H ${e}
|
|
497
|
+
m 5 -5 l -5 5 l 5 5` : `
|
|
498
|
+
M ${t} ${i}
|
|
499
|
+
H ${d + o}
|
|
500
|
+
a ${o} ${o} 0 0 0 ${-o} ${o}
|
|
501
|
+
V ${s - o}
|
|
502
|
+
a ${o} ${o} 0 0 1 ${-o} ${o}
|
|
503
|
+
H ${e}
|
|
504
|
+
m 5 -5 l -5 5 l 5 5` : _ ? `
|
|
505
|
+
M ${t} ${i}
|
|
506
|
+
H ${d + o}
|
|
507
|
+
a ${o} ${o} 0 0 1 ${-o} ${-o}
|
|
508
|
+
V ${n + o}
|
|
509
|
+
a ${o} ${o} 0 0 1 ${o} ${-o}
|
|
510
|
+
H ${h - o}
|
|
511
|
+
a ${o} ${o} 0 0 0 ${o} ${-o}
|
|
512
|
+
V ${s + o}
|
|
513
|
+
a ${o} ${o} 0 0 0 ${-o} ${-o}
|
|
514
|
+
H ${e}
|
|
515
|
+
m 5 -5 l -5 5 l 5 5` : `
|
|
516
|
+
M ${t} ${i}
|
|
517
|
+
H ${d + o}
|
|
518
|
+
a ${o} ${o} 0 0 0 ${-o} ${o}
|
|
519
|
+
V ${n - o}
|
|
520
|
+
a ${o} ${o} 0 0 0 ${o} ${o}
|
|
521
|
+
H ${h - o}
|
|
522
|
+
a ${o} ${o} 0 0 1 ${o} ${o}
|
|
523
|
+
V ${s - o}
|
|
524
|
+
a ${o} ${o} 0 0 1 ${-o} ${o}
|
|
525
|
+
H ${e}
|
|
526
|
+
m 5 -5 l -5 5 l 5 5`;
|
|
527
|
+
}
|
|
471
528
|
_get_connected_bars() {
|
|
472
529
|
const t = this.from_task.task.id, e = this.to_task.task.id;
|
|
473
530
|
return Array.from(
|
|
@@ -478,12 +535,12 @@ class U {
|
|
|
478
535
|
}
|
|
479
536
|
draw() {
|
|
480
537
|
let t = "";
|
|
481
|
-
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element =
|
|
538
|
+
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element = $("path", {
|
|
482
539
|
d: this.path,
|
|
483
540
|
"data-from": this.from_task.task.id,
|
|
484
541
|
"data-to": this.to_task.task.id,
|
|
485
542
|
class: t
|
|
486
|
-
}), this.hit_element =
|
|
543
|
+
}), this.hit_element = $("path", {
|
|
487
544
|
d: this.path,
|
|
488
545
|
stroke: "transparent",
|
|
489
546
|
"stroke-width": 15,
|
|
@@ -495,21 +552,72 @@ class U {
|
|
|
495
552
|
this._get_connected_bars().forEach((i) => {
|
|
496
553
|
const s = i.querySelector(".bar");
|
|
497
554
|
s && s.classList.add(e);
|
|
498
|
-
});
|
|
555
|
+
}), this._show_label();
|
|
499
556
|
}), this.hit_element.addEventListener("mouseleave", () => {
|
|
500
557
|
this.is_hovered = !1, this.element.classList.remove("arrow-hover"), this._get_connected_bars().forEach((e) => {
|
|
501
558
|
const i = e.querySelector(".bar");
|
|
502
|
-
i && i.classList.remove("bar-arrow-hover", "bar-arrow-critical", "bar-arrow-invalid");
|
|
503
|
-
});
|
|
559
|
+
i && (i.classList.remove("bar-arrow-hover"), this.is_active || i.classList.remove("bar-arrow-critical", "bar-arrow-invalid"));
|
|
560
|
+
}), !this.is_active && !this.is_hovered && this._hide_label();
|
|
561
|
+
}), this.hit_element.addEventListener("click", (e) => {
|
|
562
|
+
e.stopPropagation(), this.is_active ? this.gantt.set_active_arrow(null) : this.gantt.set_active_arrow(this);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
_get_type_abbr() {
|
|
566
|
+
return {
|
|
567
|
+
"finish-to-start": "FS",
|
|
568
|
+
"start-to-start": "SS",
|
|
569
|
+
"finish-to-finish": "FF",
|
|
570
|
+
"start-to-finish": "SF"
|
|
571
|
+
}[this.dependency_type] || "FS";
|
|
572
|
+
}
|
|
573
|
+
_show_label() {
|
|
574
|
+
if (this.label_element) return;
|
|
575
|
+
const t = this._get_type_abbr(), e = 21, i = 20, { x: s, y: n, side: a } = this.label_pos, o = a === "left" ? s - 10 - e / 2 : s + 10 + e / 2, d = n;
|
|
576
|
+
this.label_element = $("g", { class: "arrow-type-label" });
|
|
577
|
+
const h = $("rect", {
|
|
578
|
+
x: o - e / 2,
|
|
579
|
+
y: d - i / 2,
|
|
580
|
+
width: e,
|
|
581
|
+
height: i,
|
|
582
|
+
rx: 3
|
|
583
|
+
}), _ = $("text", {
|
|
584
|
+
x: o,
|
|
585
|
+
y: d,
|
|
586
|
+
"dominant-baseline": "middle",
|
|
587
|
+
"text-anchor": "middle"
|
|
588
|
+
});
|
|
589
|
+
_.textContent = t, this.label_element.appendChild(h), this.label_element.appendChild(_), this.label_element.addEventListener("mouseenter", () => {
|
|
590
|
+
this.hit_element.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !1 }));
|
|
591
|
+
}), this.label_element.addEventListener("mouseleave", () => {
|
|
592
|
+
this.hit_element.dispatchEvent(new MouseEvent("mouseleave", { bubbles: !1 }));
|
|
593
|
+
}), this.label_element.addEventListener("click", (l) => {
|
|
594
|
+
l.stopPropagation(), this.hit_element.dispatchEvent(new MouseEvent("click", { bubbles: !1 }));
|
|
595
|
+
}), this.gantt.layers.arrow.appendChild(this.label_element);
|
|
596
|
+
}
|
|
597
|
+
_hide_label() {
|
|
598
|
+
this.label_element && (this.label_element.remove(), this.label_element = null);
|
|
599
|
+
}
|
|
600
|
+
activate() {
|
|
601
|
+
this.is_active = !0, this.element.classList.add("arrow-active"), this._show_label();
|
|
602
|
+
const t = this.is_invalid ? "bar-arrow-invalid" : this.is_critical ? "bar-arrow-critical" : "bar-arrow-active";
|
|
603
|
+
this._get_connected_bars().forEach((e) => {
|
|
604
|
+
const i = e.querySelector(".bar");
|
|
605
|
+
i && i.classList.add(t);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
deactivate() {
|
|
609
|
+
this.is_active = !1, this.element.classList.remove("arrow-active"), this._hide_label(), this._get_connected_bars().forEach((t) => {
|
|
610
|
+
const e = t.querySelector(".bar");
|
|
611
|
+
e && e.classList.remove("bar-arrow-active", "bar-arrow-critical", "bar-arrow-invalid");
|
|
504
612
|
});
|
|
505
613
|
}
|
|
506
614
|
update() {
|
|
507
615
|
this.calculate_path(), this.element.setAttribute("d", this.path), this.hit_element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
|
|
508
616
|
let t = "";
|
|
509
|
-
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.element.setAttribute("class", t.trim());
|
|
617
|
+
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.is_active && (t += " arrow-active"), this.element.setAttribute("class", t.trim());
|
|
510
618
|
}
|
|
511
619
|
}
|
|
512
|
-
class
|
|
620
|
+
class K {
|
|
513
621
|
constructor(t, e) {
|
|
514
622
|
this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
|
|
515
623
|
}
|
|
@@ -520,13 +628,13 @@ class Q {
|
|
|
520
628
|
this.action_completed = !1, this.gantt = t, this.task = e, this.name = this.name || "", this.is_dragging = !1, this.is_hovering_bar = !1, this.is_hovering_icon = !1, this.add_icon_hide_timeout = null;
|
|
521
629
|
}
|
|
522
630
|
prepare_wrappers() {
|
|
523
|
-
this.group =
|
|
631
|
+
this.group = $("g", {
|
|
524
632
|
class: "bar-wrapper" + (this.task.custom_class ? " " + this.task.custom_class : ""),
|
|
525
633
|
"data-id": this.task.id
|
|
526
|
-
}), this.bar_group =
|
|
634
|
+
}), this.bar_group = $("g", {
|
|
527
635
|
class: "bar-group",
|
|
528
636
|
append_to: this.group
|
|
529
|
-
}), this.handle_group =
|
|
637
|
+
}), this.handle_group = $("g", {
|
|
530
638
|
class: "handle-group",
|
|
531
639
|
append_to: this.group
|
|
532
640
|
});
|
|
@@ -551,10 +659,10 @@ class Q {
|
|
|
551
659
|
this.compute_expected_progress(), this.expected_progress_width = this.gantt.options.column_width * this.duration * (this.expected_progress / 100) || 0;
|
|
552
660
|
}
|
|
553
661
|
draw() {
|
|
554
|
-
this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail(), this.gantt.options.task_add_icon_position && this.draw_add_task_icon();
|
|
662
|
+
this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail(), this.gantt.options.task_add_icon_position && this.draw_add_task_icon(), this.draw_connector_circles();
|
|
555
663
|
}
|
|
556
664
|
draw_bar() {
|
|
557
|
-
this.$bar =
|
|
665
|
+
this.$bar = $("rect", {
|
|
558
666
|
x: this.x,
|
|
559
667
|
y: this.y,
|
|
560
668
|
width: this.width,
|
|
@@ -566,7 +674,7 @@ class Q {
|
|
|
566
674
|
}), this.task.color && (this.$bar.style.fill = this.task.color), z(this.$bar, "width", 0, this.width), this.invalid && this.$bar.classList.add("bar-invalid");
|
|
567
675
|
}
|
|
568
676
|
draw_expected_progress_bar() {
|
|
569
|
-
this.invalid || (this.$expected_bar_progress =
|
|
677
|
+
this.invalid || (this.$expected_bar_progress = $("rect", {
|
|
570
678
|
x: this.x,
|
|
571
679
|
y: this.y,
|
|
572
680
|
width: this.expected_progress_width,
|
|
@@ -586,7 +694,7 @@ class Q {
|
|
|
586
694
|
if (this.invalid) return;
|
|
587
695
|
this.progress_width = this.calculate_progress_width();
|
|
588
696
|
let t = this.corner_radius;
|
|
589
|
-
/^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress =
|
|
697
|
+
/^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress = $("rect", {
|
|
590
698
|
x: this.x,
|
|
591
699
|
y: this.y,
|
|
592
700
|
width: this.progress_width,
|
|
@@ -610,15 +718,15 @@ class Q {
|
|
|
610
718
|
this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), z(this.$bar_progress, "width", 0, this.progress_width);
|
|
611
719
|
}
|
|
612
720
|
calculate_progress_width() {
|
|
613
|
-
const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((
|
|
721
|
+
const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((d, h) => d + (h >= this.x && h < e), 0) * this.gantt.config.column_width;
|
|
614
722
|
let s = (t - i) * this.task.progress / 100;
|
|
615
|
-
const n = this.x + s,
|
|
616
|
-
s +=
|
|
617
|
-
let
|
|
723
|
+
const n = this.x + s, a = this.gantt.config.ignored_positions.reduce((d, h) => d + (h >= this.x && h < n), 0) * this.gantt.config.column_width;
|
|
724
|
+
s += a;
|
|
725
|
+
let o = this.gantt.get_ignored_region(
|
|
618
726
|
this.x + s
|
|
619
727
|
);
|
|
620
|
-
for (;
|
|
621
|
-
s += this.gantt.config.column_width,
|
|
728
|
+
for (; o.length; )
|
|
729
|
+
s += this.gantt.config.column_width, o = this.gantt.get_ignored_region(
|
|
622
730
|
this.x + s
|
|
623
731
|
);
|
|
624
732
|
return this.progress_width = s, s;
|
|
@@ -627,7 +735,7 @@ class Q {
|
|
|
627
735
|
let t = this.x + this.$bar.getWidth() / 2;
|
|
628
736
|
this.task.thumbnail && (t = this.x + this.image_size + 5);
|
|
629
737
|
const e = this.gantt.options.task_column.enabled ? "" : this.task.name;
|
|
630
|
-
this.$bar_label =
|
|
738
|
+
this.$bar_label = $("text", {
|
|
631
739
|
x: t,
|
|
632
740
|
y: this.y + this.height / 2,
|
|
633
741
|
innerHTML: e,
|
|
@@ -637,9 +745,9 @@ class Q {
|
|
|
637
745
|
}
|
|
638
746
|
draw_thumbnail() {
|
|
639
747
|
let t = 10, e = 2, i, s;
|
|
640
|
-
i =
|
|
748
|
+
i = $("defs", {
|
|
641
749
|
append_to: this.bar_group
|
|
642
|
-
}),
|
|
750
|
+
}), $("rect", {
|
|
643
751
|
id: "rect_" + this.task.id,
|
|
644
752
|
x: this.x + t,
|
|
645
753
|
y: this.y + e,
|
|
@@ -648,13 +756,13 @@ class Q {
|
|
|
648
756
|
rx: "15",
|
|
649
757
|
class: "img_mask",
|
|
650
758
|
append_to: i
|
|
651
|
-
}), s =
|
|
759
|
+
}), s = $("clipPath", {
|
|
652
760
|
id: "clip_" + this.task.id,
|
|
653
761
|
append_to: i
|
|
654
|
-
}),
|
|
762
|
+
}), $("use", {
|
|
655
763
|
href: "#rect_" + this.task.id,
|
|
656
764
|
append_to: s
|
|
657
|
-
}),
|
|
765
|
+
}), $("image", {
|
|
658
766
|
x: this.x + t,
|
|
659
767
|
y: this.y + e,
|
|
660
768
|
width: this.image_size,
|
|
@@ -675,38 +783,38 @@ class Q {
|
|
|
675
783
|
else
|
|
676
784
|
return;
|
|
677
785
|
const s = this.y + (this.height - 20) / 2;
|
|
678
|
-
this.$add_icon_group =
|
|
786
|
+
this.$add_icon_group = $("g", {
|
|
679
787
|
class: "add-task-icon hide",
|
|
680
788
|
append_to: this.handle_group
|
|
681
|
-
}), this.$add_icon_circle =
|
|
789
|
+
}), this.$add_icon_circle = $("circle", {
|
|
682
790
|
cx: i + 20 / 2,
|
|
683
791
|
cy: s + 20 / 2,
|
|
684
792
|
r: 20 / 2,
|
|
685
793
|
class: "add-task-icon-bg",
|
|
686
794
|
append_to: this.$add_icon_group
|
|
687
|
-
}), this.$add_icon_vertical =
|
|
795
|
+
}), this.$add_icon_vertical = $("line", {
|
|
688
796
|
x1: i + 20 / 2,
|
|
689
797
|
y1: s + 5,
|
|
690
798
|
x2: i + 20 / 2,
|
|
691
799
|
y2: s + 20 - 5,
|
|
692
800
|
class: "add-task-icon-plus",
|
|
693
801
|
append_to: this.$add_icon_group
|
|
694
|
-
}), this.$add_icon_horizontal =
|
|
802
|
+
}), this.$add_icon_horizontal = $("line", {
|
|
695
803
|
x1: i + 5,
|
|
696
804
|
y1: s + 20 / 2,
|
|
697
805
|
x2: i + 20 - 5,
|
|
698
806
|
y2: s + 20 / 2,
|
|
699
807
|
class: "add-task-icon-plus",
|
|
700
808
|
append_to: this.$add_icon_group
|
|
701
|
-
}),
|
|
809
|
+
}), u.on(this.$add_icon_group, "mousedown", (n) => {
|
|
702
810
|
n.stopPropagation();
|
|
703
|
-
}),
|
|
811
|
+
}), u.on(this.$add_icon_group, "mouseup", (n) => {
|
|
704
812
|
n.stopPropagation();
|
|
705
|
-
}),
|
|
813
|
+
}), u.on(this.$add_icon_group, "click", (n) => {
|
|
706
814
|
n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
|
|
707
|
-
}),
|
|
815
|
+
}), u.on(this.$add_icon_group, "mouseenter", (n) => {
|
|
708
816
|
this.is_hovering_icon = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.$add_icon_group.classList.add("active"), this.$add_icon_group.classList.remove("hide"), n.stopPropagation();
|
|
709
|
-
}),
|
|
817
|
+
}), u.on(this.$add_icon_group, "mouseleave", () => {
|
|
710
818
|
this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
|
|
711
819
|
});
|
|
712
820
|
}
|
|
@@ -714,7 +822,7 @@ class Q {
|
|
|
714
822
|
if (this.invalid || this.gantt.options.readonly) return;
|
|
715
823
|
const t = this.$bar, e = 8;
|
|
716
824
|
if (this.handles = [], this.gantt.options.readonly_dates || (this.handles.push(
|
|
717
|
-
|
|
825
|
+
$("rect", {
|
|
718
826
|
x: t.getEndX() - e,
|
|
719
827
|
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
720
828
|
width: e,
|
|
@@ -725,7 +833,7 @@ class Q {
|
|
|
725
833
|
append_to: this.handle_group
|
|
726
834
|
})
|
|
727
835
|
), this.handles.push(
|
|
728
|
-
|
|
836
|
+
$("rect", {
|
|
729
837
|
x: t.getX() - e,
|
|
730
838
|
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
731
839
|
width: e,
|
|
@@ -737,7 +845,7 @@ class Q {
|
|
|
737
845
|
})
|
|
738
846
|
)), !this.gantt.options.readonly_progress) {
|
|
739
847
|
const i = this.$bar_progress;
|
|
740
|
-
this.$handle_progress =
|
|
848
|
+
this.$handle_progress = $("circle", {
|
|
741
849
|
cx: i.getEndX(),
|
|
742
850
|
cy: i.getY() + i.getHeight() / 2,
|
|
743
851
|
r: 4.5,
|
|
@@ -746,14 +854,38 @@ class Q {
|
|
|
746
854
|
}), this.handles.push(this.$handle_progress);
|
|
747
855
|
}
|
|
748
856
|
for (let i of this.handles)
|
|
749
|
-
|
|
857
|
+
u.on(i, "mouseenter", () => i.classList.add("active")), u.on(i, "mouseleave", () => i.classList.remove("active"));
|
|
858
|
+
}
|
|
859
|
+
draw_connector_circles() {
|
|
860
|
+
if (this.$connector_start = null, this.$connector_end = null, !this.gantt.options.allow_dependency_creation || this.gantt.options.readonly) return;
|
|
861
|
+
const t = this.gantt.options.isRTL, e = this.y + this.height / 2, i = t ? this.x + this.width : this.x, s = t ? this.x : this.x + this.width;
|
|
862
|
+
this.$connector_start = $("circle", {
|
|
863
|
+
class: "connector-circle connector-start",
|
|
864
|
+
"data-endpoint": "start",
|
|
865
|
+
cx: i,
|
|
866
|
+
cy: e,
|
|
867
|
+
r: 4,
|
|
868
|
+
append_to: this.handle_group
|
|
869
|
+
}), this.$connector_end = $("circle", {
|
|
870
|
+
class: "connector-circle connector-end",
|
|
871
|
+
"data-endpoint": "end",
|
|
872
|
+
cx: s,
|
|
873
|
+
cy: e,
|
|
874
|
+
r: 4,
|
|
875
|
+
append_to: this.handle_group
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
update_connector_circles() {
|
|
879
|
+
if (!this.$connector_start) return;
|
|
880
|
+
const t = this.gantt.options.isRTL, e = this.$bar.getX(), i = this.$bar.getWidth(), s = this.y + this.height / 2, n = t ? e + i : e, a = t ? e : e + i;
|
|
881
|
+
this.$connector_start.setAttribute("cx", n), this.$connector_start.setAttribute("cy", s), this.$connector_end.setAttribute("cx", a), this.$connector_end.setAttribute("cy", s);
|
|
750
882
|
}
|
|
751
883
|
bind() {
|
|
752
884
|
this.invalid || this.setup_click_event();
|
|
753
885
|
}
|
|
754
886
|
unbind() {
|
|
755
887
|
this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
|
|
756
|
-
|
|
888
|
+
u.off(this.group, t, e);
|
|
757
889
|
}), this.event_listeners = []);
|
|
758
890
|
}
|
|
759
891
|
setup_click_event() {
|
|
@@ -767,21 +899,21 @@ class Q {
|
|
|
767
899
|
p
|
|
768
900
|
]);
|
|
769
901
|
};
|
|
770
|
-
if (
|
|
771
|
-
const p = (
|
|
772
|
-
const
|
|
902
|
+
if (u.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
|
|
903
|
+
const p = (c) => {
|
|
904
|
+
const m = c.offsetX || c.layerX;
|
|
773
905
|
if (this.$handle_progress) {
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
906
|
+
const f = +this.$handle_progress.getAttribute("cx");
|
|
907
|
+
if (f > m - 1 && f < m + 1 || this.gantt.bar_being_dragged) return;
|
|
776
908
|
}
|
|
777
909
|
this.gantt.show_popup({
|
|
778
|
-
x:
|
|
779
|
-
y:
|
|
910
|
+
x: c.offsetX || c.layerX,
|
|
911
|
+
y: c.offsetY || c.layerY,
|
|
780
912
|
task: this.task,
|
|
781
913
|
target: this.$bar
|
|
782
914
|
});
|
|
783
915
|
};
|
|
784
|
-
|
|
916
|
+
u.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
|
|
785
917
|
}
|
|
786
918
|
let i;
|
|
787
919
|
const s = (p) => {
|
|
@@ -792,56 +924,56 @@ class Q {
|
|
|
792
924
|
task: this.task,
|
|
793
925
|
target: this.$bar
|
|
794
926
|
});
|
|
795
|
-
const
|
|
796
|
-
|
|
927
|
+
const c = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
|
|
928
|
+
c && c.classList.remove("hide");
|
|
797
929
|
}, 200), this.$add_icon_group && (this.is_hovering_bar = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.is_dragging || this.$add_icon_group.classList.remove("hide"));
|
|
798
930
|
};
|
|
799
|
-
|
|
931
|
+
u.on(this.group, "mouseenter", s), this.event_listeners.push({ event: "mouseenter", handler: s });
|
|
800
932
|
const n = () => {
|
|
801
|
-
var
|
|
802
|
-
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((
|
|
933
|
+
var c, m;
|
|
934
|
+
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((m = (c = this.gantt.popup) == null ? void 0 : c.hide) == null || m.call(c));
|
|
803
935
|
const p = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
|
|
804
936
|
p && p.classList.add("hide"), this.$add_icon_group && (this.is_hovering_bar = !1, this.add_icon_hide_timeout && clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = setTimeout(() => {
|
|
805
937
|
this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
|
|
806
938
|
}, 200));
|
|
807
939
|
};
|
|
808
|
-
|
|
809
|
-
const
|
|
940
|
+
u.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
|
|
941
|
+
const a = () => {
|
|
810
942
|
this.is_dragging = !0, this.hide_add_icon();
|
|
811
943
|
};
|
|
812
|
-
|
|
813
|
-
const
|
|
944
|
+
u.on(this.group, "mousedown", a), this.event_listeners.push({ event: "mousedown", handler: a });
|
|
945
|
+
const o = () => {
|
|
814
946
|
setTimeout(() => {
|
|
815
947
|
this.gantt.bar_being_dragged !== !0 && (this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide"));
|
|
816
948
|
}, 0);
|
|
817
949
|
};
|
|
818
|
-
|
|
819
|
-
const
|
|
950
|
+
u.on(this.group, "mouseup", o), this.event_listeners.push({ event: "mouseup", handler: o });
|
|
951
|
+
const d = () => {
|
|
820
952
|
this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
|
|
821
953
|
};
|
|
822
|
-
|
|
823
|
-
const
|
|
954
|
+
u.on(this.group, "click", d), this.event_listeners.push({ event: "click", handler: d });
|
|
955
|
+
const h = () => {
|
|
824
956
|
this.action_completed || (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
|
|
825
957
|
};
|
|
826
|
-
|
|
958
|
+
u.on(this.group, "dblclick", h), this.event_listeners.push({ event: "dblclick", handler: h });
|
|
827
959
|
let _ = !1;
|
|
828
|
-
const
|
|
960
|
+
const l = (p) => {
|
|
829
961
|
if (!_)
|
|
830
962
|
return _ = !0, setTimeout(function() {
|
|
831
963
|
_ = !1;
|
|
832
964
|
}, 300), !1;
|
|
833
965
|
p.preventDefault(), !this.action_completed && (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
|
|
834
966
|
};
|
|
835
|
-
|
|
967
|
+
u.on(this.group, "touchstart", l), this.event_listeners.push({ event: "touchstart", handler: l });
|
|
836
968
|
}
|
|
837
969
|
update_bar_position({ x: t = null, width: e = null }) {
|
|
838
970
|
const i = this.$bar;
|
|
839
|
-
t && (this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px"), e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_position(), this.update_add_icon_position(), this.date_changed(), this.compute_duration(), this.gantt.options.show_expected_progress && this.update_expected_progressbar_position(), this.update_progressbar_position(), this.update_arrow_position();
|
|
971
|
+
t && (this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px"), e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_position(), this.update_add_icon_position(), this.date_changed(), this.compute_duration(), this.gantt.options.show_expected_progress && this.update_expected_progressbar_position(), this.update_progressbar_position(), this.update_arrow_position(), this.update_connector_circles();
|
|
840
972
|
}
|
|
841
973
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
|
842
|
-
const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "",
|
|
843
|
-
let
|
|
844
|
-
s.classList.contains("big") || (
|
|
974
|
+
const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", a = this.bar_group.querySelector(".img_mask") || "";
|
|
975
|
+
let o = this.$bar.getX() + this.$bar.getWidth(), d = s.getX() + t, h = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, l = d + s.getBBox().width + 7, p = e + i.clientWidth / 2;
|
|
976
|
+
s.classList.contains("big") || (l < o && t > 0 && l < p || d - _ > this.$bar.getX() && t < 0 && l > p) && (s.setAttribute("x", d), n && (n.setAttribute("x", h), a.setAttribute("x", h)));
|
|
845
977
|
}
|
|
846
978
|
date_changed() {
|
|
847
979
|
let t = !1;
|
|
@@ -924,14 +1056,14 @@ class Q {
|
|
|
924
1056
|
}
|
|
925
1057
|
update_label_position() {
|
|
926
1058
|
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
|
|
927
|
-
let n = 5,
|
|
928
|
-
const
|
|
929
|
-
|
|
1059
|
+
let n = 5, a = this.image_size + 10;
|
|
1060
|
+
const o = i.getBBox().width, d = e.getWidth();
|
|
1061
|
+
o > d ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + a)) : i.setAttribute("x", e.getEndX() + n)) : (i.classList.remove("big"), s ? (s.setAttribute("x", e.getX() + n), t.setAttribute("x", e.getX() + n), i.setAttribute(
|
|
930
1062
|
"x",
|
|
931
|
-
e.getX() +
|
|
1063
|
+
e.getX() + d / 2 + a
|
|
932
1064
|
)) : i.setAttribute(
|
|
933
1065
|
"x",
|
|
934
|
-
e.getX() +
|
|
1066
|
+
e.getX() + d / 2 - o / 2
|
|
935
1067
|
));
|
|
936
1068
|
}
|
|
937
1069
|
update_handle_position() {
|
|
@@ -963,7 +1095,7 @@ class Q {
|
|
|
963
1095
|
t.update();
|
|
964
1096
|
}
|
|
965
1097
|
}
|
|
966
|
-
class
|
|
1098
|
+
class J {
|
|
967
1099
|
constructor(t, e, i) {
|
|
968
1100
|
this.parent = t, this.popup_func = e, this.gantt = i, this.make();
|
|
969
1101
|
}
|
|
@@ -981,18 +1113,18 @@ class K {
|
|
|
981
1113
|
task: i,
|
|
982
1114
|
chart: this.gantt,
|
|
983
1115
|
get_title: () => this.title,
|
|
984
|
-
set_title: (
|
|
1116
|
+
set_title: (a) => this.title.innerHTML = a,
|
|
985
1117
|
get_subtitle: () => this.subtitle,
|
|
986
|
-
set_subtitle: (
|
|
1118
|
+
set_subtitle: (a) => this.subtitle.innerHTML = a,
|
|
987
1119
|
get_details: () => this.details,
|
|
988
|
-
set_details: (
|
|
989
|
-
add_action: (
|
|
990
|
-
let
|
|
1120
|
+
set_details: (a) => this.details.innerHTML = a,
|
|
1121
|
+
add_action: (a, o) => {
|
|
1122
|
+
let d = this.gantt.create_el({
|
|
991
1123
|
classes: "action-btn",
|
|
992
1124
|
type: "button",
|
|
993
1125
|
append_to: this.actions
|
|
994
1126
|
});
|
|
995
|
-
typeof
|
|
1127
|
+
typeof a == "function" && (a = a(i)), d.innerHTML = a, d.onclick = (h) => o(i, this.gantt, h);
|
|
996
1128
|
}
|
|
997
1129
|
});
|
|
998
1130
|
n !== !1 && (n && (this.parent.innerHTML = n), this.actions.innerHTML === "" ? this.actions.remove() : this.parent.appendChild(this.actions), this.parent.style.left = t + 10 + "px", this.parent.style.top = e - 10 + "px", this.parent.classList.remove("hide"));
|
|
@@ -1005,11 +1137,11 @@ function C(r) {
|
|
|
1005
1137
|
const t = r.getFullYear();
|
|
1006
1138
|
return t - t % 10 + "";
|
|
1007
1139
|
}
|
|
1008
|
-
function
|
|
1140
|
+
function Z(r, t, e) {
|
|
1009
1141
|
let i = g.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
|
|
1010
1142
|
return `${g.format(r, n, e)} - ${g.format(i, s, e)}`;
|
|
1011
1143
|
}
|
|
1012
|
-
const
|
|
1144
|
+
const k = [
|
|
1013
1145
|
{
|
|
1014
1146
|
name: "Hour",
|
|
1015
1147
|
padding: "7d",
|
|
@@ -1052,7 +1184,7 @@ const x = [
|
|
|
1052
1184
|
step: "7d",
|
|
1053
1185
|
date_format: "YYYY-MM-DD",
|
|
1054
1186
|
column_width: 140,
|
|
1055
|
-
lower_text:
|
|
1187
|
+
lower_text: Z,
|
|
1056
1188
|
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
|
|
1057
1189
|
thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
|
|
1058
1190
|
upper_text_frequency: 4
|
|
@@ -1078,7 +1210,8 @@ const x = [
|
|
|
1078
1210
|
lower_text: "YYYY",
|
|
1079
1211
|
snap_at: "30d"
|
|
1080
1212
|
}
|
|
1081
|
-
],
|
|
1213
|
+
], B = {
|
|
1214
|
+
allow_dependency_creation: !0,
|
|
1082
1215
|
arrow_curve: 5,
|
|
1083
1216
|
auto_move_label: !1,
|
|
1084
1217
|
bar_corner_radius: 3,
|
|
@@ -1125,7 +1258,7 @@ const x = [
|
|
|
1125
1258
|
today_button: !0,
|
|
1126
1259
|
view_mode: "Day",
|
|
1127
1260
|
view_mode_select: !1,
|
|
1128
|
-
view_modes:
|
|
1261
|
+
view_modes: k,
|
|
1129
1262
|
is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6,
|
|
1130
1263
|
task_column: {
|
|
1131
1264
|
enabled: !1,
|
|
@@ -1156,7 +1289,7 @@ class tt {
|
|
|
1156
1289
|
throw new TypeError(
|
|
1157
1290
|
"Frappe Gantt only supports usage of a string CSS selector, HTML DOM element or SVG DOM element for the 'element' parameter"
|
|
1158
1291
|
);
|
|
1159
|
-
e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg =
|
|
1292
|
+
e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg = $("svg", {
|
|
1160
1293
|
append_to: i,
|
|
1161
1294
|
class: "gantt"
|
|
1162
1295
|
}), this.$wrapper = this.create_el({
|
|
@@ -1177,15 +1310,15 @@ class tt {
|
|
|
1177
1310
|
var i;
|
|
1178
1311
|
this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((s) => {
|
|
1179
1312
|
if (typeof s == "string") {
|
|
1180
|
-
const n =
|
|
1181
|
-
(
|
|
1313
|
+
const n = k.find(
|
|
1314
|
+
(a) => a.name === s
|
|
1182
1315
|
);
|
|
1183
1316
|
return n || console.error(
|
|
1184
1317
|
`The view mode "${s}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
|
|
1185
1318
|
), n;
|
|
1186
1319
|
}
|
|
1187
1320
|
return s;
|
|
1188
|
-
}), t.view_mode = t.view_modes[0]), this.options = { ...
|
|
1321
|
+
}), t.view_mode = t.view_modes[0]), this.options = { ...B, ...t };
|
|
1189
1322
|
const e = {
|
|
1190
1323
|
"grid-height": "container_height",
|
|
1191
1324
|
"bar-height": "bar_height",
|
|
@@ -1246,9 +1379,9 @@ class tt {
|
|
|
1246
1379
|
return console.error(`task "${e.id}" doesn't have an end date`), !1;
|
|
1247
1380
|
}
|
|
1248
1381
|
if (!e._has_no_dates) {
|
|
1249
|
-
if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((
|
|
1250
|
-
let { duration:
|
|
1251
|
-
e.end = g.add(e.end,
|
|
1382
|
+
if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((d) => {
|
|
1383
|
+
let { duration: h, scale: _ } = g.parse_duration(d);
|
|
1384
|
+
e.end = g.add(e.end, h, _);
|
|
1252
1385
|
})), e._end = g.parse(e.end), g.diff(e._end, e._start, "year") < 0)
|
|
1253
1386
|
return console.error(
|
|
1254
1387
|
`start of task can't be after end of task: in task "${e.id}"`
|
|
@@ -1257,7 +1390,7 @@ class tt {
|
|
|
1257
1390
|
return console.error(
|
|
1258
1391
|
`the duration of task "${e.id}" is too long (above ten years)`
|
|
1259
1392
|
), !1;
|
|
1260
|
-
e._index = i, g.get_date_values(e._end).slice(3).every((
|
|
1393
|
+
e._index = i, g.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = g.add(e._end, 24, "hour"));
|
|
1261
1394
|
}
|
|
1262
1395
|
return (typeof e.dependencies == "string" || Array.isArray(e.dependencies) && e.dependencies.some((n) => typeof n == "string")) && console.warn(`[frappe-gantt] Task "${e.id}": dependencies must be an array of {id, type?} objects. String format is no longer supported.`), Array.isArray(e.dependencies) || (e.dependencies = []), e.dependencies = e.dependencies.filter((n) => n && typeof n.id == "string").map((n) => ({ ...n, id: n.id.replaceAll(" ", "_") })), e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = et(e), e;
|
|
1263
1396
|
}).filter((e) => e).map((e, i) => (e._index = i, e)), this.setup_dependencies();
|
|
@@ -1272,9 +1405,9 @@ class tt {
|
|
|
1272
1405
|
this.setup_tasks(t), this.change_view_mode(this.options.view_mode, e);
|
|
1273
1406
|
}
|
|
1274
1407
|
update_task(t, e) {
|
|
1275
|
-
let i = this.tasks.find((
|
|
1408
|
+
let i = this.tasks.find((a) => a.id === t), s = this.bars[i._index];
|
|
1276
1409
|
const n = e.dependencies !== void 0;
|
|
1277
|
-
Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((
|
|
1410
|
+
Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((a) => a && typeof a.id == "string").map((a) => ({ ...a, id: a.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
|
|
1278
1411
|
}
|
|
1279
1412
|
change_view_mode(t = this.options.view_mode, e = !1) {
|
|
1280
1413
|
typeof t == "string" && (t = this.options.view_modes.find((n) => n.name === t));
|
|
@@ -1337,7 +1470,7 @@ class tt {
|
|
|
1337
1470
|
), this.dates.push(t);
|
|
1338
1471
|
}
|
|
1339
1472
|
bind_events() {
|
|
1340
|
-
this.bind_grid_click(), this.bind_holiday_labels(), this.bind_bar_events(), this.bind_task_column_resize(), this.bind_task_column_scroll();
|
|
1473
|
+
this.bind_grid_click(), this.bind_holiday_labels(), this.bind_bar_events(), this.bind_task_column_resize(), this.bind_task_column_scroll(), this.options.allow_dependency_creation && this.bind_dependency_linking();
|
|
1341
1474
|
}
|
|
1342
1475
|
render() {
|
|
1343
1476
|
this.clear(), this.setup_layers(), this.make_grid(), this.make_dates(), this.make_grid_extras(), this.make_bars(), this.make_arrows(), this.map_arrows_on_bars(), this.set_dimensions(), this.set_scroll_position(this.options.scroll_to);
|
|
@@ -1346,11 +1479,14 @@ class tt {
|
|
|
1346
1479
|
this.layers = {};
|
|
1347
1480
|
const t = ["grid", "arrow", "progress", "bar"];
|
|
1348
1481
|
for (let e of t)
|
|
1349
|
-
this.layers[e] =
|
|
1482
|
+
this.layers[e] = $("g", {
|
|
1350
1483
|
class: e,
|
|
1351
1484
|
append_to: this.$svg
|
|
1352
1485
|
});
|
|
1353
|
-
this
|
|
1486
|
+
this.options.allow_dependency_creation && (this.layers.linking = $("g", {
|
|
1487
|
+
class: "linking",
|
|
1488
|
+
append_to: this.$svg
|
|
1489
|
+
})), this.$extras = this.create_el({
|
|
1354
1490
|
classes: "extras",
|
|
1355
1491
|
append_to: this.$container
|
|
1356
1492
|
}), this.$adjust = this.create_el({
|
|
@@ -1370,23 +1506,23 @@ class tt {
|
|
|
1370
1506
|
this.config.header_height + this.options.padding + (this.options.bar_height + this.options.padding) * this.tasks.length - 10,
|
|
1371
1507
|
this.options.container_height !== "auto" ? this.options.container_height : 0
|
|
1372
1508
|
);
|
|
1373
|
-
|
|
1509
|
+
$("rect", {
|
|
1374
1510
|
x: 0,
|
|
1375
1511
|
y: 0,
|
|
1376
1512
|
width: t,
|
|
1377
1513
|
height: e,
|
|
1378
1514
|
class: "grid-background",
|
|
1379
1515
|
append_to: this.$svg
|
|
1380
|
-
}),
|
|
1516
|
+
}), u.attr(this.$svg, {
|
|
1381
1517
|
height: e,
|
|
1382
1518
|
width: "100%"
|
|
1383
1519
|
}), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
|
|
1384
1520
|
}
|
|
1385
1521
|
make_grid_rows() {
|
|
1386
|
-
const t =
|
|
1522
|
+
const t = $("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
|
|
1387
1523
|
this.config.header_height;
|
|
1388
1524
|
for (let s = this.config.header_height; s < this.grid_height; s += i)
|
|
1389
|
-
|
|
1525
|
+
$("rect", {
|
|
1390
1526
|
x: 0,
|
|
1391
1527
|
y: s,
|
|
1392
1528
|
width: e,
|
|
@@ -1431,12 +1567,12 @@ class tt {
|
|
|
1431
1567
|
}
|
|
1432
1568
|
}
|
|
1433
1569
|
make_task_column() {
|
|
1434
|
-
var i, s, n, o,
|
|
1570
|
+
var i, s, n, a, o, d, h, _, l, p;
|
|
1435
1571
|
if ((i = this.$task_column) == null || i.remove(), !((s = this.options.task_column) != null && s.enabled)) {
|
|
1436
|
-
(
|
|
1572
|
+
(a = (n = this.$wrapper) == null ? void 0 : n.classList) == null || a.remove("has-task-column");
|
|
1437
1573
|
return;
|
|
1438
1574
|
}
|
|
1439
|
-
(
|
|
1575
|
+
(d = (o = this.$wrapper) == null ? void 0 : o.classList) == null || d.add("has-task-column"), this.$task_column = this.create_el({
|
|
1440
1576
|
classes: "task-column",
|
|
1441
1577
|
append_to: this.$wrapper
|
|
1442
1578
|
}), this.$wrapper.insertBefore(this.$task_column, this.$container), this.$task_column_header = this.create_el({
|
|
@@ -1456,47 +1592,47 @@ class tt {
|
|
|
1456
1592
|
), this.$container.style.setProperty(
|
|
1457
1593
|
"--gv-task-column-content-height",
|
|
1458
1594
|
e + "px"
|
|
1459
|
-
), this.tasks.forEach((
|
|
1460
|
-
const
|
|
1595
|
+
), this.tasks.forEach((c) => {
|
|
1596
|
+
const m = this.options.bar_height + this.options.padding, f = this.create_el({
|
|
1461
1597
|
classes: "task-row",
|
|
1462
1598
|
append_to: this.$task_column_content
|
|
1463
1599
|
});
|
|
1464
|
-
if (
|
|
1465
|
-
const
|
|
1466
|
-
typeof
|
|
1600
|
+
if (f.style.top = c._index * m - 1 + "px", f.style.height = m + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
|
|
1601
|
+
const w = this.options.task_column.content(c);
|
|
1602
|
+
typeof w == "string" ? f.innerHTML = w : w instanceof HTMLElement && f.appendChild(w);
|
|
1467
1603
|
} else
|
|
1468
|
-
|
|
1469
|
-
|
|
1604
|
+
f.textContent = c.name, f.title = c.name;
|
|
1605
|
+
f.setAttribute("data-task-id", c.id);
|
|
1470
1606
|
}), this.$task_column.style.width = this.options.task_column.width + "px", this.$task_column_resize_handle = this.create_el({
|
|
1471
1607
|
classes: "task-column-resize-handle",
|
|
1472
1608
|
append_to: this.$task_column
|
|
1473
|
-
}), this.options.isRTL ? (_ = (
|
|
1609
|
+
}), this.options.isRTL ? (_ = (h = this.$wrapper) == null ? void 0 : h.classList) == null || _.add("rtl") : (p = (l = this.$wrapper) == null ? void 0 : l.classList) == null || p.remove("rtl");
|
|
1474
1610
|
}
|
|
1475
1611
|
make_grid_ticks() {
|
|
1476
1612
|
if (this.options.lines === "none") return;
|
|
1477
|
-
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s =
|
|
1613
|
+
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s = $("g", {
|
|
1478
1614
|
class: "lines_layer",
|
|
1479
1615
|
append_to: this.layers.grid
|
|
1480
1616
|
}), n = this.config.header_height;
|
|
1481
|
-
const
|
|
1617
|
+
const a = this.dates.length * this.config.column_width, o = this.options.bar_height + this.options.padding;
|
|
1482
1618
|
if (this.options.lines !== "vertical")
|
|
1483
|
-
for (let
|
|
1484
|
-
|
|
1619
|
+
for (let d = this.config.header_height; d < this.grid_height; d += o)
|
|
1620
|
+
$("line", {
|
|
1485
1621
|
x1: 0,
|
|
1486
|
-
y1: n +
|
|
1487
|
-
x2:
|
|
1488
|
-
y2: n +
|
|
1622
|
+
y1: n + o,
|
|
1623
|
+
x2: a,
|
|
1624
|
+
y2: n + o,
|
|
1489
1625
|
class: "row-line",
|
|
1490
1626
|
append_to: s
|
|
1491
|
-
}), n +=
|
|
1627
|
+
}), n += o;
|
|
1492
1628
|
if (this.options.lines !== "horizontal")
|
|
1493
|
-
for (let
|
|
1494
|
-
let
|
|
1495
|
-
this.config.view_mode.thick_line && this.config.view_mode.thick_line(
|
|
1629
|
+
for (let d of this.dates) {
|
|
1630
|
+
let h = "tick";
|
|
1631
|
+
this.config.view_mode.thick_line && this.config.view_mode.thick_line(d) && (h += " thick"), $("path", {
|
|
1496
1632
|
d: `M ${t} ${e} v ${i}`,
|
|
1497
|
-
class:
|
|
1633
|
+
class: h,
|
|
1498
1634
|
append_to: this.layers.grid
|
|
1499
|
-
}), this.view_is("month") ? t += g.get_days_in_month(
|
|
1635
|
+
}), this.view_is("month") ? t += g.get_days_in_month(d) * this.config.column_width / 30 : this.view_is("year") ? t += g.get_days_in_year(d) * this.config.column_width / 365 : t += this.config.column_width;
|
|
1500
1636
|
}
|
|
1501
1637
|
}
|
|
1502
1638
|
highlight_holidays() {
|
|
@@ -1507,44 +1643,44 @@ class tt {
|
|
|
1507
1643
|
i === "weekend" && (i = this.options.is_weekend);
|
|
1508
1644
|
let s;
|
|
1509
1645
|
if (typeof i == "object") {
|
|
1510
|
-
let n = i.find((
|
|
1646
|
+
let n = i.find((a) => typeof a == "function");
|
|
1511
1647
|
if (n && (s = n), this.options.holidays.name) {
|
|
1512
|
-
let
|
|
1513
|
-
i = (
|
|
1648
|
+
let a = /* @__PURE__ */ new Date(i.date + " ");
|
|
1649
|
+
i = (o) => a.getTime() === o.getTime(), t[a] = i.name;
|
|
1514
1650
|
} else
|
|
1515
|
-
i = (
|
|
1516
|
-
if (
|
|
1517
|
-
let
|
|
1518
|
-
return t[
|
|
1651
|
+
i = (a) => this.options.holidays[e].filter((o) => typeof o != "function").map((o) => {
|
|
1652
|
+
if (o.name) {
|
|
1653
|
+
let d = /* @__PURE__ */ new Date(o.date + " ");
|
|
1654
|
+
return t[d] = o.name, d.getTime();
|
|
1519
1655
|
}
|
|
1520
|
-
return (/* @__PURE__ */ new Date(
|
|
1521
|
-
}).includes(
|
|
1656
|
+
return (/* @__PURE__ */ new Date(o + " ")).getTime();
|
|
1657
|
+
}).includes(a.getTime());
|
|
1522
1658
|
}
|
|
1523
1659
|
for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
|
|
1524
1660
|
if (!(this.config.ignored_dates.find(
|
|
1525
|
-
(
|
|
1661
|
+
(a) => a.getTime() == n.getTime()
|
|
1526
1662
|
) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
|
|
1527
|
-
const
|
|
1663
|
+
const a = g.diff(
|
|
1528
1664
|
n,
|
|
1529
1665
|
this.gantt_start,
|
|
1530
1666
|
this.config.unit
|
|
1531
|
-
) / this.config.step * this.config.column_width,
|
|
1667
|
+
) / this.config.step * this.config.column_width, o = this.grid_height - this.config.header_height, d = g.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
|
|
1532
1668
|
if (t[n]) {
|
|
1533
|
-
let
|
|
1534
|
-
classes: "holiday-label label_" +
|
|
1669
|
+
let h = this.create_el({
|
|
1670
|
+
classes: "holiday-label label_" + d,
|
|
1535
1671
|
append_to: this.$extras
|
|
1536
1672
|
});
|
|
1537
|
-
|
|
1673
|
+
h.textContent = t[n];
|
|
1538
1674
|
}
|
|
1539
|
-
|
|
1540
|
-
x: Math.round(
|
|
1675
|
+
$("rect", {
|
|
1676
|
+
x: Math.round(a),
|
|
1541
1677
|
y: this.config.header_height,
|
|
1542
1678
|
width: this.config.column_width / g.convert_scales(
|
|
1543
1679
|
this.config.view_mode.step,
|
|
1544
1680
|
"day"
|
|
1545
1681
|
),
|
|
1546
|
-
height:
|
|
1547
|
-
class: "holiday-highlight " +
|
|
1682
|
+
height: o,
|
|
1683
|
+
class: "holiday-highlight " + d,
|
|
1548
1684
|
style: `fill: ${e};`,
|
|
1549
1685
|
append_to: this.layers.grid
|
|
1550
1686
|
});
|
|
@@ -1599,7 +1735,7 @@ class tt {
|
|
|
1599
1735
|
g.diff(i, this.gantt_start) + "d",
|
|
1600
1736
|
this.config.unit
|
|
1601
1737
|
) / this.config.step;
|
|
1602
|
-
this.config.ignored_positions.push(s * this.config.column_width),
|
|
1738
|
+
this.config.ignored_positions.push(s * this.config.column_width), $("rect", {
|
|
1603
1739
|
x: s * this.config.column_width,
|
|
1604
1740
|
y: this.config.header_height,
|
|
1605
1741
|
width: this.config.column_width,
|
|
@@ -1613,10 +1749,10 @@ class tt {
|
|
|
1613
1749
|
this.config.view_mode
|
|
1614
1750
|
);
|
|
1615
1751
|
}
|
|
1616
|
-
create_el({ left: t, top: e, width: i, height: s, id: n, classes:
|
|
1617
|
-
let
|
|
1618
|
-
for (let _ of
|
|
1619
|
-
return
|
|
1752
|
+
create_el({ left: t, top: e, width: i, height: s, id: n, classes: a, append_to: o, type: d }) {
|
|
1753
|
+
let h = document.createElement(d || "div");
|
|
1754
|
+
for (let _ of a.split(" ")) h.classList.add(_);
|
|
1755
|
+
return h.style.top = e + "px", h.style.left = t + "px", n && (h.id = n), i && (h.style.width = i + "px"), s && (h.style.height = s + "px"), o && o.appendChild(h), h;
|
|
1620
1756
|
}
|
|
1621
1757
|
make_dates() {
|
|
1622
1758
|
this.get_dates_to_draw().forEach((t, e) => {
|
|
@@ -1653,8 +1789,8 @@ class tt {
|
|
|
1653
1789
|
let i = e ? e.date : null;
|
|
1654
1790
|
this.config.column_width;
|
|
1655
1791
|
const s = e ? e.x + e.column_width : 0;
|
|
1656
|
-
let n = this.config.view_mode.upper_text,
|
|
1657
|
-
return n ? typeof n == "string" && (this.config.view_mode.upper_text = (
|
|
1792
|
+
let n = this.config.view_mode.upper_text, a = this.config.view_mode.lower_text;
|
|
1793
|
+
return n ? typeof n == "string" && (this.config.view_mode.upper_text = (o) => g.format(o, n, this.options.language)) : this.config.view_mode.upper_text = () => "", a ? typeof a == "string" && (this.config.view_mode.lower_text = (o) => g.format(o, a, this.options.language)) : this.config.view_mode.lower_text = () => "", {
|
|
1658
1794
|
date: t,
|
|
1659
1795
|
formatted_date: D(
|
|
1660
1796
|
g.format(
|
|
@@ -1683,26 +1819,26 @@ class tt {
|
|
|
1683
1819
|
this.bars = this.tasks.map((t) => {
|
|
1684
1820
|
if (t._has_no_dates)
|
|
1685
1821
|
return null;
|
|
1686
|
-
const e = new
|
|
1822
|
+
const e = new K(this, t);
|
|
1687
1823
|
return this.layers.bar.appendChild(e.group), e;
|
|
1688
1824
|
}).filter((t) => t !== null);
|
|
1689
1825
|
}
|
|
1690
1826
|
make_arrows() {
|
|
1691
|
-
this.arrows = [], this.options.critical_path && this.calculate_critical_path();
|
|
1827
|
+
this.arrows = [], this.active_arrow = null, this.options.critical_path && this.calculate_critical_path();
|
|
1692
1828
|
for (let t of this.tasks) {
|
|
1693
1829
|
let e = [];
|
|
1694
1830
|
e = t.dependencies.map((i) => {
|
|
1695
1831
|
const s = this.get_task(i.id);
|
|
1696
1832
|
if (!s) return;
|
|
1697
|
-
const n = this.bars[s._index],
|
|
1698
|
-
if (!n || !
|
|
1699
|
-
const
|
|
1833
|
+
const n = this.bars[s._index], a = this.bars[t._index];
|
|
1834
|
+
if (!n || !a) return;
|
|
1835
|
+
const o = i.type || this.options.dependencies_type || "finish-to-start", d = new Q(
|
|
1700
1836
|
this,
|
|
1701
1837
|
n,
|
|
1702
|
-
|
|
1703
|
-
|
|
1838
|
+
a,
|
|
1839
|
+
o
|
|
1704
1840
|
);
|
|
1705
|
-
return this.layers.arrow.appendChild(
|
|
1841
|
+
return this.layers.arrow.appendChild(d.element), this.layers.arrow.appendChild(d.hit_element), d;
|
|
1706
1842
|
}).filter(Boolean), this.arrows = this.arrows.concat(e);
|
|
1707
1843
|
}
|
|
1708
1844
|
}
|
|
@@ -1714,35 +1850,35 @@ class tt {
|
|
|
1714
1850
|
});
|
|
1715
1851
|
const e = (n) => {
|
|
1716
1852
|
if (t[n.id].ef > 0) return t[n.id];
|
|
1717
|
-
let
|
|
1718
|
-
n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((
|
|
1719
|
-
const
|
|
1720
|
-
if (
|
|
1721
|
-
const _ = e(
|
|
1722
|
-
|
|
1853
|
+
let a = 0;
|
|
1854
|
+
n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((d) => {
|
|
1855
|
+
const h = this.get_task(d.id);
|
|
1856
|
+
if (h) {
|
|
1857
|
+
const _ = e(h);
|
|
1858
|
+
a = Math.max(a, _.ef);
|
|
1723
1859
|
}
|
|
1724
|
-
}), t[n.id].es =
|
|
1725
|
-
const
|
|
1726
|
-
return t[n.id].ef =
|
|
1860
|
+
}), t[n.id].es = a;
|
|
1861
|
+
const o = g.diff(n._end, n._start, "hour") / 24;
|
|
1862
|
+
return t[n.id].ef = a + o, t[n.id];
|
|
1727
1863
|
};
|
|
1728
1864
|
this.tasks.forEach((n) => e(n));
|
|
1729
1865
|
const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
|
|
1730
1866
|
if (t[n.id].ls > 0 || t[n.id].lf > 0)
|
|
1731
1867
|
return t[n.id];
|
|
1732
|
-
const
|
|
1733
|
-
(
|
|
1868
|
+
const a = this.tasks.filter(
|
|
1869
|
+
(h) => h.dependencies && h.dependencies.some((_) => _.id === n.id)
|
|
1734
1870
|
);
|
|
1735
|
-
let
|
|
1736
|
-
|
|
1737
|
-
const _ = s(
|
|
1738
|
-
|
|
1871
|
+
let o = i;
|
|
1872
|
+
a.length > 0 && a.forEach((h) => {
|
|
1873
|
+
const _ = s(h);
|
|
1874
|
+
o = Math.min(o, _.ls);
|
|
1739
1875
|
});
|
|
1740
|
-
const
|
|
1741
|
-
return t[n.id].lf =
|
|
1876
|
+
const d = g.diff(n._end, n._start, "hour") / 24;
|
|
1877
|
+
return t[n.id].lf = o, t[n.id].ls = o - d, t[n.id];
|
|
1742
1878
|
};
|
|
1743
1879
|
this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
|
|
1744
|
-
const
|
|
1745
|
-
n._is_critical = Math.abs(
|
|
1880
|
+
const a = t[n.id], o = a.ls - a.es;
|
|
1881
|
+
n._is_critical = Math.abs(o) < 0.01;
|
|
1746
1882
|
});
|
|
1747
1883
|
}
|
|
1748
1884
|
update_arrow_critical_path() {
|
|
@@ -1760,8 +1896,8 @@ class tt {
|
|
|
1760
1896
|
}
|
|
1761
1897
|
set_scroll_position(t) {
|
|
1762
1898
|
if (this.options.infinite_padding && (!t || t === "start")) {
|
|
1763
|
-
let [
|
|
1764
|
-
this.$container.scrollLeft =
|
|
1899
|
+
let [a, ...o] = this.get_start_end_positions();
|
|
1900
|
+
this.$container.scrollLeft = a;
|
|
1765
1901
|
return;
|
|
1766
1902
|
}
|
|
1767
1903
|
if (!t || t === "start")
|
|
@@ -1791,7 +1927,7 @@ class tt {
|
|
|
1791
1927
|
null,
|
|
1792
1928
|
this.options.language
|
|
1793
1929
|
), n = this.upperTexts.find(
|
|
1794
|
-
(
|
|
1930
|
+
(a) => a.textContent === s
|
|
1795
1931
|
);
|
|
1796
1932
|
this.current_date = g.add(
|
|
1797
1933
|
this.gantt_start,
|
|
@@ -1801,7 +1937,7 @@ class tt {
|
|
|
1801
1937
|
this.current_date,
|
|
1802
1938
|
null,
|
|
1803
1939
|
this.options.language
|
|
1804
|
-
), n = this.upperTexts.find((
|
|
1940
|
+
), n = this.upperTexts.find((a) => a.textContent === s), n.classList.add("current-upper"), this.$current = n;
|
|
1805
1941
|
}
|
|
1806
1942
|
scroll_current() {
|
|
1807
1943
|
let t = this.get_closest_date();
|
|
@@ -1841,29 +1977,32 @@ class tt {
|
|
|
1841
1977
|
];
|
|
1842
1978
|
}
|
|
1843
1979
|
bind_grid_click() {
|
|
1844
|
-
|
|
1980
|
+
u.on(
|
|
1845
1981
|
this.$container,
|
|
1846
1982
|
"click",
|
|
1847
1983
|
".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
|
|
1848
1984
|
(t, e) => {
|
|
1849
|
-
if (e && e.classList.contains("grid-row")) {
|
|
1985
|
+
if (e && (e.classList.contains("grid-row") || e.classList.contains("ignored-bar") || e.classList.contains("holiday-highlight"))) {
|
|
1850
1986
|
const i = this.$svg, s = i.createSVGPoint();
|
|
1851
1987
|
s.x = t.clientX, s.y = t.clientY;
|
|
1852
|
-
const n = s.matrixTransform(i.getScreenCTM().inverse()),
|
|
1853
|
-
if (
|
|
1854
|
-
const
|
|
1988
|
+
const n = s.matrixTransform(i.getScreenCTM().inverse()), a = this.options.bar_height + this.options.padding, o = Math.floor((n.y - this.config.header_height) / a), d = this.tasks[o];
|
|
1989
|
+
if (d && d._has_no_dates) {
|
|
1990
|
+
const h = n.x / this.config.column_width, _ = Math.floor(h * this.config.step), l = g.add(
|
|
1855
1991
|
this.gantt_start,
|
|
1856
1992
|
_,
|
|
1857
1993
|
this.config.unit
|
|
1858
1994
|
);
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1995
|
+
if (this.config.ignored_function)
|
|
1996
|
+
for (; this.config.ignored_function(l); )
|
|
1997
|
+
l = g.add(l, 1, "day");
|
|
1998
|
+
d._start = l, d._end = g.add(l, 1, "day"), d.start = l, d.end = d._end, delete d._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
|
|
1999
|
+
d,
|
|
2000
|
+
d._start,
|
|
2001
|
+
d._end
|
|
1863
2002
|
]), this.trigger_event("after_date_change", [
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
2003
|
+
d,
|
|
2004
|
+
d._start,
|
|
2005
|
+
d._end
|
|
1867
2006
|
]);
|
|
1868
2007
|
return;
|
|
1869
2008
|
}
|
|
@@ -1892,146 +2031,147 @@ class tt {
|
|
|
1892
2031
|
get_start_end_positions() {
|
|
1893
2032
|
if (!this.bars.length) return [0, 0, 0];
|
|
1894
2033
|
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
|
|
1895
|
-
return Array.prototype.forEach.call(this.bars, function({ group:
|
|
1896
|
-
let { x:
|
|
1897
|
-
|
|
2034
|
+
return Array.prototype.forEach.call(this.bars, function({ group: a }, o) {
|
|
2035
|
+
let { x: d, width: h } = a.getBBox();
|
|
2036
|
+
d < i && (i = d), d > s && (s = d), d + h > n && (n = d + h);
|
|
1898
2037
|
}), [i, s, n];
|
|
1899
2038
|
}
|
|
1900
2039
|
bind_bar_events() {
|
|
1901
|
-
let t = !1, e = 0, i = 0, s = !1, n = !1,
|
|
1902
|
-
this.bar_being_dragged = null;
|
|
1903
|
-
const
|
|
2040
|
+
let t = !1, e = 0, i = 0, s = !1, n = !1, a = null, o = [];
|
|
2041
|
+
this.bar_being_dragged = null, this.active_arrow = null;
|
|
2042
|
+
const d = () => t || s || n;
|
|
1904
2043
|
this.$svg.onclick = (_) => {
|
|
1905
2044
|
_.target.classList.contains("grid-row") && this.unselect_all();
|
|
1906
|
-
};
|
|
1907
|
-
let
|
|
1908
|
-
if (
|
|
1909
|
-
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) -
|
|
1910
|
-
}),
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
2045
|
+
}, this._document_click_handler || (this._document_click_handler = () => this.set_active_arrow(null), document.addEventListener("click", this._document_click_handler));
|
|
2046
|
+
let h = 0;
|
|
2047
|
+
if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
|
|
2048
|
+
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - h) > 10 && (this.bar_being_dragged = !0);
|
|
2049
|
+
}), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, l) => {
|
|
2050
|
+
if (_.target.classList.contains("connector-circle")) return;
|
|
2051
|
+
const p = u.closest(".bar-wrapper", l);
|
|
2052
|
+
l.classList.contains("left") ? (s = !0, l.classList.add("visible")) : l.classList.contains("right") ? (n = !0, l.classList.add("visible")) : l.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, a = p.getAttribute("data-id"), o = [this.get_bar(a)], this.bar_being_dragged = !1, h = e, o.forEach((c) => {
|
|
2053
|
+
const m = c.$bar;
|
|
2054
|
+
m.ox = m.getX(), m.oy = m.getY(), m.owidth = m.getWidth(), m.finaldx = 0;
|
|
1915
2055
|
});
|
|
1916
2056
|
}), this.options.infinite_padding) {
|
|
1917
2057
|
let _ = !1;
|
|
1918
|
-
|
|
2058
|
+
u.on(this.$container, "mousewheel", (l) => {
|
|
1919
2059
|
let p = this.$container.scrollWidth / 2;
|
|
1920
|
-
if (!_ &&
|
|
1921
|
-
let
|
|
2060
|
+
if (!_ && l.currentTarget.scrollLeft <= p) {
|
|
2061
|
+
let c = l.currentTarget.scrollLeft;
|
|
1922
2062
|
_ = !0, this.gantt_start = g.add(
|
|
1923
2063
|
this.gantt_start,
|
|
1924
2064
|
-this.config.extend_by_units,
|
|
1925
2065
|
this.config.unit
|
|
1926
|
-
), this.setup_date_values(), this.render(),
|
|
2066
|
+
), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
|
|
1927
2067
|
}
|
|
1928
|
-
if (!_ &&
|
|
1929
|
-
let
|
|
2068
|
+
if (!_ && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= p) {
|
|
2069
|
+
let c = l.currentTarget.scrollLeft;
|
|
1930
2070
|
_ = !0, this.gantt_end = g.add(
|
|
1931
2071
|
this.gantt_end,
|
|
1932
2072
|
this.config.extend_by_units,
|
|
1933
2073
|
this.config.unit
|
|
1934
|
-
), this.setup_date_values(), this.render(),
|
|
2074
|
+
), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c, setTimeout(() => _ = !1, 300);
|
|
1935
2075
|
}
|
|
1936
2076
|
});
|
|
1937
2077
|
}
|
|
1938
|
-
|
|
2078
|
+
u.on(this.$container, "scroll", (_) => {
|
|
1939
2079
|
this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = _.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
1940
2080
|
this._syncing_scroll = !1;
|
|
1941
2081
|
}));
|
|
1942
|
-
let
|
|
2082
|
+
let l = [];
|
|
1943
2083
|
const p = this.bars.map(
|
|
1944
|
-
({ group:
|
|
2084
|
+
({ group: b }) => b.getAttribute("data-id")
|
|
1945
2085
|
);
|
|
1946
|
-
let
|
|
1947
|
-
i && (
|
|
2086
|
+
let c;
|
|
2087
|
+
i && (c = _.currentTarget.scrollLeft - i), this.current_date = g.add(
|
|
1948
2088
|
this.gantt_start,
|
|
1949
2089
|
_.currentTarget.scrollLeft / this.config.column_width * this.config.step,
|
|
1950
2090
|
this.config.unit
|
|
1951
2091
|
);
|
|
1952
|
-
let
|
|
2092
|
+
let m = this.config.view_mode.upper_text(
|
|
1953
2093
|
this.current_date,
|
|
1954
2094
|
null,
|
|
1955
2095
|
this.options.language
|
|
1956
|
-
),
|
|
1957
|
-
(
|
|
2096
|
+
), f = this.upperTexts.find(
|
|
2097
|
+
(b) => b.textContent === m
|
|
1958
2098
|
);
|
|
1959
2099
|
this.current_date = g.add(
|
|
1960
2100
|
this.gantt_start,
|
|
1961
|
-
(_.currentTarget.scrollLeft +
|
|
2101
|
+
(_.currentTarget.scrollLeft + f.clientWidth) / this.config.column_width * this.config.step,
|
|
1962
2102
|
this.config.unit
|
|
1963
|
-
),
|
|
2103
|
+
), m = this.config.view_mode.upper_text(
|
|
1964
2104
|
this.current_date,
|
|
1965
2105
|
null,
|
|
1966
2106
|
this.options.language
|
|
1967
|
-
),
|
|
1968
|
-
(
|
|
1969
|
-
),
|
|
1970
|
-
let [
|
|
1971
|
-
i >
|
|
2107
|
+
), f = this.upperTexts.find(
|
|
2108
|
+
(b) => b.textContent === m
|
|
2109
|
+
), f !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), f.classList.add("current-upper"), this.$current = f), i = _.currentTarget.scrollLeft;
|
|
2110
|
+
let [w, y, x] = this.get_start_end_positions();
|
|
2111
|
+
i > x + 100 ? (this.$adjust.innerHTML = "←", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1972
2112
|
this.$container.scrollTo({
|
|
1973
2113
|
left: y,
|
|
1974
2114
|
behavior: "smooth"
|
|
1975
2115
|
});
|
|
1976
|
-
}) : i + _.currentTarget.offsetWidth <
|
|
2116
|
+
}) : i + _.currentTarget.offsetWidth < w - 100 ? (this.$adjust.innerHTML = "→", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1977
2117
|
this.$container.scrollTo({
|
|
1978
|
-
left:
|
|
2118
|
+
left: w,
|
|
1979
2119
|
behavior: "smooth"
|
|
1980
2120
|
});
|
|
1981
|
-
}) : this.$adjust.classList.add("hide"),
|
|
1982
|
-
|
|
1983
|
-
x:
|
|
2121
|
+
}) : this.$adjust.classList.add("hide"), c && (l = p.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
|
|
2122
|
+
b.update_label_position_on_horizontal_scroll({
|
|
2123
|
+
x: c,
|
|
1984
2124
|
sx: _.currentTarget.scrollLeft
|
|
1985
2125
|
});
|
|
1986
2126
|
}));
|
|
1987
|
-
}),
|
|
1988
|
-
if (!
|
|
1989
|
-
const
|
|
1990
|
-
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
x:
|
|
1994
|
-
width:
|
|
2127
|
+
}), u.on(this.$svg, "mousemove", (_) => {
|
|
2128
|
+
if (!d()) return;
|
|
2129
|
+
const l = (_.offsetX || _.layerX) - e;
|
|
2130
|
+
o.forEach((p) => {
|
|
2131
|
+
const c = p.$bar;
|
|
2132
|
+
c.finaldx = this.get_snap_position(l, c.ox), this.hide_popup(), s ? a === p.task.id ? p.update_bar_position({
|
|
2133
|
+
x: c.ox + c.finaldx,
|
|
2134
|
+
width: c.owidth - c.finaldx
|
|
1995
2135
|
}) : p.update_bar_position({
|
|
1996
|
-
x:
|
|
1997
|
-
}) : n ?
|
|
1998
|
-
width:
|
|
1999
|
-
}) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x:
|
|
2136
|
+
x: c.ox + c.finaldx
|
|
2137
|
+
}) : n ? a === p.task.id && p.update_bar_position({
|
|
2138
|
+
width: c.owidth + c.finaldx
|
|
2139
|
+
}) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: c.ox + c.finaldx });
|
|
2000
2140
|
});
|
|
2001
2141
|
}), document.addEventListener("mouseup", () => {
|
|
2002
|
-
var p,
|
|
2142
|
+
var p, c, m;
|
|
2003
2143
|
const _ = this.bar_being_dragged === !0;
|
|
2004
2144
|
this.bar_being_dragged = null;
|
|
2005
|
-
const
|
|
2006
|
-
if (
|
|
2007
|
-
if (!
|
|
2008
|
-
_ &&
|
|
2145
|
+
const l = [];
|
|
2146
|
+
if (o.forEach((f) => {
|
|
2147
|
+
if (!f.$bar.finaldx) {
|
|
2148
|
+
_ && f.set_action_completed();
|
|
2009
2149
|
return;
|
|
2010
2150
|
}
|
|
2011
|
-
|
|
2012
|
-
task:
|
|
2013
|
-
start:
|
|
2014
|
-
end: g.add(
|
|
2151
|
+
f.date_changed(), f.compute_progress(), f.set_action_completed(), l.push({
|
|
2152
|
+
task: f.task,
|
|
2153
|
+
start: f.task._start,
|
|
2154
|
+
end: g.add(f.task._end, -1, "second")
|
|
2015
2155
|
});
|
|
2016
|
-
}), this.options.critical_path &&
|
|
2017
|
-
const
|
|
2018
|
-
let
|
|
2019
|
-
s ?
|
|
2020
|
-
if (
|
|
2021
|
-
const
|
|
2022
|
-
if (!
|
|
2023
|
-
const
|
|
2156
|
+
}), this.options.critical_path && o.some((f) => f.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && this.options.dependency_shifting !== "none") {
|
|
2157
|
+
const f = this.options.dependency_shifting;
|
|
2158
|
+
let w;
|
|
2159
|
+
s ? w = f === "maintain_buffer_downstream" ? "none" : "upstream" : n ? w = "downstream" : w = f === "maintain_buffer_downstream" ? "downstream" : "both", l.forEach(({ task: y }) => {
|
|
2160
|
+
if (w === "none") return;
|
|
2161
|
+
const x = o.find((T) => T.task.id === y.id);
|
|
2162
|
+
if (!x || !x.$bar.finaldx) return;
|
|
2163
|
+
const b = x.$bar.finaldx / this.config.column_width, V = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, P = b * this.config.step * V;
|
|
2024
2164
|
I(
|
|
2025
2165
|
this.tasks,
|
|
2026
2166
|
y.id,
|
|
2027
|
-
|
|
2167
|
+
P,
|
|
2028
2168
|
this.options.dependency_shifting,
|
|
2029
|
-
|
|
2169
|
+
w
|
|
2030
2170
|
).forEach((T, N) => {
|
|
2031
2171
|
const v = this.get_bar(N);
|
|
2032
2172
|
if (!v) return;
|
|
2033
|
-
const M = v.task,
|
|
2034
|
-
v.update_bar_position({ x:
|
|
2173
|
+
const M = v.task, O = new Date(M._start.getTime() + T), j = g.diff(O, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
|
|
2174
|
+
v.update_bar_position({ x: j }), v.update_arrow_position(), this.trigger_event("after_date_change", [
|
|
2035
2175
|
M,
|
|
2036
2176
|
M._start,
|
|
2037
2177
|
g.add(M._end, -1, "second")
|
|
@@ -2039,37 +2179,37 @@ class tt {
|
|
|
2039
2179
|
});
|
|
2040
2180
|
});
|
|
2041
2181
|
}
|
|
2042
|
-
|
|
2043
|
-
this.trigger_event("after_date_change", [
|
|
2044
|
-
}),
|
|
2045
|
-
|
|
2046
|
-
}), t = !1, s = !1, n = !1, (
|
|
2182
|
+
l.length > 0 && l.forEach(({ task: f, start: w, end: y }) => {
|
|
2183
|
+
this.trigger_event("after_date_change", [f, w, y]);
|
|
2184
|
+
}), o.forEach((f) => {
|
|
2185
|
+
f.$bar.finaldx = 0;
|
|
2186
|
+
}), t = !1, s = !1, n = !1, (m = (c = (p = this.$container.querySelector(".visible")) == null ? void 0 : p.classList) == null ? void 0 : c.remove) == null || m.call(c, "visible");
|
|
2047
2187
|
}), this.bind_bar_progress();
|
|
2048
2188
|
}
|
|
2049
2189
|
bind_task_column_resize() {
|
|
2050
2190
|
if (!this.$task_column_resize_handle) return;
|
|
2051
2191
|
let t = !1, e = 0, i = 0;
|
|
2052
2192
|
const s = 100, n = 600;
|
|
2053
|
-
|
|
2054
|
-
t = !0, e =
|
|
2055
|
-
}),
|
|
2193
|
+
u.on(this.$task_column_resize_handle, "mousedown", (a) => {
|
|
2194
|
+
t = !0, e = a.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), a.preventDefault();
|
|
2195
|
+
}), u.on(document, "mousemove", (a) => {
|
|
2056
2196
|
if (!t) return;
|
|
2057
|
-
let
|
|
2058
|
-
this.options.isRTL && (
|
|
2059
|
-
let
|
|
2060
|
-
|
|
2197
|
+
let o = a.clientX - e;
|
|
2198
|
+
this.options.isRTL && (o = -o);
|
|
2199
|
+
let d = i + o;
|
|
2200
|
+
d = Math.max(s, Math.min(n, d)), this.options.task_column.width = d, this.$task_column.style.width = d + "px", this.$wrapper.style.setProperty(
|
|
2061
2201
|
"--gv-task-column-width",
|
|
2062
|
-
|
|
2202
|
+
d + "px"
|
|
2063
2203
|
), this.$container.style.setProperty(
|
|
2064
2204
|
"--gv-task-column-width",
|
|
2065
|
-
|
|
2066
|
-
), this.trigger_event("task_column_resize", [
|
|
2067
|
-
}),
|
|
2205
|
+
d + "px"
|
|
2206
|
+
), this.trigger_event("task_column_resize", [d]);
|
|
2207
|
+
}), u.on(document, "mouseup", () => {
|
|
2068
2208
|
t && (t = !1, this.$task_column.classList.remove("resizing"), this.trigger_event("task_after_column_resize", [this.options.task_column.width]));
|
|
2069
2209
|
});
|
|
2070
2210
|
}
|
|
2071
2211
|
bind_task_column_scroll() {
|
|
2072
|
-
this.$task_column &&
|
|
2212
|
+
this.$task_column && u.on(this.$task_column, "scroll", (t) => {
|
|
2073
2213
|
this._syncing_scroll || (this._syncing_scroll = !0, this.$container.scrollTop = t.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
2074
2214
|
this._syncing_scroll = !1;
|
|
2075
2215
|
}));
|
|
@@ -2077,45 +2217,143 @@ class tt {
|
|
|
2077
2217
|
}
|
|
2078
2218
|
bind_bar_progress() {
|
|
2079
2219
|
let t = 0, e = null, i = null, s = null, n = null;
|
|
2080
|
-
|
|
2081
|
-
e = !0, t =
|
|
2082
|
-
const _ =
|
|
2220
|
+
u.on(this.$svg, "mousedown", ".handle.progress", (o, d) => {
|
|
2221
|
+
e = !0, t = o.offsetX || o.layerX;
|
|
2222
|
+
const _ = u.closest(".bar-wrapper", d).getAttribute("data-id");
|
|
2083
2223
|
i = this.get_bar(_), s = i.$bar_progress, n = i.$bar, s.finaldx = 0, s.owidth = s.getWidth(), s.min_dx = -s.owidth, s.max_dx = n.getWidth() - s.getWidth();
|
|
2084
2224
|
});
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
|
|
2225
|
+
const a = this.config.ignored_positions.map((o) => [
|
|
2226
|
+
o,
|
|
2227
|
+
o + this.config.column_width
|
|
2088
2228
|
]);
|
|
2089
|
-
|
|
2229
|
+
u.on(this.$svg, "mousemove", (o) => {
|
|
2090
2230
|
if (!e) return;
|
|
2091
|
-
let
|
|
2092
|
-
if (
|
|
2093
|
-
let
|
|
2094
|
-
([p,
|
|
2231
|
+
let d = o.offsetX || o.layerX;
|
|
2232
|
+
if (d > t) {
|
|
2233
|
+
let l = a.find(
|
|
2234
|
+
([p, c]) => d >= p && d < c
|
|
2095
2235
|
);
|
|
2096
|
-
for (;
|
|
2097
|
-
|
|
2098
|
-
([p,
|
|
2236
|
+
for (; l; )
|
|
2237
|
+
d = l[1], l = a.find(
|
|
2238
|
+
([p, c]) => d >= p && d < c
|
|
2099
2239
|
);
|
|
2100
2240
|
} else {
|
|
2101
|
-
let
|
|
2102
|
-
([p,
|
|
2241
|
+
let l = a.find(
|
|
2242
|
+
([p, c]) => d > p && d <= c
|
|
2103
2243
|
);
|
|
2104
|
-
for (;
|
|
2105
|
-
|
|
2106
|
-
([p,
|
|
2244
|
+
for (; l; )
|
|
2245
|
+
d = l[0], l = a.find(
|
|
2246
|
+
([p, c]) => d > p && d <= c
|
|
2107
2247
|
);
|
|
2108
2248
|
}
|
|
2109
|
-
let _ =
|
|
2110
|
-
|
|
2111
|
-
}),
|
|
2249
|
+
let _ = d - t;
|
|
2250
|
+
_ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), u.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
|
|
2251
|
+
}), u.on(this.$svg, "mouseup", () => {
|
|
2112
2252
|
e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
|
|
2113
2253
|
});
|
|
2114
2254
|
}
|
|
2255
|
+
bind_dependency_linking() {
|
|
2256
|
+
this.is_linking = !1, this.linking_source_bar = null, this.linking_source_endpoint = null, this.linking_temp_line = null, this.linking_snap_badge = null, u.on(this.$svg, "mousedown", ".connector-circle", (t, e) => {
|
|
2257
|
+
const i = u.closest(".bar-wrapper", e);
|
|
2258
|
+
if (!i) return;
|
|
2259
|
+
const s = i.getAttribute("data-id"), n = this.get_bar(s);
|
|
2260
|
+
if (!n) return;
|
|
2261
|
+
this.is_linking = !0, this.linking_source_bar = n, this.linking_source_endpoint = e.getAttribute("data-endpoint");
|
|
2262
|
+
const a = parseFloat(e.getAttribute("cx")), o = parseFloat(e.getAttribute("cy"));
|
|
2263
|
+
this.linking_temp_line = $("line", {
|
|
2264
|
+
x1: a,
|
|
2265
|
+
y1: o,
|
|
2266
|
+
x2: a,
|
|
2267
|
+
y2: o,
|
|
2268
|
+
class: "linking-temp-line",
|
|
2269
|
+
append_to: this.layers.linking
|
|
2270
|
+
});
|
|
2271
|
+
}), u.on(this.$svg, "mousemove", (t) => {
|
|
2272
|
+
if (!this.is_linking || !this.linking_temp_line) return;
|
|
2273
|
+
const e = this.$svg.createSVGPoint();
|
|
2274
|
+
e.x = t.clientX, e.y = t.clientY;
|
|
2275
|
+
const i = e.matrixTransform(this.$svg.getScreenCTM().inverse());
|
|
2276
|
+
this.linking_temp_line.setAttribute("x2", i.x), this.linking_temp_line.setAttribute("y2", i.y);
|
|
2277
|
+
}), u.on(this.$svg, "mouseover", ".connector-circle", (t, e) => {
|
|
2278
|
+
if (!this.is_linking) return;
|
|
2279
|
+
const i = u.closest(".bar-wrapper", e);
|
|
2280
|
+
if (!(!i || i.getAttribute("data-id") === this.linking_source_bar.task.id) && (e.setAttribute("r", "9"), this.linking_temp_line && this.linking_temp_line.classList.add("snap"), !this.linking_snap_badge)) {
|
|
2281
|
+
const n = e.getAttribute("data-endpoint"), a = this._resolve_dependency_type(
|
|
2282
|
+
this.linking_source_endpoint,
|
|
2283
|
+
n
|
|
2284
|
+
), o = { "finish-to-start": "FS", "start-to-start": "SS", "finish-to-finish": "FF", "start-to-finish": "SF" }[a] || "FS", d = parseFloat(e.getAttribute("cx")), h = parseFloat(e.getAttribute("cy"));
|
|
2285
|
+
this.linking_snap_badge = $("text", {
|
|
2286
|
+
x: d + 12,
|
|
2287
|
+
y: h - 10,
|
|
2288
|
+
class: "linking-snap-badge",
|
|
2289
|
+
append_to: this.layers.linking
|
|
2290
|
+
}), this.linking_snap_badge.textContent = o;
|
|
2291
|
+
}
|
|
2292
|
+
}), u.on(this.$svg, "mouseout", ".connector-circle", (t, e) => {
|
|
2293
|
+
this.is_linking && (e.setAttribute("r", "4"), this.linking_temp_line && this.linking_temp_line.classList.remove("snap"), this.linking_snap_badge && (this.linking_snap_badge.remove(), this.linking_snap_badge = null));
|
|
2294
|
+
}), u.on(this.$svg, "mouseup", ".connector-circle", (t, e) => {
|
|
2295
|
+
if (!this.is_linking) return;
|
|
2296
|
+
const i = u.closest(".bar-wrapper", e);
|
|
2297
|
+
if (!i) return;
|
|
2298
|
+
const s = i.getAttribute("data-id");
|
|
2299
|
+
if (s !== this.linking_source_bar.task.id) {
|
|
2300
|
+
const n = this.get_bar(s), a = e.getAttribute("data-endpoint");
|
|
2301
|
+
n && this._commit_dependency(n, a);
|
|
2302
|
+
}
|
|
2303
|
+
}), document.addEventListener("mouseup", () => {
|
|
2304
|
+
this.is_linking && this._cancel_linking();
|
|
2305
|
+
}), document.addEventListener("keydown", (t) => {
|
|
2306
|
+
if ((t.key === "Delete" || t.key === "Backspace") && this.active_arrow) {
|
|
2307
|
+
const e = t.target.tagName;
|
|
2308
|
+
if (e === "INPUT" || e === "TEXTAREA" || t.target.isContentEditable) return;
|
|
2309
|
+
t.preventDefault(), this.delete_dependency(this.active_arrow);
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
_resolve_dependency_type(t, e) {
|
|
2314
|
+
return t === "end" && e === "start" ? "finish-to-start" : t === "start" && e === "start" ? "start-to-start" : t === "end" && e === "end" ? "finish-to-finish" : t === "start" && e === "end" ? "start-to-finish" : "finish-to-start";
|
|
2315
|
+
}
|
|
2316
|
+
_commit_dependency(t, e) {
|
|
2317
|
+
var l;
|
|
2318
|
+
const i = this.linking_source_bar.task, s = t.task, n = this._resolve_dependency_type(
|
|
2319
|
+
this.linking_source_endpoint,
|
|
2320
|
+
e
|
|
2321
|
+
), a = s.dependencies.find((p) => p.id === i.id), o = a ? a.type || this.options.dependencies_type || "finish-to-start" : null, d = s.dependencies.filter(
|
|
2322
|
+
(p) => p.id !== i.id
|
|
2323
|
+
);
|
|
2324
|
+
if (o === n) {
|
|
2325
|
+
this.update_task(s.id, { dependencies: d }), this.options.on_dependency_delete && this.options.on_dependency_delete(i, s, n);
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
const h = (l = i.dependencies) == null ? void 0 : l.find((p) => p.id === s.id);
|
|
2329
|
+
if (h) {
|
|
2330
|
+
const p = h.type || this.options.dependencies_type || "finish-to-start";
|
|
2331
|
+
this.update_task(i.id, {
|
|
2332
|
+
dependencies: i.dependencies.filter((c) => c.id !== s.id)
|
|
2333
|
+
}), this.options.on_dependency_delete && this.options.on_dependency_delete(s, i, p);
|
|
2334
|
+
}
|
|
2335
|
+
const _ = [...d, { id: i.id, type: n }];
|
|
2336
|
+
this.update_task(s.id, { dependencies: _ }), a ? this.options.on_dependency_changed && this.options.on_dependency_changed(
|
|
2337
|
+
i,
|
|
2338
|
+
s,
|
|
2339
|
+
o,
|
|
2340
|
+
n
|
|
2341
|
+
) : this.options.on_dependency_create && this.options.on_dependency_create(i, s, n);
|
|
2342
|
+
}
|
|
2343
|
+
_cancel_linking() {
|
|
2344
|
+
this.linking_temp_line && (this.linking_temp_line.remove(), this.linking_temp_line = null), this.linking_snap_badge && (this.linking_snap_badge.remove(), this.linking_snap_badge = null), this.$svg.querySelectorAll('.connector-circle[r="9"]').forEach((t) => t.setAttribute("r", "4")), this.is_linking = !1, this.linking_source_bar = null, this.linking_source_endpoint = null;
|
|
2345
|
+
}
|
|
2346
|
+
delete_dependency(t) {
|
|
2347
|
+
const e = t.from_task.task, i = t.to_task.task, s = t.dependency_type, n = i.dependencies.filter((a) => {
|
|
2348
|
+
const o = a.type || this.options.dependencies_type || "finish-to-start";
|
|
2349
|
+
return !(a.id === e.id && o === s);
|
|
2350
|
+
});
|
|
2351
|
+
this.set_active_arrow(null), this.update_task(i.id, { dependencies: n }), this.options.on_dependency_delete && this.options.on_dependency_delete(e, i, s);
|
|
2352
|
+
}
|
|
2115
2353
|
get_all_dependent_tasks(t) {
|
|
2116
2354
|
let e = [], i = [t];
|
|
2117
2355
|
for (; i.length; ) {
|
|
2118
|
-
const s = i.reduce((n,
|
|
2356
|
+
const s = i.reduce((n, a) => (n = n.concat(this.dependency_map[a]), n), []);
|
|
2119
2357
|
e = e.concat(s), i = s.filter((n) => !i.includes(n));
|
|
2120
2358
|
}
|
|
2121
2359
|
return e.filter(Boolean);
|
|
@@ -2124,22 +2362,25 @@ class tt {
|
|
|
2124
2362
|
let i = 1;
|
|
2125
2363
|
const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
|
|
2126
2364
|
if (s !== "unit") {
|
|
2127
|
-
const { duration: _, scale:
|
|
2128
|
-
i = g.convert_scales(this.config.view_mode.step,
|
|
2365
|
+
const { duration: _, scale: l } = g.parse_duration(s);
|
|
2366
|
+
i = g.convert_scales(this.config.view_mode.step, l) / _;
|
|
2129
2367
|
}
|
|
2130
2368
|
const n = t % (this.config.column_width / i);
|
|
2131
|
-
let
|
|
2132
|
-
const
|
|
2133
|
-
let
|
|
2134
|
-
for (;
|
|
2135
|
-
|
|
2136
|
-
return
|
|
2369
|
+
let a = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), o = e + a;
|
|
2370
|
+
const d = a > 0 ? 1 : -1;
|
|
2371
|
+
let h = this.get_ignored_region(o, d);
|
|
2372
|
+
for (; h.length; )
|
|
2373
|
+
o += this.config.column_width * d, h = this.get_ignored_region(o, d), h.length || (o -= this.config.column_width * d);
|
|
2374
|
+
return o - e;
|
|
2137
2375
|
}
|
|
2138
2376
|
get_ignored_region(t, e = 1) {
|
|
2139
2377
|
return e === 1 ? this.config.ignored_positions.filter((i) => t > i && t <= i + this.config.column_width) : this.config.ignored_positions.filter(
|
|
2140
2378
|
(i) => t >= i && t < i + this.config.column_width
|
|
2141
2379
|
);
|
|
2142
2380
|
}
|
|
2381
|
+
set_active_arrow(t) {
|
|
2382
|
+
this.active_arrow !== t && (this.active_arrow && this.active_arrow.deactivate(), this.active_arrow = t, t && (t.activate(), this.options.on_arrow_click && this.options.on_arrow_click(t.from_task.task, t.to_task.task)));
|
|
2383
|
+
}
|
|
2143
2384
|
unselect_all() {
|
|
2144
2385
|
this.popup && this.popup.parent.classList.add("hide"), this.$container.querySelectorAll(".date-range-highlight").forEach((t) => t.classList.add("hide"));
|
|
2145
2386
|
}
|
|
@@ -2153,7 +2394,7 @@ class tt {
|
|
|
2153
2394
|
return this.bars.find((e) => e.task.id === t);
|
|
2154
2395
|
}
|
|
2155
2396
|
show_popup(t) {
|
|
2156
|
-
this.options.popup !== !1 && (this.popup || (this.popup = new
|
|
2397
|
+
this.options.popup !== !1 && (this.popup || (this.popup = new J(
|
|
2157
2398
|
this.$popup_wrapper,
|
|
2158
2399
|
this.options.popup,
|
|
2159
2400
|
this
|
|
@@ -2182,18 +2423,18 @@ class tt {
|
|
|
2182
2423
|
* @memberof Gantt
|
|
2183
2424
|
*/
|
|
2184
2425
|
clear() {
|
|
2185
|
-
var t, e, i, s, n, o,
|
|
2186
|
-
this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (s = (i = this.$side_header) == null ? void 0 : i.remove) == null || s.call(i), (
|
|
2426
|
+
var t, e, i, s, n, a, o, d, h, _, l, p, c, m, f, w;
|
|
2427
|
+
this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (s = (i = this.$side_header) == null ? void 0 : i.remove) == null || s.call(i), (a = (n = this.$task_column) == null ? void 0 : n.remove) == null || a.call(n), (d = (o = this.$current_highlight) == null ? void 0 : o.remove) == null || d.call(o), (_ = (h = this.$extras) == null ? void 0 : h.remove) == null || _.call(h), (p = (l = this.popup) == null ? void 0 : l.hide) == null || p.call(l), (m = (c = this.$wrapper) == null ? void 0 : c.classList) == null || m.remove("has-task-column"), (w = (f = this.$wrapper) == null ? void 0 : f.classList) == null || w.remove("rtl");
|
|
2187
2428
|
}
|
|
2188
2429
|
}
|
|
2189
2430
|
tt.VIEW_MODE = {
|
|
2190
|
-
HOUR:
|
|
2191
|
-
QUARTER_DAY:
|
|
2192
|
-
HALF_DAY:
|
|
2193
|
-
DAY:
|
|
2194
|
-
WEEK:
|
|
2195
|
-
MONTH:
|
|
2196
|
-
YEAR:
|
|
2431
|
+
HOUR: k[0],
|
|
2432
|
+
QUARTER_DAY: k[1],
|
|
2433
|
+
HALF_DAY: k[2],
|
|
2434
|
+
DAY: k[3],
|
|
2435
|
+
WEEK: k[4],
|
|
2436
|
+
MONTH: k[5],
|
|
2437
|
+
YEAR: k[6]
|
|
2197
2438
|
};
|
|
2198
2439
|
function et(r) {
|
|
2199
2440
|
return r.name + "_" + Math.random().toString(36).slice(2, 12);
|