@workiom/frappe-gantt 1.0.19 → 1.0.21
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 +52 -19
- package/dist/frappe-gantt.css +1 -1
- package/dist/frappe-gantt.es.js +761 -630
- package/dist/frappe-gantt.umd.js +46 -21
- package/package.json +1 -1
- package/src/arrow.js +171 -84
- package/src/bar.js +0 -70
- package/src/defaults.js +2 -2
- package/src/dependency_shifting.js +201 -0
- package/src/index.js +115 -151
- package/src/styles/dark.css +5 -0
- package/src/styles/gantt.css +13 -0
- package/src/styles/light.css +1 -0
package/dist/frappe-gantt.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second", W = "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) {
|
|
@@ -22,27 +22,27 @@ const M = "year", D = "month", L = "day", T = "hour", A = "minute", Y = "second"
|
|
|
22
22
|
if (r instanceof Date)
|
|
23
23
|
return r;
|
|
24
24
|
if (typeof r == "string") {
|
|
25
|
-
let i,
|
|
26
|
-
const
|
|
27
|
-
i =
|
|
25
|
+
let i, s;
|
|
26
|
+
const n = r.split(" ");
|
|
27
|
+
i = n[0].split(t).map((a) => parseInt(a, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
|
|
28
28
|
let o = i;
|
|
29
|
-
return
|
|
29
|
+
return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), o = o.concat(s)), new Date(...o);
|
|
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((
|
|
36
|
-
return i + (t ? " " +
|
|
35
|
+
const e = this.get_date_values(r).map((n, o) => (o === 1 && (n = n + 1), o === 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
|
+
return i + (t ? " " + s : "");
|
|
37
37
|
},
|
|
38
38
|
format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
|
|
39
39
|
const i = new Intl.DateTimeFormat(e, {
|
|
40
40
|
month: "long"
|
|
41
|
-
}),
|
|
41
|
+
}), s = new Intl.DateTimeFormat(e, {
|
|
42
42
|
month: "short"
|
|
43
|
-
}),
|
|
43
|
+
}), n = i.format(r), o = n.charAt(0).toUpperCase() + n.slice(1), a = this.get_date_values(r).map((c) => L(c, 2, 0)), h = {
|
|
44
44
|
YYYY: a[0],
|
|
45
|
-
MM:
|
|
45
|
+
MM: L(+a[1] + 1, 2, 0),
|
|
46
46
|
DD: a[2],
|
|
47
47
|
HH: a[3],
|
|
48
48
|
mm: a[4],
|
|
@@ -50,26 +50,26 @@ const M = "year", D = "month", L = "day", T = "hour", A = "minute", Y = "second"
|
|
|
50
50
|
SSS: a[6],
|
|
51
51
|
D: a[2],
|
|
52
52
|
MMMM: o,
|
|
53
|
-
MMM:
|
|
53
|
+
MMM: s.format(r)
|
|
54
54
|
};
|
|
55
55
|
let d = t;
|
|
56
56
|
const _ = [];
|
|
57
|
-
return Object.keys(h).sort((
|
|
58
|
-
d.includes(
|
|
59
|
-
}), _.forEach((
|
|
60
|
-
d = d.replaceAll(`$${
|
|
57
|
+
return Object.keys(h).sort((c, p) => p.length - c.length).forEach((c) => {
|
|
58
|
+
d.includes(c) && (d = d.replaceAll(c, `$${_.length}`), _.push(h[c]));
|
|
59
|
+
}), _.forEach((c, p) => {
|
|
60
|
+
d = d.replaceAll(`$${p}`, c);
|
|
61
61
|
}), d;
|
|
62
62
|
},
|
|
63
63
|
diff(r, t, e = "day") {
|
|
64
|
-
let i,
|
|
65
|
-
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4,
|
|
66
|
-
let _ = r.getFullYear() - t.getFullYear(),
|
|
67
|
-
return
|
|
64
|
+
let i, s, n, o, a, h, d;
|
|
65
|
+
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, o = s / 60, n = o / 60, a = n / 24;
|
|
66
|
+
let _ = r.getFullYear() - t.getFullYear(), c = r.getMonth() - t.getMonth();
|
|
67
|
+
return c += a % 30 / 30, h = _ * 12 + c, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
|
|
68
68
|
{
|
|
69
69
|
milliseconds: i,
|
|
70
|
-
seconds:
|
|
70
|
+
seconds: s,
|
|
71
71
|
minutes: o,
|
|
72
|
-
hours:
|
|
72
|
+
hours: n,
|
|
73
73
|
days: a,
|
|
74
74
|
months: h,
|
|
75
75
|
years: d
|
|
@@ -86,40 +86,40 @@ const M = "year", D = "month", L = "day", T = "hour", A = "minute", Y = "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 ===
|
|
92
|
-
r.getHours() + (e ===
|
|
93
|
-
r.getMinutes() + (e ===
|
|
94
|
-
r.getSeconds() + (e ===
|
|
95
|
-
r.getMilliseconds() + (e ===
|
|
89
|
+
r.getFullYear() + (e === A ? t : 0),
|
|
90
|
+
r.getMonth() + (e === E ? t : 0),
|
|
91
|
+
r.getDate() + (e === Y ? t : 0),
|
|
92
|
+
r.getHours() + (e === S ? t : 0),
|
|
93
|
+
r.getMinutes() + (e === H ? t : 0),
|
|
94
|
+
r.getSeconds() + (e === X ? t : 0),
|
|
95
|
+
r.getMilliseconds() + (e === W ? 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
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
[
|
|
101
|
+
[A]: 6,
|
|
102
|
+
[E]: 5,
|
|
103
|
+
[Y]: 4,
|
|
104
|
+
[S]: 3,
|
|
105
|
+
[H]: 2,
|
|
106
|
+
[X]: 1,
|
|
107
|
+
[W]: 0
|
|
108
108
|
};
|
|
109
|
-
function i(
|
|
109
|
+
function i(n) {
|
|
110
110
|
const o = e[t];
|
|
111
|
-
return e[
|
|
111
|
+
return e[n] <= o;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const s = [
|
|
114
114
|
r.getFullYear(),
|
|
115
|
-
i(
|
|
116
|
-
i(
|
|
117
|
-
i(
|
|
118
|
-
i(
|
|
119
|
-
i(
|
|
120
|
-
i(
|
|
115
|
+
i(A) ? 0 : r.getMonth(),
|
|
116
|
+
i(E) ? 1 : r.getDate(),
|
|
117
|
+
i(Y) ? 0 : r.getHours(),
|
|
118
|
+
i(S) ? 0 : r.getMinutes(),
|
|
119
|
+
i(H) ? 0 : r.getSeconds(),
|
|
120
|
+
i(X) ? 0 : r.getMilliseconds()
|
|
121
121
|
];
|
|
122
|
-
return new Date(...
|
|
122
|
+
return new Date(...s);
|
|
123
123
|
},
|
|
124
124
|
clone(r) {
|
|
125
125
|
return new Date(...this.get_date_values(r));
|
|
@@ -144,8 +144,8 @@ const M = "year", D = "month", L = "day", T = "hour", A = "minute", Y = "second"
|
|
|
144
144
|
day: 1,
|
|
145
145
|
month: 30,
|
|
146
146
|
year: 365
|
|
147
|
-
}, { duration: i, scale:
|
|
148
|
-
return i * e[
|
|
147
|
+
}, { duration: i, scale: s } = this.parse_duration(r);
|
|
148
|
+
return i * e[s] / e[t];
|
|
149
149
|
},
|
|
150
150
|
get_days_in_month(r) {
|
|
151
151
|
const t = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], e = r.getMonth();
|
|
@@ -158,50 +158,50 @@ const M = "year", D = "month", L = "day", T = "hour", A = "minute", Y = "second"
|
|
|
158
158
|
return r.getFullYear() % 4 ? 365 : 366;
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
function
|
|
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 m(r, t) {
|
|
165
165
|
return typeof r == "string" ? (t || document).querySelector(r) : r || null;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function w(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
|
-
function
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
|
|
173
|
+
function z(r, t, e, i) {
|
|
174
|
+
const s = B(r, t, e, i);
|
|
175
|
+
if (s === r) {
|
|
176
|
+
const n = document.createEvent("HTMLEvents");
|
|
177
|
+
n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function B(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
181
181
|
const o = r.querySelector("animate");
|
|
182
182
|
if (o)
|
|
183
|
-
return
|
|
183
|
+
return m.attr(o, {
|
|
184
184
|
attributeName: t,
|
|
185
185
|
from: e,
|
|
186
186
|
to: i,
|
|
187
|
-
dur:
|
|
188
|
-
begin: "click + " +
|
|
187
|
+
dur: s,
|
|
188
|
+
begin: "click + " + n
|
|
189
189
|
// artificial click
|
|
190
190
|
}), r;
|
|
191
|
-
const a =
|
|
191
|
+
const a = w("animate", {
|
|
192
192
|
attributeName: t,
|
|
193
193
|
from: e,
|
|
194
194
|
to: i,
|
|
195
|
-
dur:
|
|
196
|
-
begin:
|
|
195
|
+
dur: s,
|
|
196
|
+
begin: n,
|
|
197
197
|
calcMode: "spline",
|
|
198
198
|
values: e + ";" + i,
|
|
199
199
|
keyTimes: "0; 1",
|
|
200
|
-
keySplines:
|
|
200
|
+
keySplines: G("ease-out")
|
|
201
201
|
});
|
|
202
202
|
return r.appendChild(a), r;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function G(r) {
|
|
205
205
|
return {
|
|
206
206
|
ease: ".25 .1 .25 1",
|
|
207
207
|
linear: "0 0 1 1",
|
|
@@ -210,46 +210,129 @@ function C(r) {
|
|
|
210
210
|
"ease-in-out": ".42 0 .58 1"
|
|
211
211
|
}[r];
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
i ?
|
|
213
|
+
m.on = (r, t, e, i) => {
|
|
214
|
+
i ? m.delegate(r, t, e, i) : (i = e, m.bind(r, t, i));
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
m.off = (r, t, e) => {
|
|
217
217
|
r.removeEventListener(t, e);
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
m.bind = (r, t, e) => {
|
|
220
220
|
t.split(/\s+/).forEach(function(i) {
|
|
221
221
|
r.addEventListener(i, e);
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
r.addEventListener(t, function(
|
|
226
|
-
const
|
|
227
|
-
|
|
224
|
+
m.delegate = (r, t, e, i) => {
|
|
225
|
+
r.addEventListener(t, function(s) {
|
|
226
|
+
const n = s.target.closest(e);
|
|
227
|
+
n && (s.delegatedTarget = n, i.call(this, s, n));
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
m.closest = (r, t) => t ? t.matches(r) ? t : m.closest(r, t.parentNode) : null;
|
|
231
|
+
m.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
|
+
m.attr(r, i, t[i]);
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
r.setAttribute(t, e);
|
|
240
240
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
function I(r, t, e, i, s = "downstream") {
|
|
242
|
+
if (i === "none" || e === 0) return /* @__PURE__ */ new Map();
|
|
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(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const h of r)
|
|
246
|
+
h._has_no_dates || (n.set(h.id, h), o.set(h.id, []), a.set(h.id, []));
|
|
247
|
+
for (const h of r)
|
|
248
|
+
if (!h._has_no_dates)
|
|
249
|
+
for (const d of h.dependencies || []) {
|
|
250
|
+
if (!n.has(d.id)) continue;
|
|
251
|
+
const _ = d.type || "finish-to-start";
|
|
252
|
+
o.get(h.id).push({ id: d.id, type: _ }), a.get(d.id).push({ id: h.id, type: _ });
|
|
253
|
+
}
|
|
254
|
+
return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e, o, a, s === "both", s === "upstream") : i === "consume_buffer" ? R(t, e, n, o, a, s) : /* @__PURE__ */ new Map();
|
|
255
|
+
}
|
|
256
|
+
function q(r, t, e, i, s, n) {
|
|
257
|
+
const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set([r]), h = [], d = (_) => {
|
|
258
|
+
for (const { id: c } of _)
|
|
259
|
+
a.has(c) || (a.add(c), h.push(c));
|
|
260
|
+
};
|
|
261
|
+
for (n && !s ? d(e.get(r) || []) : (d(i.get(r) || []), s && d(e.get(r) || [])); h.length > 0; ) {
|
|
262
|
+
const _ = h.shift();
|
|
263
|
+
o.set(_, t), n && !s ? d(e.get(_) || []) : (d(i.get(_) || []), s && d(e.get(_) || []));
|
|
264
|
+
}
|
|
265
|
+
return o;
|
|
266
|
+
}
|
|
267
|
+
function R(r, t, e, i, s, n) {
|
|
268
|
+
const o = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const [l] of e)
|
|
270
|
+
o.set(l, (i.get(l) || []).length);
|
|
271
|
+
const a = [], h = [];
|
|
272
|
+
for (const [l, f] of o)
|
|
273
|
+
f === 0 && h.push(l);
|
|
274
|
+
for (; h.length > 0; ) {
|
|
275
|
+
const l = h.shift();
|
|
276
|
+
a.push(l);
|
|
277
|
+
for (const { id: f } of s.get(l) || []) {
|
|
278
|
+
const u = o.get(f) - 1;
|
|
279
|
+
o.set(f, u), u === 0 && h.push(f);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const d = /* @__PURE__ */ new Map([[r, 0]]), _ = (l) => e.get(l)._start.getTime() + (d.get(l) || 0), c = (l) => e.get(l)._end.getTime() + (d.get(l) || 0);
|
|
283
|
+
if (n === "downstream" || n === "both")
|
|
284
|
+
for (const l of a) {
|
|
285
|
+
if (l === r) continue;
|
|
286
|
+
let f = 0;
|
|
287
|
+
for (const { id: u, type: b } of i.get(l) || []) {
|
|
288
|
+
const y = F(u, l, b, _, c);
|
|
289
|
+
y > f && (f = y);
|
|
290
|
+
}
|
|
291
|
+
f > 0 && d.set(l, (d.get(l) || 0) + f);
|
|
292
|
+
}
|
|
293
|
+
if (n === "upstream" || n === "both")
|
|
294
|
+
for (let l = a.length - 1; l >= 0; l--) {
|
|
295
|
+
const f = a[l];
|
|
296
|
+
if (f === r) continue;
|
|
297
|
+
let u = 0;
|
|
298
|
+
for (const { id: b, type: y } of s.get(f) || []) {
|
|
299
|
+
const k = F(f, b, y, _, c);
|
|
300
|
+
if (k > 0) {
|
|
301
|
+
const $ = -k;
|
|
302
|
+
$ < u && (u = $);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
u < 0 && d.set(f, (d.get(f) || 0) + u);
|
|
306
|
+
}
|
|
307
|
+
const p = /* @__PURE__ */ new Map();
|
|
308
|
+
for (const [l, f] of d)
|
|
309
|
+
l !== r && f !== 0 && p.set(l, f);
|
|
310
|
+
return p;
|
|
311
|
+
}
|
|
312
|
+
function F(r, t, e, i, s) {
|
|
313
|
+
const n = i(r), o = s(r), a = i(t), h = s(t);
|
|
314
|
+
switch (e) {
|
|
315
|
+
case "finish-to-start":
|
|
316
|
+
return o > a ? o - a : 0;
|
|
317
|
+
case "start-to-start":
|
|
318
|
+
return n > a ? n - a : 0;
|
|
319
|
+
case "finish-to-finish":
|
|
320
|
+
return o > h ? o - h : 0;
|
|
321
|
+
case "start-to-finish":
|
|
322
|
+
return n > h ? n - h : 0;
|
|
323
|
+
default:
|
|
324
|
+
return o > a ? o - a : 0;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
class U {
|
|
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();
|
|
244
330
|
}
|
|
245
331
|
check_critical_path() {
|
|
246
332
|
return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
|
|
247
333
|
}
|
|
248
334
|
check_invalid_dependency() {
|
|
249
|
-
const t = this.
|
|
250
|
-
if (t === "fixed")
|
|
251
|
-
return this.to_task.$bar.getX() < this.from_task.$bar.getX();
|
|
252
|
-
const e = this.from_task.task, i = this.to_task.task;
|
|
335
|
+
const t = this.dependency_type, e = this.from_task.task, i = this.to_task.task;
|
|
253
336
|
switch (t) {
|
|
254
337
|
case "finish-to-start":
|
|
255
338
|
return i._start < e._end;
|
|
@@ -263,61 +346,170 @@ class W {
|
|
|
263
346
|
return !1;
|
|
264
347
|
}
|
|
265
348
|
calculate_path() {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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(), o = this.from_task.$bar.getX(), a = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), h = this.to_task.$bar.getX(), d = (l) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * l.task._index + t.padding / 2, _ = d(this.from_task), c = d(this.to_task), p = (_ + c) / 2;
|
|
350
|
+
switch (this.dependency_type) {
|
|
351
|
+
case "finish-to-start":
|
|
352
|
+
this.path = this._path_finish_to_start(
|
|
353
|
+
n,
|
|
354
|
+
o,
|
|
355
|
+
a,
|
|
356
|
+
h,
|
|
357
|
+
_,
|
|
358
|
+
c,
|
|
359
|
+
p,
|
|
360
|
+
s,
|
|
361
|
+
i
|
|
362
|
+
);
|
|
363
|
+
break;
|
|
364
|
+
case "start-to-start":
|
|
365
|
+
this.path = this._path_start_to_start(
|
|
366
|
+
o,
|
|
367
|
+
h,
|
|
368
|
+
_,
|
|
369
|
+
c,
|
|
370
|
+
s,
|
|
371
|
+
i
|
|
372
|
+
);
|
|
373
|
+
break;
|
|
374
|
+
case "finish-to-finish":
|
|
375
|
+
this.path = this._path_finish_to_finish(
|
|
376
|
+
n,
|
|
377
|
+
a,
|
|
378
|
+
_,
|
|
379
|
+
c,
|
|
380
|
+
s,
|
|
381
|
+
i
|
|
382
|
+
);
|
|
383
|
+
break;
|
|
384
|
+
case "start-to-finish":
|
|
385
|
+
this.path = this._path_start_to_finish(
|
|
386
|
+
o,
|
|
387
|
+
a,
|
|
388
|
+
_,
|
|
389
|
+
c,
|
|
390
|
+
p,
|
|
391
|
+
s,
|
|
392
|
+
i
|
|
393
|
+
);
|
|
394
|
+
break;
|
|
395
|
+
default:
|
|
396
|
+
this.path = this._path_finish_to_start(
|
|
397
|
+
n,
|
|
398
|
+
o,
|
|
399
|
+
a,
|
|
400
|
+
h,
|
|
401
|
+
_,
|
|
402
|
+
c,
|
|
403
|
+
p,
|
|
404
|
+
s,
|
|
405
|
+
i
|
|
406
|
+
);
|
|
303
407
|
}
|
|
304
408
|
}
|
|
409
|
+
_path_finish_to_start(t, e, i, s, n, o, a, h, d) {
|
|
410
|
+
const _ = t + h;
|
|
411
|
+
if (_ < s)
|
|
412
|
+
return `
|
|
413
|
+
M ${t} ${n}
|
|
414
|
+
H ${_ - d}
|
|
415
|
+
a ${d} ${d} 0 0 1 ${d} ${d}
|
|
416
|
+
V ${o - d}
|
|
417
|
+
a ${d} ${d} 0 0 0 ${d} ${d}
|
|
418
|
+
H ${s}
|
|
419
|
+
m -5 -5 l 5 5 l -5 5`;
|
|
420
|
+
const c = s - h;
|
|
421
|
+
return `
|
|
422
|
+
M ${t} ${n}
|
|
423
|
+
H ${_ - d}
|
|
424
|
+
a ${d} ${d} 0 0 1 ${d} ${d}
|
|
425
|
+
V ${a - d}
|
|
426
|
+
a ${d} ${d} 0 0 1 ${-d} ${d}
|
|
427
|
+
H ${c + d}
|
|
428
|
+
a ${d} ${d} 0 0 0 ${-d} ${d}
|
|
429
|
+
V ${o - d}
|
|
430
|
+
a ${d} ${d} 0 0 0 ${d} ${d}
|
|
431
|
+
H ${s}
|
|
432
|
+
m -5 -5 l 5 5 l -5 5`;
|
|
433
|
+
}
|
|
434
|
+
_path_start_to_start(t, e, i, s, n, o) {
|
|
435
|
+
const a = Math.min(t, e) - n;
|
|
436
|
+
return `
|
|
437
|
+
M ${t} ${i}
|
|
438
|
+
H ${a + o}
|
|
439
|
+
a ${o} ${o} 0 0 0 ${-o} ${o}
|
|
440
|
+
V ${s - o}
|
|
441
|
+
a ${o} ${o} 0 0 0 ${o} ${o}
|
|
442
|
+
H ${e}
|
|
443
|
+
m -5 -5 l 5 5 l -5 5`;
|
|
444
|
+
}
|
|
445
|
+
_path_finish_to_finish(t, e, i, s, n, o) {
|
|
446
|
+
const a = Math.max(t, e) + n;
|
|
447
|
+
return `
|
|
448
|
+
M ${t} ${i}
|
|
449
|
+
H ${a - o}
|
|
450
|
+
a ${o} ${o} 0 0 1 ${o} ${o}
|
|
451
|
+
V ${s - o}
|
|
452
|
+
a ${o} ${o} 0 0 1 ${-o} ${o}
|
|
453
|
+
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 `
|
|
459
|
+
M ${t} ${i}
|
|
460
|
+
H ${h + a}
|
|
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}
|
|
465
|
+
a ${a} ${a} 0 0 1 ${a} ${a}
|
|
466
|
+
V ${s - a}
|
|
467
|
+
a ${a} ${a} 0 0 1 ${-a} ${a}
|
|
468
|
+
H ${e}
|
|
469
|
+
m 5 -5 l -5 5 l 5 5`;
|
|
470
|
+
}
|
|
471
|
+
_get_connected_bars() {
|
|
472
|
+
const t = this.from_task.task.id, e = this.to_task.task.id;
|
|
473
|
+
return Array.from(
|
|
474
|
+
this.gantt.$svg.querySelectorAll(
|
|
475
|
+
`[data-id="${CSS.escape(t)}"], [data-id="${CSS.escape(e)}"]`
|
|
476
|
+
)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
305
479
|
draw() {
|
|
306
480
|
let t = "";
|
|
307
|
-
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element =
|
|
481
|
+
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element = w("path", {
|
|
308
482
|
d: this.path,
|
|
309
483
|
"data-from": this.from_task.task.id,
|
|
310
484
|
"data-to": this.to_task.task.id,
|
|
311
485
|
class: t
|
|
486
|
+
}), this.hit_element = w("path", {
|
|
487
|
+
d: this.path,
|
|
488
|
+
stroke: "transparent",
|
|
489
|
+
"stroke-width": 15,
|
|
490
|
+
fill: "none",
|
|
491
|
+
style: "pointer-events: stroke; cursor: pointer;"
|
|
492
|
+
}), this.hit_element.addEventListener("mouseenter", () => {
|
|
493
|
+
this.is_hovered = !0, this.element.classList.add("arrow-hover");
|
|
494
|
+
const e = this.is_invalid ? "bar-arrow-invalid" : this.is_critical ? "bar-arrow-critical" : "bar-arrow-hover";
|
|
495
|
+
this._get_connected_bars().forEach((i) => {
|
|
496
|
+
const s = i.querySelector(".bar");
|
|
497
|
+
s && s.classList.add(e);
|
|
498
|
+
});
|
|
499
|
+
}), this.hit_element.addEventListener("mouseleave", () => {
|
|
500
|
+
this.is_hovered = !1, this.element.classList.remove("arrow-hover"), this._get_connected_bars().forEach((e) => {
|
|
501
|
+
const i = e.querySelector(".bar");
|
|
502
|
+
i && i.classList.remove("bar-arrow-hover", "bar-arrow-critical", "bar-arrow-invalid");
|
|
503
|
+
});
|
|
312
504
|
});
|
|
313
505
|
}
|
|
314
506
|
update() {
|
|
315
|
-
this.calculate_path(), this.element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
|
|
507
|
+
this.calculate_path(), this.element.setAttribute("d", this.path), this.hit_element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
|
|
316
508
|
let t = "";
|
|
317
|
-
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element.setAttribute("class", 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());
|
|
318
510
|
}
|
|
319
511
|
}
|
|
320
|
-
class
|
|
512
|
+
class Q {
|
|
321
513
|
constructor(t, e) {
|
|
322
514
|
this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
|
|
323
515
|
}
|
|
@@ -328,13 +520,13 @@ class q {
|
|
|
328
520
|
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;
|
|
329
521
|
}
|
|
330
522
|
prepare_wrappers() {
|
|
331
|
-
this.group =
|
|
523
|
+
this.group = w("g", {
|
|
332
524
|
class: "bar-wrapper" + (this.task.custom_class ? " " + this.task.custom_class : ""),
|
|
333
525
|
"data-id": this.task.id
|
|
334
|
-
}), this.bar_group =
|
|
526
|
+
}), this.bar_group = w("g", {
|
|
335
527
|
class: "bar-group",
|
|
336
528
|
append_to: this.group
|
|
337
|
-
}), this.handle_group =
|
|
529
|
+
}), this.handle_group = w("g", {
|
|
338
530
|
class: "handle-group",
|
|
339
531
|
append_to: this.group
|
|
340
532
|
});
|
|
@@ -362,7 +554,7 @@ class q {
|
|
|
362
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();
|
|
363
555
|
}
|
|
364
556
|
draw_bar() {
|
|
365
|
-
this.$bar =
|
|
557
|
+
this.$bar = w("rect", {
|
|
366
558
|
x: this.x,
|
|
367
559
|
y: this.y,
|
|
368
560
|
width: this.width,
|
|
@@ -371,10 +563,10 @@ class q {
|
|
|
371
563
|
ry: this.corner_radius,
|
|
372
564
|
class: "bar",
|
|
373
565
|
append_to: this.bar_group
|
|
374
|
-
}), this.task.color && (this.$bar.style.fill = this.task.color),
|
|
566
|
+
}), 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");
|
|
375
567
|
}
|
|
376
568
|
draw_expected_progress_bar() {
|
|
377
|
-
this.invalid || (this.$expected_bar_progress =
|
|
569
|
+
this.invalid || (this.$expected_bar_progress = w("rect", {
|
|
378
570
|
x: this.x,
|
|
379
571
|
y: this.y,
|
|
380
572
|
width: this.expected_progress_width,
|
|
@@ -383,7 +575,7 @@ class q {
|
|
|
383
575
|
ry: this.corner_radius,
|
|
384
576
|
class: "bar-expected-progress",
|
|
385
577
|
append_to: this.bar_group
|
|
386
|
-
}),
|
|
578
|
+
}), z(
|
|
387
579
|
this.$expected_bar_progress,
|
|
388
580
|
"width",
|
|
389
581
|
0,
|
|
@@ -394,7 +586,7 @@ class q {
|
|
|
394
586
|
if (this.invalid) return;
|
|
395
587
|
this.progress_width = this.calculate_progress_width();
|
|
396
588
|
let t = this.corner_radius;
|
|
397
|
-
/^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress =
|
|
589
|
+
/^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress = w("rect", {
|
|
398
590
|
x: this.x,
|
|
399
591
|
y: this.y,
|
|
400
592
|
width: this.progress_width,
|
|
@@ -404,7 +596,7 @@ class q {
|
|
|
404
596
|
class: "bar-progress",
|
|
405
597
|
append_to: this.bar_group
|
|
406
598
|
}), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
|
|
407
|
-
const e =
|
|
599
|
+
const e = g.diff(
|
|
408
600
|
this.task._start,
|
|
409
601
|
this.gantt.gantt_start,
|
|
410
602
|
this.gantt.config.unit
|
|
@@ -415,27 +607,27 @@ class q {
|
|
|
415
607
|
width: this.width,
|
|
416
608
|
left: e
|
|
417
609
|
});
|
|
418
|
-
this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight),
|
|
610
|
+
this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), z(this.$bar_progress, "width", 0, this.progress_width);
|
|
419
611
|
}
|
|
420
612
|
calculate_progress_width() {
|
|
421
613
|
const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < e), 0) * this.gantt.config.column_width;
|
|
422
|
-
let
|
|
423
|
-
const
|
|
424
|
-
|
|
614
|
+
let s = (t - i) * this.task.progress / 100;
|
|
615
|
+
const n = this.x + s, o = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < n), 0) * this.gantt.config.column_width;
|
|
616
|
+
s += o;
|
|
425
617
|
let a = this.gantt.get_ignored_region(
|
|
426
|
-
this.x +
|
|
618
|
+
this.x + s
|
|
427
619
|
);
|
|
428
620
|
for (; a.length; )
|
|
429
|
-
|
|
430
|
-
this.x +
|
|
621
|
+
s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
|
|
622
|
+
this.x + s
|
|
431
623
|
);
|
|
432
|
-
return this.progress_width =
|
|
624
|
+
return this.progress_width = s, s;
|
|
433
625
|
}
|
|
434
626
|
draw_label() {
|
|
435
627
|
let t = this.x + this.$bar.getWidth() / 2;
|
|
436
628
|
this.task.thumbnail && (t = this.x + this.image_size + 5);
|
|
437
629
|
const e = this.gantt.options.task_column.enabled ? "" : this.task.name;
|
|
438
|
-
this.$bar_label =
|
|
630
|
+
this.$bar_label = w("text", {
|
|
439
631
|
x: t,
|
|
440
632
|
y: this.y + this.height / 2,
|
|
441
633
|
innerHTML: e,
|
|
@@ -444,10 +636,10 @@ class q {
|
|
|
444
636
|
}), this.task.color_text && (this.$bar_label.style.fill = this.task.color_text), requestAnimationFrame(() => this.update_label_position());
|
|
445
637
|
}
|
|
446
638
|
draw_thumbnail() {
|
|
447
|
-
let t = 10, e = 2, i,
|
|
448
|
-
i =
|
|
639
|
+
let t = 10, e = 2, i, s;
|
|
640
|
+
i = w("defs", {
|
|
449
641
|
append_to: this.bar_group
|
|
450
|
-
}),
|
|
642
|
+
}), w("rect", {
|
|
451
643
|
id: "rect_" + this.task.id,
|
|
452
644
|
x: this.x + t,
|
|
453
645
|
y: this.y + e,
|
|
@@ -456,13 +648,13 @@ class q {
|
|
|
456
648
|
rx: "15",
|
|
457
649
|
class: "img_mask",
|
|
458
650
|
append_to: i
|
|
459
|
-
}),
|
|
651
|
+
}), s = w("clipPath", {
|
|
460
652
|
id: "clip_" + this.task.id,
|
|
461
653
|
append_to: i
|
|
462
|
-
}),
|
|
654
|
+
}), w("use", {
|
|
463
655
|
href: "#rect_" + this.task.id,
|
|
464
|
-
append_to:
|
|
465
|
-
}),
|
|
656
|
+
append_to: s
|
|
657
|
+
}), w("image", {
|
|
466
658
|
x: this.x + t,
|
|
467
659
|
y: this.y + e,
|
|
468
660
|
width: this.image_size,
|
|
@@ -482,39 +674,39 @@ class q {
|
|
|
482
674
|
i = this.x + this.$bar.getWidth() + 5;
|
|
483
675
|
else
|
|
484
676
|
return;
|
|
485
|
-
const
|
|
486
|
-
this.$add_icon_group =
|
|
677
|
+
const s = this.y + (this.height - 20) / 2;
|
|
678
|
+
this.$add_icon_group = w("g", {
|
|
487
679
|
class: "add-task-icon hide",
|
|
488
680
|
append_to: this.handle_group
|
|
489
|
-
}), this.$add_icon_circle =
|
|
681
|
+
}), this.$add_icon_circle = w("circle", {
|
|
490
682
|
cx: i + 20 / 2,
|
|
491
|
-
cy:
|
|
683
|
+
cy: s + 20 / 2,
|
|
492
684
|
r: 20 / 2,
|
|
493
685
|
class: "add-task-icon-bg",
|
|
494
686
|
append_to: this.$add_icon_group
|
|
495
|
-
}), this.$add_icon_vertical =
|
|
687
|
+
}), this.$add_icon_vertical = w("line", {
|
|
496
688
|
x1: i + 20 / 2,
|
|
497
|
-
y1:
|
|
689
|
+
y1: s + 5,
|
|
498
690
|
x2: i + 20 / 2,
|
|
499
|
-
y2:
|
|
691
|
+
y2: s + 20 - 5,
|
|
500
692
|
class: "add-task-icon-plus",
|
|
501
693
|
append_to: this.$add_icon_group
|
|
502
|
-
}), this.$add_icon_horizontal =
|
|
694
|
+
}), this.$add_icon_horizontal = w("line", {
|
|
503
695
|
x1: i + 5,
|
|
504
|
-
y1:
|
|
696
|
+
y1: s + 20 / 2,
|
|
505
697
|
x2: i + 20 - 5,
|
|
506
|
-
y2:
|
|
698
|
+
y2: s + 20 / 2,
|
|
507
699
|
class: "add-task-icon-plus",
|
|
508
700
|
append_to: this.$add_icon_group
|
|
509
|
-
}),
|
|
510
|
-
|
|
511
|
-
}),
|
|
512
|
-
|
|
513
|
-
}),
|
|
514
|
-
|
|
515
|
-
}),
|
|
516
|
-
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"),
|
|
517
|
-
}),
|
|
701
|
+
}), m.on(this.$add_icon_group, "mousedown", (n) => {
|
|
702
|
+
n.stopPropagation();
|
|
703
|
+
}), m.on(this.$add_icon_group, "mouseup", (n) => {
|
|
704
|
+
n.stopPropagation();
|
|
705
|
+
}), m.on(this.$add_icon_group, "click", (n) => {
|
|
706
|
+
n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
|
|
707
|
+
}), m.on(this.$add_icon_group, "mouseenter", (n) => {
|
|
708
|
+
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
|
+
}), m.on(this.$add_icon_group, "mouseleave", () => {
|
|
518
710
|
this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
|
|
519
711
|
});
|
|
520
712
|
}
|
|
@@ -522,7 +714,7 @@ class q {
|
|
|
522
714
|
if (this.invalid || this.gantt.options.readonly) return;
|
|
523
715
|
const t = this.$bar, e = 8;
|
|
524
716
|
if (this.handles = [], this.gantt.options.readonly_dates || (this.handles.push(
|
|
525
|
-
|
|
717
|
+
w("rect", {
|
|
526
718
|
x: t.getEndX() - e,
|
|
527
719
|
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
528
720
|
width: e,
|
|
@@ -533,7 +725,7 @@ class q {
|
|
|
533
725
|
append_to: this.handle_group
|
|
534
726
|
})
|
|
535
727
|
), this.handles.push(
|
|
536
|
-
|
|
728
|
+
w("rect", {
|
|
537
729
|
x: t.getX() - e,
|
|
538
730
|
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
539
731
|
width: e,
|
|
@@ -545,7 +737,7 @@ class q {
|
|
|
545
737
|
})
|
|
546
738
|
)), !this.gantt.options.readonly_progress) {
|
|
547
739
|
const i = this.$bar_progress;
|
|
548
|
-
this.$handle_progress =
|
|
740
|
+
this.$handle_progress = w("circle", {
|
|
549
741
|
cx: i.getEndX(),
|
|
550
742
|
cy: i.getY() + i.getHeight() / 2,
|
|
551
743
|
r: 4.5,
|
|
@@ -554,140 +746,102 @@ class q {
|
|
|
554
746
|
}), this.handles.push(this.$handle_progress);
|
|
555
747
|
}
|
|
556
748
|
for (let i of this.handles)
|
|
557
|
-
|
|
749
|
+
m.on(i, "mouseenter", () => i.classList.add("active")), m.on(i, "mouseleave", () => i.classList.remove("active"));
|
|
558
750
|
}
|
|
559
751
|
bind() {
|
|
560
752
|
this.invalid || this.setup_click_event();
|
|
561
753
|
}
|
|
562
754
|
unbind() {
|
|
563
755
|
this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
|
|
564
|
-
|
|
756
|
+
m.off(this.group, t, e);
|
|
565
757
|
}), this.event_listeners = []);
|
|
566
758
|
}
|
|
567
759
|
setup_click_event() {
|
|
568
760
|
this.event_listeners = [];
|
|
569
761
|
let t = this.task.id;
|
|
570
|
-
const e = (
|
|
762
|
+
const e = (p) => {
|
|
571
763
|
this.gantt.trigger_event("hover", [
|
|
572
764
|
this.task,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
765
|
+
p.screenX,
|
|
766
|
+
p.screenY,
|
|
767
|
+
p
|
|
576
768
|
]);
|
|
577
769
|
};
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
const
|
|
770
|
+
if (m.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
|
|
771
|
+
const p = (l) => {
|
|
772
|
+
const f = l.offsetX || l.layerX;
|
|
581
773
|
if (this.$handle_progress) {
|
|
582
|
-
const
|
|
583
|
-
if (
|
|
774
|
+
const u = +this.$handle_progress.getAttribute("cx");
|
|
775
|
+
if (u > f - 1 && u < f + 1 || this.gantt.bar_being_dragged) return;
|
|
584
776
|
}
|
|
585
777
|
this.gantt.show_popup({
|
|
586
|
-
x:
|
|
587
|
-
y:
|
|
778
|
+
x: l.offsetX || l.layerX,
|
|
779
|
+
y: l.offsetY || l.layerY,
|
|
588
780
|
task: this.task,
|
|
589
781
|
target: this.$bar
|
|
590
782
|
});
|
|
591
783
|
};
|
|
592
|
-
|
|
784
|
+
m.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
|
|
593
785
|
}
|
|
594
786
|
let i;
|
|
595
|
-
const
|
|
787
|
+
const s = (p) => {
|
|
596
788
|
i = setTimeout(() => {
|
|
597
789
|
this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
|
|
598
|
-
x:
|
|
599
|
-
y:
|
|
790
|
+
x: p.offsetX || p.layerX,
|
|
791
|
+
y: p.offsetY || p.layerY,
|
|
600
792
|
task: this.task,
|
|
601
793
|
target: this.$bar
|
|
602
794
|
});
|
|
603
|
-
const
|
|
604
|
-
|
|
795
|
+
const l = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
|
|
796
|
+
l && l.classList.remove("hide");
|
|
605
797
|
}, 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"));
|
|
606
798
|
};
|
|
607
|
-
|
|
608
|
-
const
|
|
609
|
-
var
|
|
610
|
-
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((
|
|
611
|
-
const
|
|
612
|
-
|
|
799
|
+
m.on(this.group, "mouseenter", s), this.event_listeners.push({ event: "mouseenter", handler: s });
|
|
800
|
+
const n = () => {
|
|
801
|
+
var l, f;
|
|
802
|
+
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((f = (l = this.gantt.popup) == null ? void 0 : l.hide) == null || f.call(l));
|
|
803
|
+
const p = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
|
|
804
|
+
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(() => {
|
|
613
805
|
this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
|
|
614
806
|
}, 200));
|
|
615
807
|
};
|
|
616
|
-
|
|
808
|
+
m.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
|
|
617
809
|
const o = () => {
|
|
618
810
|
this.is_dragging = !0, this.hide_add_icon();
|
|
619
811
|
};
|
|
620
|
-
|
|
812
|
+
m.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
|
|
621
813
|
const a = () => {
|
|
622
814
|
setTimeout(() => {
|
|
623
815
|
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"));
|
|
624
816
|
}, 0);
|
|
625
817
|
};
|
|
626
|
-
|
|
818
|
+
m.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
|
|
627
819
|
const h = () => {
|
|
628
820
|
this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
|
|
629
821
|
};
|
|
630
|
-
|
|
822
|
+
m.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
|
|
631
823
|
const d = () => {
|
|
632
824
|
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]));
|
|
633
825
|
};
|
|
634
|
-
|
|
826
|
+
m.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
|
|
635
827
|
let _ = !1;
|
|
636
|
-
const
|
|
828
|
+
const c = (p) => {
|
|
637
829
|
if (!_)
|
|
638
830
|
return _ = !0, setTimeout(function() {
|
|
639
831
|
_ = !1;
|
|
640
832
|
}, 300), !1;
|
|
641
|
-
|
|
833
|
+
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]));
|
|
642
834
|
};
|
|
643
|
-
|
|
835
|
+
m.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
|
|
644
836
|
}
|
|
645
837
|
update_bar_position({ x: t = null, width: e = null }) {
|
|
646
838
|
const i = this.$bar;
|
|
647
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();
|
|
648
840
|
}
|
|
649
|
-
validate_dependency_constraints(t, e = null) {
|
|
650
|
-
const i = this.task.dependencies_type || this.gantt.options.dependencies_type;
|
|
651
|
-
if (i === "fixed")
|
|
652
|
-
return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, l) => _ && t >= l, !0);
|
|
653
|
-
const n = t / this.gantt.config.column_width, s = c.add(
|
|
654
|
-
this.gantt.gantt_start,
|
|
655
|
-
n * this.gantt.config.step,
|
|
656
|
-
this.gantt.config.unit
|
|
657
|
-
), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = c.add(
|
|
658
|
-
s,
|
|
659
|
-
a * this.gantt.config.step,
|
|
660
|
-
this.gantt.config.unit
|
|
661
|
-
);
|
|
662
|
-
for (const d of this.task.dependencies) {
|
|
663
|
-
const _ = this.gantt.get_bar(d);
|
|
664
|
-
if (!_) continue;
|
|
665
|
-
const l = _.task;
|
|
666
|
-
switch (i) {
|
|
667
|
-
case "finish-to-start":
|
|
668
|
-
if (s < l._end)
|
|
669
|
-
return !1;
|
|
670
|
-
break;
|
|
671
|
-
case "start-to-start":
|
|
672
|
-
if (s < l._start)
|
|
673
|
-
return !1;
|
|
674
|
-
break;
|
|
675
|
-
case "finish-to-finish":
|
|
676
|
-
if (h < l._end)
|
|
677
|
-
return !1;
|
|
678
|
-
break;
|
|
679
|
-
case "start-to-finish":
|
|
680
|
-
if (h < l._start)
|
|
681
|
-
return !1;
|
|
682
|
-
break;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return !0;
|
|
686
|
-
}
|
|
687
841
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
|
688
|
-
const i = this.gantt.$container,
|
|
689
|
-
let a = this.$bar.getX() + this.$bar.getWidth(), h =
|
|
690
|
-
|
|
842
|
+
const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
|
|
843
|
+
let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, c = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
|
|
844
|
+
s.classList.contains("big") || (c < a && t > 0 && c < p || h - _ > this.$bar.getX() && t < 0 && c > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
|
|
691
845
|
}
|
|
692
846
|
date_changed() {
|
|
693
847
|
let t = !1;
|
|
@@ -695,7 +849,7 @@ class q {
|
|
|
695
849
|
Number(this.task._start) !== Number(e) && (t = !0, this.task._start = e), Number(this.task._end) !== Number(i) && (t = !0, this.task._end = i), t && this.gantt.trigger_event("date_change", [
|
|
696
850
|
this.task,
|
|
697
851
|
e,
|
|
698
|
-
|
|
852
|
+
g.add(i, -1, "second")
|
|
699
853
|
]);
|
|
700
854
|
}
|
|
701
855
|
progress_changed() {
|
|
@@ -709,32 +863,32 @@ class q {
|
|
|
709
863
|
}
|
|
710
864
|
compute_start_end_date() {
|
|
711
865
|
const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
|
|
712
|
-
let i =
|
|
866
|
+
let i = g.add(
|
|
713
867
|
this.gantt.gantt_start,
|
|
714
868
|
e * this.gantt.config.step,
|
|
715
869
|
this.gantt.config.unit
|
|
716
870
|
);
|
|
717
|
-
const
|
|
871
|
+
const s = t.getWidth() / this.gantt.config.column_width, n = g.add(
|
|
718
872
|
i,
|
|
719
|
-
|
|
873
|
+
s * this.gantt.config.step,
|
|
720
874
|
this.gantt.config.unit
|
|
721
875
|
);
|
|
722
|
-
return { new_start_date: i, new_end_date:
|
|
876
|
+
return { new_start_date: i, new_end_date: n };
|
|
723
877
|
}
|
|
724
878
|
compute_progress() {
|
|
725
879
|
this.progress_width = this.$bar_progress.getWidth(), this.x = this.$bar_progress.getBBox().x;
|
|
726
|
-
const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((
|
|
880
|
+
const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((s, n) => s + (n >= this.x && n <= t), 0) * this.gantt.config.column_width;
|
|
727
881
|
if (e < 0) return 0;
|
|
728
882
|
const i = this.$bar.getWidth() - this.ignored_duration_raw * this.gantt.config.column_width;
|
|
729
883
|
return parseInt(e / i * 100, 10);
|
|
730
884
|
}
|
|
731
885
|
compute_expected_progress() {
|
|
732
|
-
this.expected_progress =
|
|
886
|
+
this.expected_progress = g.diff(g.today(), this.task._start, "hour") / this.gantt.config.step, this.expected_progress = (this.expected_progress < this.duration ? this.expected_progress : this.duration) * 100 / this.duration;
|
|
733
887
|
}
|
|
734
888
|
compute_x() {
|
|
735
889
|
const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
|
|
736
|
-
let
|
|
737
|
-
this.x =
|
|
890
|
+
let n = g.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
|
|
891
|
+
this.x = n;
|
|
738
892
|
}
|
|
739
893
|
compute_y() {
|
|
740
894
|
this.y = this.gantt.config.header_height + this.gantt.options.padding / 2 + this.task._index * (this.height + this.gantt.options.padding);
|
|
@@ -743,12 +897,12 @@ class q {
|
|
|
743
897
|
let t = 0, e = 0;
|
|
744
898
|
for (let i = new Date(this.task._start); i < this.task._end; i.setDate(i.getDate() + 1))
|
|
745
899
|
e++, !this.gantt.config.ignored_dates.find(
|
|
746
|
-
(
|
|
900
|
+
(s) => s.getTime() === i.getTime()
|
|
747
901
|
) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
|
|
748
|
-
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration =
|
|
902
|
+
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = g.convert_scales(
|
|
749
903
|
e + "d",
|
|
750
904
|
this.gantt.config.unit
|
|
751
|
-
) / this.gantt.config.step, this.actual_duration_raw =
|
|
905
|
+
) / this.gantt.config.step, this.actual_duration_raw = g.convert_scales(
|
|
752
906
|
t + "d",
|
|
753
907
|
this.gantt.config.unit
|
|
754
908
|
) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
|
|
@@ -769,10 +923,10 @@ class q {
|
|
|
769
923
|
));
|
|
770
924
|
}
|
|
771
925
|
update_label_position() {
|
|
772
|
-
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"),
|
|
773
|
-
let
|
|
926
|
+
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, o = this.image_size + 10;
|
|
774
928
|
const a = i.getBBox().width, h = e.getWidth();
|
|
775
|
-
a > h ? (i.classList.add("big"),
|
|
929
|
+
a > h ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + o)) : 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(
|
|
776
930
|
"x",
|
|
777
931
|
e.getX() + h / 2 + o
|
|
778
932
|
)) : i.setAttribute(
|
|
@@ -797,8 +951,8 @@ class q {
|
|
|
797
951
|
i = this.x + this.$bar.getWidth() + e;
|
|
798
952
|
else
|
|
799
953
|
return;
|
|
800
|
-
const
|
|
801
|
-
this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy",
|
|
954
|
+
const s = this.y + (this.height - t) / 2;
|
|
955
|
+
this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy", s + t / 2), this.$add_icon_vertical.setAttribute("x1", i + t / 2), this.$add_icon_vertical.setAttribute("y1", s + 5), this.$add_icon_vertical.setAttribute("x2", i + t / 2), this.$add_icon_vertical.setAttribute("y2", s + t - 5), this.$add_icon_horizontal.setAttribute("x1", i + 5), this.$add_icon_horizontal.setAttribute("y1", s + t / 2), this.$add_icon_horizontal.setAttribute("x2", i + t - 5), this.$add_icon_horizontal.setAttribute("y2", s + t / 2);
|
|
802
956
|
}
|
|
803
957
|
hide_add_icon() {
|
|
804
958
|
this.$add_icon_group && this.$add_icon_group.classList.add("hide");
|
|
@@ -809,7 +963,7 @@ class q {
|
|
|
809
963
|
t.update();
|
|
810
964
|
}
|
|
811
965
|
}
|
|
812
|
-
class
|
|
966
|
+
class K {
|
|
813
967
|
constructor(t, e, i) {
|
|
814
968
|
this.parent = t, this.popup_func = e, this.gantt = i, this.make();
|
|
815
969
|
}
|
|
@@ -821,9 +975,9 @@ class F {
|
|
|
821
975
|
<div class="actions"></div>
|
|
822
976
|
`, this.hide(), this.title = this.parent.querySelector(".title"), this.subtitle = this.parent.querySelector(".subtitle"), this.details = this.parent.querySelector(".details"), this.actions = this.parent.querySelector(".actions");
|
|
823
977
|
}
|
|
824
|
-
show({ x: t, y: e, task: i, target:
|
|
978
|
+
show({ x: t, y: e, task: i, target: s }) {
|
|
825
979
|
this.actions.innerHTML = "";
|
|
826
|
-
let
|
|
980
|
+
let n = this.popup_func({
|
|
827
981
|
task: i,
|
|
828
982
|
chart: this.gantt,
|
|
829
983
|
get_title: () => this.title,
|
|
@@ -841,28 +995,28 @@ class F {
|
|
|
841
995
|
typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
|
|
842
996
|
}
|
|
843
997
|
});
|
|
844
|
-
|
|
998
|
+
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"));
|
|
845
999
|
}
|
|
846
1000
|
hide() {
|
|
847
1001
|
this.parent.classList.add("hide");
|
|
848
1002
|
}
|
|
849
1003
|
}
|
|
850
|
-
function
|
|
1004
|
+
function C(r) {
|
|
851
1005
|
const t = r.getFullYear();
|
|
852
1006
|
return t - t % 10 + "";
|
|
853
1007
|
}
|
|
854
|
-
function
|
|
855
|
-
let i =
|
|
856
|
-
return `${
|
|
1008
|
+
function J(r, t, e) {
|
|
1009
|
+
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
|
+
return `${g.format(r, n, e)} - ${g.format(i, s, e)}`;
|
|
857
1011
|
}
|
|
858
|
-
const
|
|
1012
|
+
const x = [
|
|
859
1013
|
{
|
|
860
1014
|
name: "Hour",
|
|
861
1015
|
padding: "7d",
|
|
862
1016
|
step: "1h",
|
|
863
1017
|
date_format: "YYYY-MM-DD HH:",
|
|
864
1018
|
lower_text: "HH",
|
|
865
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
1019
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D MMMM", e) : "",
|
|
866
1020
|
upper_text_frequency: 24
|
|
867
1021
|
},
|
|
868
1022
|
{
|
|
@@ -871,7 +1025,7 @@ const k = [
|
|
|
871
1025
|
step: "6h",
|
|
872
1026
|
date_format: "YYYY-MM-DD HH:",
|
|
873
1027
|
lower_text: "HH",
|
|
874
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
1028
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D MMM", e) : "",
|
|
875
1029
|
upper_text_frequency: 4
|
|
876
1030
|
},
|
|
877
1031
|
{
|
|
@@ -880,7 +1034,7 @@ const k = [
|
|
|
880
1034
|
step: "12h",
|
|
881
1035
|
date_format: "YYYY-MM-DD HH:",
|
|
882
1036
|
lower_text: "HH",
|
|
883
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ?
|
|
1037
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? g.format(r, "D MMM", e) : g.format(r, "D", e) : "",
|
|
884
1038
|
upper_text_frequency: 2
|
|
885
1039
|
},
|
|
886
1040
|
{
|
|
@@ -888,8 +1042,8 @@ const k = [
|
|
|
888
1042
|
padding: "7d",
|
|
889
1043
|
date_format: "YYYY-MM-DD",
|
|
890
1044
|
step: "1d",
|
|
891
|
-
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
892
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
1045
|
+
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D", e) : "",
|
|
1046
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
|
|
893
1047
|
thick_line: (r) => r.getDay() === 1
|
|
894
1048
|
},
|
|
895
1049
|
{
|
|
@@ -898,8 +1052,8 @@ const k = [
|
|
|
898
1052
|
step: "7d",
|
|
899
1053
|
date_format: "YYYY-MM-DD",
|
|
900
1054
|
column_width: 140,
|
|
901
|
-
lower_text:
|
|
902
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
1055
|
+
lower_text: J,
|
|
1056
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
|
|
903
1057
|
thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
|
|
904
1058
|
upper_text_frequency: 4
|
|
905
1059
|
},
|
|
@@ -910,7 +1064,7 @@ const k = [
|
|
|
910
1064
|
column_width: 120,
|
|
911
1065
|
date_format: "YYYY-MM",
|
|
912
1066
|
lower_text: "MMMM",
|
|
913
|
-
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ?
|
|
1067
|
+
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? g.format(r, "YYYY", e) : "",
|
|
914
1068
|
thick_line: (r) => r.getMonth() % 3 === 0,
|
|
915
1069
|
snap_at: "7d"
|
|
916
1070
|
},
|
|
@@ -920,11 +1074,11 @@ const k = [
|
|
|
920
1074
|
step: "1y",
|
|
921
1075
|
column_width: 120,
|
|
922
1076
|
date_format: "YYYY",
|
|
923
|
-
upper_text: (r, t, e) => !t ||
|
|
1077
|
+
upper_text: (r, t, e) => !t || C(r) !== C(t) ? C(r) : "",
|
|
924
1078
|
lower_text: "YYYY",
|
|
925
1079
|
snap_at: "30d"
|
|
926
1080
|
}
|
|
927
|
-
],
|
|
1081
|
+
], Z = {
|
|
928
1082
|
arrow_curve: 5,
|
|
929
1083
|
auto_move_label: !1,
|
|
930
1084
|
bar_corner_radius: 3,
|
|
@@ -933,7 +1087,9 @@ const k = [
|
|
|
933
1087
|
column_width: null,
|
|
934
1088
|
critical_path: !1,
|
|
935
1089
|
date_format: "YYYY-MM-DD HH:mm",
|
|
936
|
-
dependencies_type: "
|
|
1090
|
+
dependencies_type: "finish-to-start",
|
|
1091
|
+
dependency_shifting: "none",
|
|
1092
|
+
// 'none' | 'maintain_buffer_all' | 'maintain_buffer_downstream' | 'consume_buffer'
|
|
937
1093
|
upper_header_height: 45,
|
|
938
1094
|
lower_header_height: 30,
|
|
939
1095
|
snap_at: null,
|
|
@@ -943,16 +1099,15 @@ const k = [
|
|
|
943
1099
|
isRTL: !1,
|
|
944
1100
|
language: "en",
|
|
945
1101
|
lines: "both",
|
|
946
|
-
move_dependencies: !0,
|
|
947
1102
|
padding: 18,
|
|
948
1103
|
popup: (r) => {
|
|
949
1104
|
r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
|
|
950
|
-
const t =
|
|
1105
|
+
const t = g.format(
|
|
951
1106
|
r.task._start,
|
|
952
1107
|
"MMM D",
|
|
953
1108
|
r.chart.options.language
|
|
954
|
-
), e =
|
|
955
|
-
|
|
1109
|
+
), e = g.format(
|
|
1110
|
+
g.add(r.task._end, -1, "second"),
|
|
956
1111
|
"MMM D",
|
|
957
1112
|
r.chart.options.language
|
|
958
1113
|
);
|
|
@@ -970,7 +1125,7 @@ const k = [
|
|
|
970
1125
|
today_button: !0,
|
|
971
1126
|
view_mode: "Day",
|
|
972
1127
|
view_mode_select: !1,
|
|
973
|
-
view_modes:
|
|
1128
|
+
view_modes: x,
|
|
974
1129
|
is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6,
|
|
975
1130
|
task_column: {
|
|
976
1131
|
enabled: !1,
|
|
@@ -979,19 +1134,19 @@ const k = [
|
|
|
979
1134
|
content: null
|
|
980
1135
|
}
|
|
981
1136
|
};
|
|
982
|
-
class
|
|
1137
|
+
class tt {
|
|
983
1138
|
constructor(t, e, i) {
|
|
984
1139
|
this.setup_wrapper(t), this.setup_options(i), this.apply_rtl_direction(), this.setup_tasks(e), this.change_view_mode(), this.bind_events();
|
|
985
1140
|
}
|
|
986
1141
|
setup_wrapper(t) {
|
|
987
1142
|
let e, i;
|
|
988
1143
|
if (typeof t == "string") {
|
|
989
|
-
let
|
|
990
|
-
if (!
|
|
1144
|
+
let s = document.querySelector(t);
|
|
1145
|
+
if (!s)
|
|
991
1146
|
throw new ReferenceError(
|
|
992
1147
|
`CSS selector "${t}" could not be found in DOM`
|
|
993
1148
|
);
|
|
994
|
-
t =
|
|
1149
|
+
t = s;
|
|
995
1150
|
}
|
|
996
1151
|
if (t instanceof HTMLElement)
|
|
997
1152
|
i = t, e = t.querySelector("svg");
|
|
@@ -1001,7 +1156,7 @@ class I {
|
|
|
1001
1156
|
throw new TypeError(
|
|
1002
1157
|
"Frappe Gantt only supports usage of a string CSS selector, HTML DOM element or SVG DOM element for the 'element' parameter"
|
|
1003
1158
|
);
|
|
1004
|
-
e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg =
|
|
1159
|
+
e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg = w("svg", {
|
|
1005
1160
|
append_to: i,
|
|
1006
1161
|
class: "gantt"
|
|
1007
1162
|
}), this.$wrapper = this.create_el({
|
|
@@ -1020,31 +1175,31 @@ class I {
|
|
|
1020
1175
|
}
|
|
1021
1176
|
setup_options(t) {
|
|
1022
1177
|
var i;
|
|
1023
|
-
this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((
|
|
1024
|
-
if (typeof
|
|
1025
|
-
const
|
|
1026
|
-
(o) => o.name ===
|
|
1178
|
+
this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((s) => {
|
|
1179
|
+
if (typeof s == "string") {
|
|
1180
|
+
const n = x.find(
|
|
1181
|
+
(o) => o.name === s
|
|
1027
1182
|
);
|
|
1028
|
-
return
|
|
1029
|
-
`The view mode "${
|
|
1030
|
-
),
|
|
1183
|
+
return n || console.error(
|
|
1184
|
+
`The view mode "${s}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
|
|
1185
|
+
), n;
|
|
1031
1186
|
}
|
|
1032
|
-
return
|
|
1033
|
-
}), t.view_mode = t.view_modes[0]), this.options = { ...
|
|
1187
|
+
return s;
|
|
1188
|
+
}), t.view_mode = t.view_modes[0]), this.options = { ...Z, ...t };
|
|
1034
1189
|
const e = {
|
|
1035
1190
|
"grid-height": "container_height",
|
|
1036
1191
|
"bar-height": "bar_height",
|
|
1037
1192
|
"lower-header-height": "lower_header_height",
|
|
1038
1193
|
"upper-header-height": "upper_header_height"
|
|
1039
1194
|
};
|
|
1040
|
-
for (let
|
|
1041
|
-
let
|
|
1042
|
-
|
|
1043
|
-
"--gv-" +
|
|
1044
|
-
|
|
1195
|
+
for (let s in e) {
|
|
1196
|
+
let n = this.options[e[s]];
|
|
1197
|
+
n !== "auto" && (this.$wrapper.style.setProperty(
|
|
1198
|
+
"--gv-" + s,
|
|
1199
|
+
n + "px"
|
|
1045
1200
|
), this.$container.style.setProperty(
|
|
1046
|
-
"--gv-" +
|
|
1047
|
-
|
|
1201
|
+
"--gv-" + s,
|
|
1202
|
+
n + "px"
|
|
1048
1203
|
));
|
|
1049
1204
|
}
|
|
1050
1205
|
if ((i = this.options.task_column) != null && i.enabled && (this.$wrapper.style.setProperty(
|
|
@@ -1059,12 +1214,12 @@ class I {
|
|
|
1059
1214
|
extend_by_units: 10
|
|
1060
1215
|
}, typeof this.options.ignore != "function") {
|
|
1061
1216
|
typeof this.options.ignore == "string" && (this.options.ignore = [this.options.ignore]);
|
|
1062
|
-
for (let
|
|
1063
|
-
if (typeof
|
|
1064
|
-
this.config.ignored_function =
|
|
1217
|
+
for (let s of this.options.ignore) {
|
|
1218
|
+
if (typeof s == "function") {
|
|
1219
|
+
this.config.ignored_function = s;
|
|
1065
1220
|
continue;
|
|
1066
1221
|
}
|
|
1067
|
-
typeof
|
|
1222
|
+
typeof s == "string" && (s === "weekend" ? this.config.ignored_function = (n) => n.getDay() == 6 || n.getDay() == 0 : this.config.ignored_dates.push(/* @__PURE__ */ new Date(s + " ")));
|
|
1068
1223
|
}
|
|
1069
1224
|
} else
|
|
1070
1225
|
this.config.ignored_function = this.options.ignore;
|
|
@@ -1074,10 +1229,10 @@ class I {
|
|
|
1074
1229
|
}
|
|
1075
1230
|
setup_tasks(t) {
|
|
1076
1231
|
this.tasks = t.map((e, i) => {
|
|
1077
|
-
var
|
|
1232
|
+
var s;
|
|
1078
1233
|
if (!e.start || !e.end)
|
|
1079
1234
|
if (!e.start && !e.end) {
|
|
1080
|
-
if (!((
|
|
1235
|
+
if (!((s = this.options.task_column) != null && s.enabled))
|
|
1081
1236
|
return console.warn(
|
|
1082
1237
|
`task "${e.id || e.name}" has no dates and will be hidden (task column is disabled)`
|
|
1083
1238
|
), !1;
|
|
@@ -1091,46 +1246,43 @@ class I {
|
|
|
1091
1246
|
return console.error(`task "${e.id}" doesn't have an end date`), !1;
|
|
1092
1247
|
}
|
|
1093
1248
|
if (!e._has_no_dates) {
|
|
1094
|
-
if (e._start =
|
|
1095
|
-
let { duration: d, scale: _ } =
|
|
1096
|
-
e.end =
|
|
1097
|
-
})), e._end =
|
|
1249
|
+
if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((h) => {
|
|
1250
|
+
let { duration: d, scale: _ } = g.parse_duration(h);
|
|
1251
|
+
e.end = g.add(e.end, d, _);
|
|
1252
|
+
})), e._end = g.parse(e.end), g.diff(e._end, e._start, "year") < 0)
|
|
1098
1253
|
return console.error(
|
|
1099
1254
|
`start of task can't be after end of task: in task "${e.id}"`
|
|
1100
1255
|
), !1;
|
|
1101
|
-
if (
|
|
1256
|
+
if (g.diff(e._end, e._start, "year") > 10)
|
|
1102
1257
|
return console.error(
|
|
1103
1258
|
`the duration of task "${e.id}" is too long (above ten years)`
|
|
1104
1259
|
), !1;
|
|
1105
|
-
e._index = i,
|
|
1260
|
+
e._index = i, g.get_date_values(e._end).slice(3).every((a) => a === 0) && (e._end = g.add(e._end, 24, "hour"));
|
|
1106
1261
|
}
|
|
1107
|
-
|
|
1108
|
-
let s = [];
|
|
1109
|
-
e.dependencies && (s = e.dependencies.split(",").map((o) => o.trim().replaceAll(" ", "_")).filter((o) => o)), e.dependencies = s;
|
|
1110
|
-
}
|
|
1111
|
-
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = N(e), e;
|
|
1262
|
+
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;
|
|
1112
1263
|
}).filter((e) => e).map((e, i) => (e._index = i, e)), this.setup_dependencies();
|
|
1113
1264
|
}
|
|
1114
1265
|
setup_dependencies() {
|
|
1115
1266
|
this.dependency_map = {};
|
|
1116
1267
|
for (let t of this.tasks)
|
|
1117
1268
|
for (let e of t.dependencies)
|
|
1118
|
-
this.dependency_map[e] = this.dependency_map[e] || [], this.dependency_map[e].push(t.id);
|
|
1269
|
+
this.dependency_map[e.id] = this.dependency_map[e.id] || [], this.dependency_map[e.id].push(t.id);
|
|
1119
1270
|
}
|
|
1120
1271
|
refresh(t, e = !1) {
|
|
1121
1272
|
this.setup_tasks(t), this.change_view_mode(this.options.view_mode, e);
|
|
1122
1273
|
}
|
|
1123
1274
|
update_task(t, e) {
|
|
1124
|
-
let i = this.tasks.find((
|
|
1125
|
-
|
|
1275
|
+
let i = this.tasks.find((o) => o.id === t), s = this.bars[i._index];
|
|
1276
|
+
const n = e.dependencies !== void 0;
|
|
1277
|
+
Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((o) => o && typeof o.id == "string").map((o) => ({ ...o, id: o.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
|
|
1126
1278
|
}
|
|
1127
1279
|
change_view_mode(t = this.options.view_mode, e = !1) {
|
|
1128
|
-
typeof t == "string" && (t = this.options.view_modes.find((
|
|
1129
|
-
let i,
|
|
1130
|
-
e && (i = this.$container.scrollLeft,
|
|
1280
|
+
typeof t == "string" && (t = this.options.view_modes.find((n) => n.name === t));
|
|
1281
|
+
let i, s;
|
|
1282
|
+
e && (i = this.$container.scrollLeft, s = this.options.scroll_to, this.options.scroll_to = null), this.options.view_mode = t.name, this.config.view_mode = t, this.update_view_scale(t), this.setup_dates(e), this.render(), e && (this.$container.scrollLeft = i, this.options.scroll_to = s), this.trigger_event("view_change", [t]);
|
|
1131
1283
|
}
|
|
1132
1284
|
update_view_scale(t) {
|
|
1133
|
-
let { duration: e, scale: i } =
|
|
1285
|
+
let { duration: e, scale: i } = g.parse_duration(t.step);
|
|
1134
1286
|
this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
|
|
1135
1287
|
"--gv-column-width",
|
|
1136
1288
|
this.config.column_width + "px"
|
|
@@ -1142,15 +1294,15 @@ class I {
|
|
|
1142
1294
|
setup_gantt_dates(t) {
|
|
1143
1295
|
let e, i;
|
|
1144
1296
|
this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
|
|
1145
|
-
for (let
|
|
1146
|
-
(!e ||
|
|
1147
|
-
if (e =
|
|
1297
|
+
for (let s of this.tasks)
|
|
1298
|
+
(!e || s._start < e) && (e = s._start), (!i || s._end > i) && (i = s._end);
|
|
1299
|
+
if (e = g.start_of(e, this.config.unit), i = g.start_of(i, this.config.unit), !t)
|
|
1148
1300
|
if (this.options.infinite_padding)
|
|
1149
|
-
this.gantt_start =
|
|
1301
|
+
this.gantt_start = g.add(
|
|
1150
1302
|
e,
|
|
1151
1303
|
-this.config.extend_by_units * 3,
|
|
1152
1304
|
this.config.unit
|
|
1153
|
-
), this.gantt_end =
|
|
1305
|
+
), this.gantt_end = g.add(
|
|
1154
1306
|
i,
|
|
1155
1307
|
this.config.extend_by_units * 3,
|
|
1156
1308
|
this.config.unit
|
|
@@ -1160,17 +1312,17 @@ class I {
|
|
|
1160
1312
|
this.config.view_mode.padding,
|
|
1161
1313
|
this.config.view_mode.padding
|
|
1162
1314
|
]);
|
|
1163
|
-
let [
|
|
1164
|
-
|
|
1315
|
+
let [s, n] = this.config.view_mode.padding.map(
|
|
1316
|
+
g.parse_duration
|
|
1165
1317
|
);
|
|
1166
|
-
this.gantt_start =
|
|
1318
|
+
this.gantt_start = g.add(
|
|
1167
1319
|
e,
|
|
1168
|
-
-
|
|
1169
|
-
n.scale
|
|
1170
|
-
), this.gantt_end = c.add(
|
|
1171
|
-
i,
|
|
1172
|
-
s.duration,
|
|
1320
|
+
-s.duration,
|
|
1173
1321
|
s.scale
|
|
1322
|
+
), this.gantt_end = g.add(
|
|
1323
|
+
i,
|
|
1324
|
+
n.duration,
|
|
1325
|
+
n.scale
|
|
1174
1326
|
);
|
|
1175
1327
|
}
|
|
1176
1328
|
this.config.date_format = this.config.view_mode.date_format || this.options.date_format, this.gantt_start.setHours(0, 0, 0, 0);
|
|
@@ -1178,7 +1330,7 @@ class I {
|
|
|
1178
1330
|
setup_date_values() {
|
|
1179
1331
|
let t = this.gantt_start;
|
|
1180
1332
|
for (this.dates = [t]; t < this.gantt_end; )
|
|
1181
|
-
t =
|
|
1333
|
+
t = g.add(
|
|
1182
1334
|
t,
|
|
1183
1335
|
this.config.step,
|
|
1184
1336
|
this.config.unit
|
|
@@ -1194,7 +1346,7 @@ class I {
|
|
|
1194
1346
|
this.layers = {};
|
|
1195
1347
|
const t = ["grid", "arrow", "progress", "bar"];
|
|
1196
1348
|
for (let e of t)
|
|
1197
|
-
this.layers[e] =
|
|
1349
|
+
this.layers[e] = w("g", {
|
|
1198
1350
|
class: e,
|
|
1199
1351
|
append_to: this.$svg
|
|
1200
1352
|
});
|
|
@@ -1218,25 +1370,25 @@ class I {
|
|
|
1218
1370
|
this.config.header_height + this.options.padding + (this.options.bar_height + this.options.padding) * this.tasks.length - 10,
|
|
1219
1371
|
this.options.container_height !== "auto" ? this.options.container_height : 0
|
|
1220
1372
|
);
|
|
1221
|
-
|
|
1373
|
+
w("rect", {
|
|
1222
1374
|
x: 0,
|
|
1223
1375
|
y: 0,
|
|
1224
1376
|
width: t,
|
|
1225
1377
|
height: e,
|
|
1226
1378
|
class: "grid-background",
|
|
1227
1379
|
append_to: this.$svg
|
|
1228
|
-
}),
|
|
1380
|
+
}), m.attr(this.$svg, {
|
|
1229
1381
|
height: e,
|
|
1230
1382
|
width: "100%"
|
|
1231
1383
|
}), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
|
|
1232
1384
|
}
|
|
1233
1385
|
make_grid_rows() {
|
|
1234
|
-
const t =
|
|
1386
|
+
const t = w("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
|
|
1235
1387
|
this.config.header_height;
|
|
1236
|
-
for (let
|
|
1237
|
-
|
|
1388
|
+
for (let s = this.config.header_height; s < this.grid_height; s += i)
|
|
1389
|
+
w("rect", {
|
|
1238
1390
|
x: 0,
|
|
1239
|
-
y:
|
|
1391
|
+
y: s,
|
|
1240
1392
|
width: e,
|
|
1241
1393
|
height: i,
|
|
1242
1394
|
class: "grid-row",
|
|
@@ -1263,8 +1415,8 @@ class I {
|
|
|
1263
1415
|
const e = document.createElement("option");
|
|
1264
1416
|
e.selected = !0, e.disabled = !0, e.textContent = "Mode", t.appendChild(e);
|
|
1265
1417
|
for (const i of this.options.view_modes) {
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1418
|
+
const s = document.createElement("option");
|
|
1419
|
+
s.value = i.name, s.textContent = i.name, i.name === this.config.view_mode.name && (s.selected = !0), t.appendChild(s);
|
|
1268
1420
|
}
|
|
1269
1421
|
t.addEventListener(
|
|
1270
1422
|
"change",
|
|
@@ -1279,9 +1431,9 @@ class I {
|
|
|
1279
1431
|
}
|
|
1280
1432
|
}
|
|
1281
1433
|
make_task_column() {
|
|
1282
|
-
var i,
|
|
1283
|
-
if ((i = this.$task_column) == null || i.remove(), !((
|
|
1284
|
-
(o = (
|
|
1434
|
+
var i, s, n, o, a, h, d, _, c, p;
|
|
1435
|
+
if ((i = this.$task_column) == null || i.remove(), !((s = this.options.task_column) != null && s.enabled)) {
|
|
1436
|
+
(o = (n = this.$wrapper) == null ? void 0 : n.classList) == null || o.remove("has-task-column");
|
|
1285
1437
|
return;
|
|
1286
1438
|
}
|
|
1287
1439
|
(h = (a = this.$wrapper) == null ? void 0 : a.classList) == null || h.add("has-task-column"), this.$task_column = this.create_el({
|
|
@@ -1304,47 +1456,47 @@ class I {
|
|
|
1304
1456
|
), this.$container.style.setProperty(
|
|
1305
1457
|
"--gv-task-column-content-height",
|
|
1306
1458
|
e + "px"
|
|
1307
|
-
), this.tasks.forEach((
|
|
1308
|
-
const
|
|
1459
|
+
), this.tasks.forEach((l) => {
|
|
1460
|
+
const f = this.options.bar_height + this.options.padding, u = this.create_el({
|
|
1309
1461
|
classes: "task-row",
|
|
1310
1462
|
append_to: this.$task_column_content
|
|
1311
1463
|
});
|
|
1312
|
-
if (
|
|
1313
|
-
const b = this.options.task_column.content(
|
|
1314
|
-
typeof b == "string" ?
|
|
1464
|
+
if (u.style.top = l._index * f - 1 + "px", u.style.height = f + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
|
|
1465
|
+
const b = this.options.task_column.content(l);
|
|
1466
|
+
typeof b == "string" ? u.innerHTML = b : b instanceof HTMLElement && u.appendChild(b);
|
|
1315
1467
|
} else
|
|
1316
|
-
|
|
1317
|
-
|
|
1468
|
+
u.textContent = l.name, u.title = l.name;
|
|
1469
|
+
u.setAttribute("data-task-id", l.id);
|
|
1318
1470
|
}), this.$task_column.style.width = this.options.task_column.width + "px", this.$task_column_resize_handle = this.create_el({
|
|
1319
1471
|
classes: "task-column-resize-handle",
|
|
1320
1472
|
append_to: this.$task_column
|
|
1321
|
-
}), this.options.isRTL ? (_ = (d = this.$wrapper) == null ? void 0 : d.classList) == null || _.add("rtl") : (
|
|
1473
|
+
}), this.options.isRTL ? (_ = (d = this.$wrapper) == null ? void 0 : d.classList) == null || _.add("rtl") : (p = (c = this.$wrapper) == null ? void 0 : c.classList) == null || p.remove("rtl");
|
|
1322
1474
|
}
|
|
1323
1475
|
make_grid_ticks() {
|
|
1324
1476
|
if (this.options.lines === "none") return;
|
|
1325
|
-
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height,
|
|
1477
|
+
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s = w("g", {
|
|
1326
1478
|
class: "lines_layer",
|
|
1327
1479
|
append_to: this.layers.grid
|
|
1328
|
-
}),
|
|
1480
|
+
}), n = this.config.header_height;
|
|
1329
1481
|
const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
|
|
1330
1482
|
if (this.options.lines !== "vertical")
|
|
1331
1483
|
for (let h = this.config.header_height; h < this.grid_height; h += a)
|
|
1332
|
-
|
|
1484
|
+
w("line", {
|
|
1333
1485
|
x1: 0,
|
|
1334
|
-
y1:
|
|
1486
|
+
y1: n + a,
|
|
1335
1487
|
x2: o,
|
|
1336
|
-
y2:
|
|
1488
|
+
y2: n + a,
|
|
1337
1489
|
class: "row-line",
|
|
1338
|
-
append_to:
|
|
1339
|
-
}),
|
|
1490
|
+
append_to: s
|
|
1491
|
+
}), n += a;
|
|
1340
1492
|
if (this.options.lines !== "horizontal")
|
|
1341
1493
|
for (let h of this.dates) {
|
|
1342
1494
|
let d = "tick";
|
|
1343
|
-
this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (d += " thick"),
|
|
1495
|
+
this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (d += " thick"), w("path", {
|
|
1344
1496
|
d: `M ${t} ${e} v ${i}`,
|
|
1345
1497
|
class: d,
|
|
1346
1498
|
append_to: this.layers.grid
|
|
1347
|
-
}), this.view_is("month") ? t +=
|
|
1499
|
+
}), this.view_is("month") ? t += g.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += g.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
|
|
1348
1500
|
}
|
|
1349
1501
|
}
|
|
1350
1502
|
highlight_holidays() {
|
|
@@ -1353,10 +1505,10 @@ class I {
|
|
|
1353
1505
|
for (let e in this.options.holidays) {
|
|
1354
1506
|
let i = this.options.holidays[e];
|
|
1355
1507
|
i === "weekend" && (i = this.options.is_weekend);
|
|
1356
|
-
let
|
|
1508
|
+
let s;
|
|
1357
1509
|
if (typeof i == "object") {
|
|
1358
|
-
let
|
|
1359
|
-
if (
|
|
1510
|
+
let n = i.find((o) => typeof o == "function");
|
|
1511
|
+
if (n && (s = n), this.options.holidays.name) {
|
|
1360
1512
|
let o = /* @__PURE__ */ new Date(i.date + " ");
|
|
1361
1513
|
i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
|
|
1362
1514
|
} else
|
|
@@ -1368,26 +1520,26 @@ class I {
|
|
|
1368
1520
|
return (/* @__PURE__ */ new Date(a + " ")).getTime();
|
|
1369
1521
|
}).includes(o.getTime());
|
|
1370
1522
|
}
|
|
1371
|
-
for (let
|
|
1523
|
+
for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
|
|
1372
1524
|
if (!(this.config.ignored_dates.find(
|
|
1373
|
-
(o) => o.getTime() ==
|
|
1374
|
-
) || this.config.ignored_function && this.config.ignored_function(
|
|
1375
|
-
const o =
|
|
1376
|
-
|
|
1525
|
+
(o) => o.getTime() == n.getTime()
|
|
1526
|
+
) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
|
|
1527
|
+
const o = g.diff(
|
|
1528
|
+
n,
|
|
1377
1529
|
this.gantt_start,
|
|
1378
1530
|
this.config.unit
|
|
1379
|
-
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h =
|
|
1380
|
-
if (t[
|
|
1531
|
+
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = g.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
|
|
1532
|
+
if (t[n]) {
|
|
1381
1533
|
let d = this.create_el({
|
|
1382
1534
|
classes: "holiday-label label_" + h,
|
|
1383
1535
|
append_to: this.$extras
|
|
1384
1536
|
});
|
|
1385
|
-
d.textContent = t[
|
|
1537
|
+
d.textContent = t[n];
|
|
1386
1538
|
}
|
|
1387
|
-
|
|
1539
|
+
w("rect", {
|
|
1388
1540
|
x: Math.round(o),
|
|
1389
1541
|
y: this.config.header_height,
|
|
1390
|
-
width: this.config.column_width /
|
|
1542
|
+
width: this.config.column_width / g.convert_scales(
|
|
1391
1543
|
this.config.view_mode.step,
|
|
1392
1544
|
"day"
|
|
1393
1545
|
),
|
|
@@ -1409,20 +1561,20 @@ class I {
|
|
|
1409
1561
|
if (!t) return;
|
|
1410
1562
|
const [e, i] = t;
|
|
1411
1563
|
i.classList.add("current-date-highlight");
|
|
1412
|
-
const
|
|
1564
|
+
const n = g.diff(
|
|
1413
1565
|
/* @__PURE__ */ new Date(),
|
|
1414
1566
|
this.gantt_start,
|
|
1415
1567
|
this.config.unit
|
|
1416
1568
|
) / this.config.step * this.config.column_width;
|
|
1417
1569
|
this.$current_highlight = this.create_el({
|
|
1418
1570
|
top: this.config.header_height,
|
|
1419
|
-
left:
|
|
1571
|
+
left: n,
|
|
1420
1572
|
height: this.grid_height - this.config.header_height,
|
|
1421
1573
|
classes: "current-highlight",
|
|
1422
1574
|
append_to: this.$container
|
|
1423
1575
|
}), this.$current_ball_highlight = this.create_el({
|
|
1424
1576
|
top: this.config.header_height - 6,
|
|
1425
|
-
left:
|
|
1577
|
+
left: n - 2.5,
|
|
1426
1578
|
width: 6,
|
|
1427
1579
|
height: 6,
|
|
1428
1580
|
classes: "current-ball-highlight",
|
|
@@ -1440,15 +1592,15 @@ class I {
|
|
|
1440
1592
|
</pattern>`;
|
|
1441
1593
|
for (let i = new Date(this.gantt_start); i <= this.gantt_end; i.setDate(i.getDate() + 1)) {
|
|
1442
1594
|
if (!this.config.ignored_dates.find(
|
|
1443
|
-
(
|
|
1595
|
+
(n) => n.getTime() == i.getTime()
|
|
1444
1596
|
) && (!this.config.ignored_function || !this.config.ignored_function(i)))
|
|
1445
1597
|
continue;
|
|
1446
|
-
let
|
|
1447
|
-
|
|
1598
|
+
let s = g.convert_scales(
|
|
1599
|
+
g.diff(i, this.gantt_start) + "d",
|
|
1448
1600
|
this.config.unit
|
|
1449
1601
|
) / this.config.step;
|
|
1450
|
-
this.config.ignored_positions.push(
|
|
1451
|
-
x:
|
|
1602
|
+
this.config.ignored_positions.push(s * this.config.column_width), w("rect", {
|
|
1603
|
+
x: s * this.config.column_width,
|
|
1452
1604
|
y: this.config.header_height,
|
|
1453
1605
|
width: this.config.column_width,
|
|
1454
1606
|
height: t,
|
|
@@ -1461,10 +1613,10 @@ class I {
|
|
|
1461
1613
|
this.config.view_mode
|
|
1462
1614
|
);
|
|
1463
1615
|
}
|
|
1464
|
-
create_el({ left: t, top: e, width: i, height:
|
|
1616
|
+
create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
|
|
1465
1617
|
let d = document.createElement(h || "div");
|
|
1466
1618
|
for (let _ of o.split(" ")) d.classList.add(_);
|
|
1467
|
-
return d.style.top = e + "px", d.style.left = t + "px",
|
|
1619
|
+
return d.style.top = e + "px", d.style.left = t + "px", n && (d.id = n), i && (d.style.width = i + "px"), s && (d.style.height = s + "px"), a && a.appendChild(d), d;
|
|
1468
1620
|
}
|
|
1469
1621
|
make_dates() {
|
|
1470
1622
|
this.get_dates_to_draw().forEach((t, e) => {
|
|
@@ -1472,7 +1624,7 @@ class I {
|
|
|
1472
1624
|
let i = this.create_el({
|
|
1473
1625
|
left: t.x,
|
|
1474
1626
|
top: t.lower_y,
|
|
1475
|
-
classes: "lower-text date_" +
|
|
1627
|
+
classes: "lower-text date_" + D(t.formatted_date),
|
|
1476
1628
|
append_to: this.$lower_header
|
|
1477
1629
|
});
|
|
1478
1630
|
i.innerText = t.lower_text;
|
|
@@ -1492,27 +1644,27 @@ class I {
|
|
|
1492
1644
|
}
|
|
1493
1645
|
get_dates_to_draw() {
|
|
1494
1646
|
let t = null;
|
|
1495
|
-
return this.dates.map((i,
|
|
1496
|
-
const
|
|
1497
|
-
return t =
|
|
1647
|
+
return this.dates.map((i, s) => {
|
|
1648
|
+
const n = this.get_date_info(i, t, s);
|
|
1649
|
+
return t = n, n;
|
|
1498
1650
|
});
|
|
1499
1651
|
}
|
|
1500
1652
|
get_date_info(t, e) {
|
|
1501
1653
|
let i = e ? e.date : null;
|
|
1502
1654
|
this.config.column_width;
|
|
1503
|
-
const
|
|
1504
|
-
let
|
|
1505
|
-
return
|
|
1655
|
+
const s = e ? e.x + e.column_width : 0;
|
|
1656
|
+
let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
|
|
1657
|
+
return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => g.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => g.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
|
|
1506
1658
|
date: t,
|
|
1507
|
-
formatted_date:
|
|
1508
|
-
|
|
1659
|
+
formatted_date: D(
|
|
1660
|
+
g.format(
|
|
1509
1661
|
t,
|
|
1510
1662
|
this.config.date_format,
|
|
1511
1663
|
this.options.language
|
|
1512
1664
|
)
|
|
1513
1665
|
),
|
|
1514
1666
|
column_width: this.config.column_width,
|
|
1515
|
-
x:
|
|
1667
|
+
x: s,
|
|
1516
1668
|
upper_text: this.config.view_mode.upper_text(
|
|
1517
1669
|
t,
|
|
1518
1670
|
i,
|
|
@@ -1531,7 +1683,7 @@ class I {
|
|
|
1531
1683
|
this.bars = this.tasks.map((t) => {
|
|
1532
1684
|
if (t._has_no_dates)
|
|
1533
1685
|
return null;
|
|
1534
|
-
const e = new
|
|
1686
|
+
const e = new Q(this, t);
|
|
1535
1687
|
return this.layers.bar.appendChild(e.group), e;
|
|
1536
1688
|
}).filter((t) => t !== null);
|
|
1537
1689
|
}
|
|
@@ -1540,58 +1692,57 @@ class I {
|
|
|
1540
1692
|
for (let t of this.tasks) {
|
|
1541
1693
|
let e = [];
|
|
1542
1694
|
e = t.dependencies.map((i) => {
|
|
1543
|
-
const
|
|
1544
|
-
if (!
|
|
1545
|
-
const
|
|
1546
|
-
if (!
|
|
1547
|
-
const a = new
|
|
1695
|
+
const s = this.get_task(i.id);
|
|
1696
|
+
if (!s) return;
|
|
1697
|
+
const n = this.bars[s._index], o = this.bars[t._index];
|
|
1698
|
+
if (!n || !o) return;
|
|
1699
|
+
const a = i.type || this.options.dependencies_type || "finish-to-start", h = new U(
|
|
1548
1700
|
this,
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
// to_task
|
|
1701
|
+
n,
|
|
1702
|
+
o,
|
|
1703
|
+
a
|
|
1553
1704
|
);
|
|
1554
|
-
return this.layers.arrow.appendChild(
|
|
1705
|
+
return this.layers.arrow.appendChild(h.element), this.layers.arrow.appendChild(h.hit_element), h;
|
|
1555
1706
|
}).filter(Boolean), this.arrows = this.arrows.concat(e);
|
|
1556
1707
|
}
|
|
1557
1708
|
}
|
|
1558
1709
|
calculate_critical_path() {
|
|
1559
|
-
this.tasks.forEach((
|
|
1710
|
+
this.tasks.forEach((n) => n._is_critical = !1);
|
|
1560
1711
|
const t = {};
|
|
1561
|
-
this.tasks.forEach((
|
|
1562
|
-
t[
|
|
1712
|
+
this.tasks.forEach((n) => {
|
|
1713
|
+
t[n.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
|
|
1563
1714
|
});
|
|
1564
|
-
const e = (
|
|
1565
|
-
if (t[
|
|
1715
|
+
const e = (n) => {
|
|
1716
|
+
if (t[n.id].ef > 0) return t[n.id];
|
|
1566
1717
|
let o = 0;
|
|
1567
|
-
|
|
1568
|
-
const d = this.get_task(h);
|
|
1718
|
+
n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
|
|
1719
|
+
const d = this.get_task(h.id);
|
|
1569
1720
|
if (d) {
|
|
1570
1721
|
const _ = e(d);
|
|
1571
1722
|
o = Math.max(o, _.ef);
|
|
1572
1723
|
}
|
|
1573
|
-
}), t[
|
|
1574
|
-
const a =
|
|
1575
|
-
return t[
|
|
1724
|
+
}), t[n.id].es = o;
|
|
1725
|
+
const a = g.diff(n._end, n._start, "hour") / 24;
|
|
1726
|
+
return t[n.id].ef = o + a, t[n.id];
|
|
1576
1727
|
};
|
|
1577
|
-
this.tasks.forEach((
|
|
1578
|
-
const i = Math.max(...Object.values(t).map((
|
|
1579
|
-
if (t[
|
|
1580
|
-
return t[
|
|
1728
|
+
this.tasks.forEach((n) => e(n));
|
|
1729
|
+
const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
|
|
1730
|
+
if (t[n.id].ls > 0 || t[n.id].lf > 0)
|
|
1731
|
+
return t[n.id];
|
|
1581
1732
|
const o = this.tasks.filter(
|
|
1582
|
-
(d) => d.dependencies && d.dependencies.
|
|
1733
|
+
(d) => d.dependencies && d.dependencies.some((_) => _.id === n.id)
|
|
1583
1734
|
);
|
|
1584
1735
|
let a = i;
|
|
1585
1736
|
o.length > 0 && o.forEach((d) => {
|
|
1586
|
-
const _ =
|
|
1737
|
+
const _ = s(d);
|
|
1587
1738
|
a = Math.min(a, _.ls);
|
|
1588
1739
|
});
|
|
1589
|
-
const h =
|
|
1590
|
-
return t[
|
|
1740
|
+
const h = g.diff(n._end, n._start, "hour") / 24;
|
|
1741
|
+
return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
|
|
1591
1742
|
};
|
|
1592
|
-
this.tasks.forEach((
|
|
1593
|
-
const o = t[
|
|
1594
|
-
|
|
1743
|
+
this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
|
|
1744
|
+
const o = t[n.id], a = o.ls - o.es;
|
|
1745
|
+
n._is_critical = Math.abs(a) < 0.01;
|
|
1595
1746
|
});
|
|
1596
1747
|
}
|
|
1597
1748
|
update_arrow_critical_path() {
|
|
@@ -1620,9 +1771,9 @@ class I {
|
|
|
1620
1771
|
else {
|
|
1621
1772
|
if (t === "today")
|
|
1622
1773
|
return this.scroll_current();
|
|
1623
|
-
typeof t == "string" && (t =
|
|
1774
|
+
typeof t == "string" && (t = g.parse(t));
|
|
1624
1775
|
}
|
|
1625
|
-
const i =
|
|
1776
|
+
const i = g.diff(
|
|
1626
1777
|
t,
|
|
1627
1778
|
this.gantt_start,
|
|
1628
1779
|
this.config.unit
|
|
@@ -1630,27 +1781,27 @@ class I {
|
|
|
1630
1781
|
this.$container.scrollTo({
|
|
1631
1782
|
left: i - this.config.column_width / 6,
|
|
1632
1783
|
behavior: "smooth"
|
|
1633
|
-
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date =
|
|
1784
|
+
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date = g.add(
|
|
1634
1785
|
this.gantt_start,
|
|
1635
1786
|
this.$container.scrollLeft / this.config.column_width,
|
|
1636
1787
|
this.config.unit
|
|
1637
1788
|
);
|
|
1638
|
-
let
|
|
1789
|
+
let s = this.config.view_mode.upper_text(
|
|
1639
1790
|
this.current_date,
|
|
1640
1791
|
null,
|
|
1641
1792
|
this.options.language
|
|
1642
|
-
),
|
|
1643
|
-
(o) => o.textContent ===
|
|
1793
|
+
), n = this.upperTexts.find(
|
|
1794
|
+
(o) => o.textContent === s
|
|
1644
1795
|
);
|
|
1645
|
-
this.current_date =
|
|
1796
|
+
this.current_date = g.add(
|
|
1646
1797
|
this.gantt_start,
|
|
1647
|
-
(this.$container.scrollLeft +
|
|
1798
|
+
(this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
|
|
1648
1799
|
this.config.unit
|
|
1649
|
-
),
|
|
1800
|
+
), s = this.config.view_mode.upper_text(
|
|
1650
1801
|
this.current_date,
|
|
1651
1802
|
null,
|
|
1652
1803
|
this.options.language
|
|
1653
|
-
),
|
|
1804
|
+
), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
|
|
1654
1805
|
}
|
|
1655
1806
|
scroll_current() {
|
|
1656
1807
|
let t = this.get_closest_date();
|
|
@@ -1660,27 +1811,27 @@ class I {
|
|
|
1660
1811
|
let t = /* @__PURE__ */ new Date();
|
|
1661
1812
|
if (t < this.gantt_start || t > this.gantt_end) return null;
|
|
1662
1813
|
let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
|
|
1663
|
-
".date_" +
|
|
1664
|
-
|
|
1814
|
+
".date_" + D(
|
|
1815
|
+
g.format(
|
|
1665
1816
|
e,
|
|
1666
1817
|
this.config.date_format,
|
|
1667
1818
|
this.options.language
|
|
1668
1819
|
)
|
|
1669
1820
|
)
|
|
1670
|
-
),
|
|
1671
|
-
for (; !i &&
|
|
1672
|
-
e =
|
|
1673
|
-
".date_" +
|
|
1674
|
-
|
|
1821
|
+
), s = 0;
|
|
1822
|
+
for (; !i && s < this.config.step; )
|
|
1823
|
+
e = g.add(e, -1, this.config.unit), i = this.$container.querySelector(
|
|
1824
|
+
".date_" + D(
|
|
1825
|
+
g.format(
|
|
1675
1826
|
e,
|
|
1676
1827
|
this.config.date_format,
|
|
1677
1828
|
this.options.language
|
|
1678
1829
|
)
|
|
1679
1830
|
)
|
|
1680
|
-
),
|
|
1831
|
+
), s++;
|
|
1681
1832
|
return [
|
|
1682
1833
|
/* @__PURE__ */ new Date(
|
|
1683
|
-
|
|
1834
|
+
g.format(
|
|
1684
1835
|
e,
|
|
1685
1836
|
this.config.date_format,
|
|
1686
1837
|
this.options.language
|
|
@@ -1690,22 +1841,22 @@ class I {
|
|
|
1690
1841
|
];
|
|
1691
1842
|
}
|
|
1692
1843
|
bind_grid_click() {
|
|
1693
|
-
|
|
1844
|
+
m.on(
|
|
1694
1845
|
this.$container,
|
|
1695
1846
|
"click",
|
|
1696
1847
|
".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
|
|
1697
1848
|
(t, e) => {
|
|
1698
1849
|
if (e && e.classList.contains("grid-row")) {
|
|
1699
|
-
const i = this.$svg,
|
|
1700
|
-
|
|
1701
|
-
const
|
|
1850
|
+
const i = this.$svg, s = i.createSVGPoint();
|
|
1851
|
+
s.x = t.clientX, s.y = t.clientY;
|
|
1852
|
+
const n = s.matrixTransform(i.getScreenCTM().inverse()), o = this.options.bar_height + this.options.padding, a = Math.floor((n.y - this.config.header_height) / o), h = this.tasks[a];
|
|
1702
1853
|
if (h && h._has_no_dates) {
|
|
1703
|
-
const d =
|
|
1854
|
+
const d = n.x / this.config.column_width, _ = Math.floor(d * this.config.step), c = g.add(
|
|
1704
1855
|
this.gantt_start,
|
|
1705
1856
|
_,
|
|
1706
1857
|
this.config.unit
|
|
1707
1858
|
);
|
|
1708
|
-
h._start =
|
|
1859
|
+
h._start = c, h._end = g.add(c, 1, "day"), h.start = c, h.end = h._end, delete h._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
|
|
1709
1860
|
h,
|
|
1710
1861
|
h._start,
|
|
1711
1862
|
h._end
|
|
@@ -1728,104 +1879,98 @@ class I {
|
|
|
1728
1879
|
".label_" + e.classList[1]
|
|
1729
1880
|
);
|
|
1730
1881
|
if (!i) continue;
|
|
1731
|
-
let
|
|
1732
|
-
e.onmouseenter = (
|
|
1733
|
-
|
|
1734
|
-
i.classList.add("show"), i.style.left = (
|
|
1882
|
+
let s;
|
|
1883
|
+
e.onmouseenter = (n) => {
|
|
1884
|
+
s = setTimeout(() => {
|
|
1885
|
+
i.classList.add("show"), i.style.left = (n.offsetX || n.layerX) + "px", i.style.top = (n.offsetY || n.layerY) + "px";
|
|
1735
1886
|
}, 300);
|
|
1736
|
-
}, e.onmouseleave = (
|
|
1737
|
-
clearTimeout(
|
|
1887
|
+
}, e.onmouseleave = (n) => {
|
|
1888
|
+
clearTimeout(s), i.classList.remove("show");
|
|
1738
1889
|
};
|
|
1739
1890
|
}
|
|
1740
1891
|
}
|
|
1741
1892
|
get_start_end_positions() {
|
|
1742
1893
|
if (!this.bars.length) return [0, 0, 0];
|
|
1743
|
-
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t,
|
|
1894
|
+
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
|
|
1744
1895
|
return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
|
|
1745
1896
|
let { x: h, width: d } = o.getBBox();
|
|
1746
|
-
h < i && (i = h), h >
|
|
1747
|
-
}), [i,
|
|
1897
|
+
h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
|
|
1898
|
+
}), [i, s, n];
|
|
1748
1899
|
}
|
|
1749
1900
|
bind_bar_events() {
|
|
1750
|
-
let t = !1, e = 0, i = 0,
|
|
1901
|
+
let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
|
|
1751
1902
|
this.bar_being_dragged = null;
|
|
1752
|
-
const h = () => t ||
|
|
1903
|
+
const h = () => t || s || n;
|
|
1753
1904
|
this.$svg.onclick = (_) => {
|
|
1754
1905
|
_.target.classList.contains("grid-row") && this.unselect_all();
|
|
1755
1906
|
};
|
|
1756
1907
|
let d = 0;
|
|
1757
|
-
if (
|
|
1908
|
+
if (m.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
|
|
1758
1909
|
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
|
|
1759
|
-
}),
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
this.options.move_dependencies && w === "fixed" ? f = [
|
|
1765
|
-
o,
|
|
1766
|
-
...this.get_all_dependent_tasks(o)
|
|
1767
|
-
] : f = [o], a = f.map((b) => this.get_bar(b)), this.bar_being_dragged = !1, d = e, a.forEach((b) => {
|
|
1768
|
-
const $ = b.$bar;
|
|
1769
|
-
$.ox = $.getX(), $.oy = $.getY(), $.owidth = $.getWidth(), $.finaldx = 0;
|
|
1910
|
+
}), m.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, c) => {
|
|
1911
|
+
const p = m.closest(".bar-wrapper", c);
|
|
1912
|
+
c.classList.contains("left") ? (s = !0, c.classList.add("visible")) : c.classList.contains("right") ? (n = !0, c.classList.add("visible")) : c.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = p.getAttribute("data-id"), a = [this.get_bar(o)], this.bar_being_dragged = !1, d = e, a.forEach((l) => {
|
|
1913
|
+
const f = l.$bar;
|
|
1914
|
+
f.ox = f.getX(), f.oy = f.getY(), f.owidth = f.getWidth(), f.finaldx = 0;
|
|
1770
1915
|
});
|
|
1771
1916
|
}), this.options.infinite_padding) {
|
|
1772
1917
|
let _ = !1;
|
|
1773
|
-
|
|
1774
|
-
let
|
|
1775
|
-
if (!_ &&
|
|
1776
|
-
let
|
|
1777
|
-
_ = !0, this.gantt_start =
|
|
1918
|
+
m.on(this.$container, "mousewheel", (c) => {
|
|
1919
|
+
let p = this.$container.scrollWidth / 2;
|
|
1920
|
+
if (!_ && c.currentTarget.scrollLeft <= p) {
|
|
1921
|
+
let l = c.currentTarget.scrollLeft;
|
|
1922
|
+
_ = !0, this.gantt_start = g.add(
|
|
1778
1923
|
this.gantt_start,
|
|
1779
1924
|
-this.config.extend_by_units,
|
|
1780
1925
|
this.config.unit
|
|
1781
|
-
), this.setup_date_values(), this.render(),
|
|
1926
|
+
), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
|
|
1782
1927
|
}
|
|
1783
|
-
if (!_ &&
|
|
1784
|
-
let
|
|
1785
|
-
_ = !0, this.gantt_end =
|
|
1928
|
+
if (!_ && c.currentTarget.scrollWidth - (c.currentTarget.scrollLeft + c.currentTarget.clientWidth) <= p) {
|
|
1929
|
+
let l = c.currentTarget.scrollLeft;
|
|
1930
|
+
_ = !0, this.gantt_end = g.add(
|
|
1786
1931
|
this.gantt_end,
|
|
1787
1932
|
this.config.extend_by_units,
|
|
1788
1933
|
this.config.unit
|
|
1789
|
-
), this.setup_date_values(), this.render(),
|
|
1934
|
+
), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l, setTimeout(() => _ = !1, 300);
|
|
1790
1935
|
}
|
|
1791
1936
|
});
|
|
1792
1937
|
}
|
|
1793
|
-
|
|
1938
|
+
m.on(this.$container, "scroll", (_) => {
|
|
1794
1939
|
this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = _.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
1795
1940
|
this._syncing_scroll = !1;
|
|
1796
1941
|
}));
|
|
1797
|
-
let
|
|
1798
|
-
const
|
|
1799
|
-
({ group:
|
|
1942
|
+
let c = [];
|
|
1943
|
+
const p = this.bars.map(
|
|
1944
|
+
({ group: $ }) => $.getAttribute("data-id")
|
|
1800
1945
|
);
|
|
1801
|
-
let
|
|
1802
|
-
i && (
|
|
1946
|
+
let l;
|
|
1947
|
+
i && (l = _.currentTarget.scrollLeft - i), this.current_date = g.add(
|
|
1803
1948
|
this.gantt_start,
|
|
1804
1949
|
_.currentTarget.scrollLeft / this.config.column_width * this.config.step,
|
|
1805
1950
|
this.config.unit
|
|
1806
1951
|
);
|
|
1807
|
-
let
|
|
1952
|
+
let f = this.config.view_mode.upper_text(
|
|
1808
1953
|
this.current_date,
|
|
1809
1954
|
null,
|
|
1810
1955
|
this.options.language
|
|
1811
|
-
),
|
|
1812
|
-
(
|
|
1956
|
+
), u = this.upperTexts.find(
|
|
1957
|
+
($) => $.textContent === f
|
|
1813
1958
|
);
|
|
1814
|
-
this.current_date =
|
|
1959
|
+
this.current_date = g.add(
|
|
1815
1960
|
this.gantt_start,
|
|
1816
|
-
(_.currentTarget.scrollLeft +
|
|
1961
|
+
(_.currentTarget.scrollLeft + u.clientWidth) / this.config.column_width * this.config.step,
|
|
1817
1962
|
this.config.unit
|
|
1818
|
-
),
|
|
1963
|
+
), f = this.config.view_mode.upper_text(
|
|
1819
1964
|
this.current_date,
|
|
1820
1965
|
null,
|
|
1821
1966
|
this.options.language
|
|
1822
|
-
),
|
|
1823
|
-
(
|
|
1824
|
-
),
|
|
1825
|
-
let [b,
|
|
1826
|
-
i >
|
|
1967
|
+
), u = this.upperTexts.find(
|
|
1968
|
+
($) => $.textContent === f
|
|
1969
|
+
), u !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), u.classList.add("current-upper"), this.$current = u), i = _.currentTarget.scrollLeft;
|
|
1970
|
+
let [b, y, k] = this.get_start_end_positions();
|
|
1971
|
+
i > k + 100 ? (this.$adjust.innerHTML = "←", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1827
1972
|
this.$container.scrollTo({
|
|
1828
|
-
left:
|
|
1973
|
+
left: y,
|
|
1829
1974
|
behavior: "smooth"
|
|
1830
1975
|
});
|
|
1831
1976
|
}) : i + _.currentTarget.offsetWidth < b - 100 ? (this.$adjust.innerHTML = "→", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
@@ -1833,171 +1978,157 @@ class I {
|
|
|
1833
1978
|
left: b,
|
|
1834
1979
|
behavior: "smooth"
|
|
1835
1980
|
});
|
|
1836
|
-
}) : this.$adjust.classList.add("hide"),
|
|
1837
|
-
|
|
1838
|
-
x:
|
|
1981
|
+
}) : this.$adjust.classList.add("hide"), l && (c = p.map(($) => this.get_bar($)), this.options.auto_move_label && c.forEach(($) => {
|
|
1982
|
+
$.update_label_position_on_horizontal_scroll({
|
|
1983
|
+
x: l,
|
|
1839
1984
|
sx: _.currentTarget.scrollLeft
|
|
1840
1985
|
});
|
|
1841
1986
|
}));
|
|
1842
|
-
}),
|
|
1987
|
+
}), m.on(this.$svg, "mousemove", (_) => {
|
|
1843
1988
|
if (!h()) return;
|
|
1844
|
-
const
|
|
1845
|
-
a.forEach((
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
x:
|
|
1849
|
-
width:
|
|
1850
|
-
}) :
|
|
1851
|
-
x:
|
|
1852
|
-
}) :
|
|
1853
|
-
width:
|
|
1854
|
-
}) : t && !this.options.readonly && !this.options.readonly_dates &&
|
|
1989
|
+
const c = (_.offsetX || _.layerX) - e;
|
|
1990
|
+
a.forEach((p) => {
|
|
1991
|
+
const l = p.$bar;
|
|
1992
|
+
l.finaldx = this.get_snap_position(c, l.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
|
|
1993
|
+
x: l.ox + l.finaldx,
|
|
1994
|
+
width: l.owidth - l.finaldx
|
|
1995
|
+
}) : p.update_bar_position({
|
|
1996
|
+
x: l.ox + l.finaldx
|
|
1997
|
+
}) : n ? o === p.task.id && p.update_bar_position({
|
|
1998
|
+
width: l.owidth + l.finaldx
|
|
1999
|
+
}) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: l.ox + l.finaldx });
|
|
1855
2000
|
});
|
|
1856
2001
|
}), document.addEventListener("mouseup", () => {
|
|
1857
|
-
var
|
|
2002
|
+
var p, l, f;
|
|
1858
2003
|
const _ = this.bar_being_dragged === !0;
|
|
1859
2004
|
this.bar_being_dragged = null;
|
|
1860
|
-
const
|
|
1861
|
-
a.forEach((
|
|
1862
|
-
if (!
|
|
1863
|
-
_ &&
|
|
2005
|
+
const c = [];
|
|
2006
|
+
if (a.forEach((u) => {
|
|
2007
|
+
if (!u.$bar.finaldx) {
|
|
2008
|
+
_ && u.set_action_completed();
|
|
1864
2009
|
return;
|
|
1865
2010
|
}
|
|
1866
|
-
|
|
1867
|
-
task:
|
|
1868
|
-
start:
|
|
1869
|
-
end:
|
|
2011
|
+
u.date_changed(), u.compute_progress(), u.set_action_completed(), c.push({
|
|
2012
|
+
task: u.task,
|
|
2013
|
+
start: u.task._start,
|
|
2014
|
+
end: g.add(u.task._end, -1, "second")
|
|
1870
2015
|
});
|
|
1871
|
-
}), this.options.critical_path && a.some((
|
|
1872
|
-
|
|
1873
|
-
|
|
2016
|
+
}), this.options.critical_path && a.some((u) => u.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), c.length > 0 && this.options.dependency_shifting !== "none") {
|
|
2017
|
+
const u = this.options.dependency_shifting;
|
|
2018
|
+
let b;
|
|
2019
|
+
s ? b = u === "maintain_buffer_downstream" ? "none" : "upstream" : n ? b = "downstream" : b = u === "maintain_buffer_downstream" ? "downstream" : "both", c.forEach(({ task: y }) => {
|
|
2020
|
+
if (b === "none") return;
|
|
2021
|
+
const k = a.find((T) => T.task.id === y.id);
|
|
2022
|
+
if (!k || !k.$bar.finaldx) return;
|
|
2023
|
+
const $ = k.$bar.finaldx / this.config.column_width, P = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, O = $ * this.config.step * P;
|
|
2024
|
+
I(
|
|
2025
|
+
this.tasks,
|
|
2026
|
+
y.id,
|
|
2027
|
+
O,
|
|
2028
|
+
this.options.dependency_shifting,
|
|
2029
|
+
b
|
|
2030
|
+
).forEach((T, N) => {
|
|
2031
|
+
const v = this.get_bar(N);
|
|
2032
|
+
if (!v) return;
|
|
2033
|
+
const M = v.task, j = new Date(M._start.getTime() + T), V = g.diff(j, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
|
|
2034
|
+
v.update_bar_position({ x: V }), v.update_arrow_position(), this.trigger_event("after_date_change", [
|
|
2035
|
+
M,
|
|
2036
|
+
M._start,
|
|
2037
|
+
g.add(M._end, -1, "second")
|
|
2038
|
+
]);
|
|
2039
|
+
});
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
c.length > 0 && c.forEach(({ task: u, start: b, end: y }) => {
|
|
2043
|
+
this.trigger_event("after_date_change", [u, b, y]);
|
|
2044
|
+
}), a.forEach((u) => {
|
|
2045
|
+
u.$bar.finaldx = 0;
|
|
2046
|
+
}), t = !1, s = !1, n = !1, (f = (l = (p = this.$container.querySelector(".visible")) == null ? void 0 : p.classList) == null ? void 0 : l.remove) == null || f.call(l, "visible");
|
|
1874
2047
|
}), this.bind_bar_progress();
|
|
1875
2048
|
}
|
|
1876
2049
|
bind_task_column_resize() {
|
|
1877
2050
|
if (!this.$task_column_resize_handle) return;
|
|
1878
2051
|
let t = !1, e = 0, i = 0;
|
|
1879
|
-
const
|
|
1880
|
-
|
|
2052
|
+
const s = 100, n = 600;
|
|
2053
|
+
m.on(this.$task_column_resize_handle, "mousedown", (o) => {
|
|
1881
2054
|
t = !0, e = o.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), o.preventDefault();
|
|
1882
|
-
}),
|
|
2055
|
+
}), m.on(document, "mousemove", (o) => {
|
|
1883
2056
|
if (!t) return;
|
|
1884
2057
|
let a = o.clientX - e;
|
|
1885
2058
|
this.options.isRTL && (a = -a);
|
|
1886
2059
|
let h = i + a;
|
|
1887
|
-
h = Math.max(
|
|
2060
|
+
h = Math.max(s, Math.min(n, h)), this.options.task_column.width = h, this.$task_column.style.width = h + "px", this.$wrapper.style.setProperty(
|
|
1888
2061
|
"--gv-task-column-width",
|
|
1889
2062
|
h + "px"
|
|
1890
2063
|
), this.$container.style.setProperty(
|
|
1891
2064
|
"--gv-task-column-width",
|
|
1892
2065
|
h + "px"
|
|
1893
2066
|
), this.trigger_event("task_column_resize", [h]);
|
|
1894
|
-
}),
|
|
2067
|
+
}), m.on(document, "mouseup", () => {
|
|
1895
2068
|
t && (t = !1, this.$task_column.classList.remove("resizing"), this.trigger_event("task_after_column_resize", [this.options.task_column.width]));
|
|
1896
2069
|
});
|
|
1897
2070
|
}
|
|
1898
2071
|
bind_task_column_scroll() {
|
|
1899
|
-
this.$task_column &&
|
|
2072
|
+
this.$task_column && m.on(this.$task_column, "scroll", (t) => {
|
|
1900
2073
|
this._syncing_scroll || (this._syncing_scroll = !0, this.$container.scrollTop = t.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
1901
2074
|
this._syncing_scroll = !1;
|
|
1902
2075
|
}));
|
|
1903
2076
|
});
|
|
1904
2077
|
}
|
|
1905
2078
|
bind_bar_progress() {
|
|
1906
|
-
let t = 0, e = null, i = null,
|
|
1907
|
-
|
|
2079
|
+
let t = 0, e = null, i = null, s = null, n = null;
|
|
2080
|
+
m.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
|
|
1908
2081
|
e = !0, t = a.offsetX || a.layerX;
|
|
1909
|
-
const _ =
|
|
1910
|
-
i = this.get_bar(_),
|
|
2082
|
+
const _ = m.closest(".bar-wrapper", h).getAttribute("data-id");
|
|
2083
|
+
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();
|
|
1911
2084
|
});
|
|
1912
2085
|
const o = this.config.ignored_positions.map((a) => [
|
|
1913
2086
|
a,
|
|
1914
2087
|
a + this.config.column_width
|
|
1915
2088
|
]);
|
|
1916
|
-
|
|
2089
|
+
m.on(this.$svg, "mousemove", (a) => {
|
|
1917
2090
|
if (!e) return;
|
|
1918
2091
|
let h = a.offsetX || a.layerX;
|
|
1919
2092
|
if (h > t) {
|
|
1920
|
-
let
|
|
1921
|
-
([
|
|
2093
|
+
let c = o.find(
|
|
2094
|
+
([p, l]) => h >= p && h < l
|
|
1922
2095
|
);
|
|
1923
|
-
for (;
|
|
1924
|
-
h =
|
|
1925
|
-
([
|
|
2096
|
+
for (; c; )
|
|
2097
|
+
h = c[1], c = o.find(
|
|
2098
|
+
([p, l]) => h >= p && h < l
|
|
1926
2099
|
);
|
|
1927
2100
|
} else {
|
|
1928
|
-
let
|
|
1929
|
-
([
|
|
2101
|
+
let c = o.find(
|
|
2102
|
+
([p, l]) => h > p && h <= l
|
|
1930
2103
|
);
|
|
1931
|
-
for (;
|
|
1932
|
-
h =
|
|
1933
|
-
([
|
|
2104
|
+
for (; c; )
|
|
2105
|
+
h = c[0], c = o.find(
|
|
2106
|
+
([p, l]) => h > p && h <= l
|
|
1934
2107
|
);
|
|
1935
2108
|
}
|
|
1936
2109
|
let _ = h - t;
|
|
1937
|
-
console.log(
|
|
1938
|
-
}),
|
|
1939
|
-
e = !1,
|
|
2110
|
+
console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), m.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
|
|
2111
|
+
}), m.on(this.$svg, "mouseup", () => {
|
|
2112
|
+
e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
|
|
1940
2113
|
});
|
|
1941
2114
|
}
|
|
1942
2115
|
get_all_dependent_tasks(t) {
|
|
1943
2116
|
let e = [], i = [t];
|
|
1944
2117
|
for (; i.length; ) {
|
|
1945
|
-
const
|
|
1946
|
-
e = e.concat(
|
|
2118
|
+
const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
|
|
2119
|
+
e = e.concat(s), i = s.filter((n) => !i.includes(n));
|
|
1947
2120
|
}
|
|
1948
2121
|
return e.filter(Boolean);
|
|
1949
2122
|
}
|
|
1950
|
-
update_dependent_tasks_by_type(t) {
|
|
1951
|
-
const e = t.task.dependencies_type || this.options.dependencies_type, i = [];
|
|
1952
|
-
return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((s) => {
|
|
1953
|
-
const o = this.get_bar(s);
|
|
1954
|
-
if (!o) return;
|
|
1955
|
-
const a = o.task, h = a.dependencies_type || this.options.dependencies_type;
|
|
1956
|
-
let d, _;
|
|
1957
|
-
const l = c.diff(a._end, a._start, "hour");
|
|
1958
|
-
let g = !1;
|
|
1959
|
-
switch (h) {
|
|
1960
|
-
case "finish-to-start":
|
|
1961
|
-
t.task._end > a._start && (d = new Date(t.task._end), _ = c.add(d, l, "hour"), g = !0);
|
|
1962
|
-
break;
|
|
1963
|
-
case "start-to-start":
|
|
1964
|
-
t.task._start > a._start && (d = new Date(t.task._start), _ = c.add(d, l, "hour"), g = !0);
|
|
1965
|
-
break;
|
|
1966
|
-
case "finish-to-finish":
|
|
1967
|
-
t.task._end > a._end && (_ = new Date(t.task._end), d = c.add(_, -l, "hour"), g = !0);
|
|
1968
|
-
break;
|
|
1969
|
-
case "start-to-finish":
|
|
1970
|
-
t.task._start > a._end && (_ = new Date(t.task._start), d = c.add(_, -l, "hour"), g = !0);
|
|
1971
|
-
break;
|
|
1972
|
-
default:
|
|
1973
|
-
return;
|
|
1974
|
-
}
|
|
1975
|
-
if (!g) return;
|
|
1976
|
-
a._start = d, a._end = _, o.compute_x(), o.compute_duration(), o.update_bar_position({
|
|
1977
|
-
x: o.x,
|
|
1978
|
-
width: o.width
|
|
1979
|
-
}), this.trigger_event("date_change", [
|
|
1980
|
-
a,
|
|
1981
|
-
d,
|
|
1982
|
-
c.add(_, -1, "second")
|
|
1983
|
-
]), i.push({
|
|
1984
|
-
task: a,
|
|
1985
|
-
start: d,
|
|
1986
|
-
end: c.add(_, -1, "second")
|
|
1987
|
-
});
|
|
1988
|
-
const p = this.update_dependent_tasks_by_type(o);
|
|
1989
|
-
i.push(...p);
|
|
1990
|
-
}), i;
|
|
1991
|
-
}
|
|
1992
2123
|
get_snap_position(t, e) {
|
|
1993
2124
|
let i = 1;
|
|
1994
|
-
const
|
|
1995
|
-
if (
|
|
1996
|
-
const { duration: _, scale:
|
|
1997
|
-
i =
|
|
2125
|
+
const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
|
|
2126
|
+
if (s !== "unit") {
|
|
2127
|
+
const { duration: _, scale: c } = g.parse_duration(s);
|
|
2128
|
+
i = g.convert_scales(this.config.view_mode.step, c) / _;
|
|
1998
2129
|
}
|
|
1999
|
-
const
|
|
2000
|
-
let o = t -
|
|
2130
|
+
const n = t % (this.config.column_width / i);
|
|
2131
|
+
let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
|
|
2001
2132
|
const h = o > 0 ? 1 : -1;
|
|
2002
2133
|
let d = this.get_ignored_region(a, h);
|
|
2003
2134
|
for (; d.length; )
|
|
@@ -2022,7 +2153,7 @@ class I {
|
|
|
2022
2153
|
return this.bars.find((e) => e.task.id === t);
|
|
2023
2154
|
}
|
|
2024
2155
|
show_popup(t) {
|
|
2025
|
-
this.options.popup !== !1 && (this.popup || (this.popup = new
|
|
2156
|
+
this.options.popup !== !1 && (this.popup || (this.popup = new K(
|
|
2026
2157
|
this.$popup_wrapper,
|
|
2027
2158
|
this.options.popup,
|
|
2028
2159
|
this
|
|
@@ -2051,25 +2182,25 @@ class I {
|
|
|
2051
2182
|
* @memberof Gantt
|
|
2052
2183
|
*/
|
|
2053
2184
|
clear() {
|
|
2054
|
-
var t, e, i,
|
|
2055
|
-
this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (
|
|
2185
|
+
var t, e, i, s, n, o, a, h, d, _, c, p, l, f, u, b;
|
|
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), (o = (n = this.$task_column) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$current_highlight) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.$extras) == null ? void 0 : d.remove) == null || _.call(d), (p = (c = this.popup) == null ? void 0 : c.hide) == null || p.call(c), (f = (l = this.$wrapper) == null ? void 0 : l.classList) == null || f.remove("has-task-column"), (b = (u = this.$wrapper) == null ? void 0 : u.classList) == null || b.remove("rtl");
|
|
2056
2187
|
}
|
|
2057
2188
|
}
|
|
2058
|
-
|
|
2059
|
-
HOUR:
|
|
2060
|
-
QUARTER_DAY:
|
|
2061
|
-
HALF_DAY:
|
|
2062
|
-
DAY:
|
|
2063
|
-
WEEK:
|
|
2064
|
-
MONTH:
|
|
2065
|
-
YEAR:
|
|
2189
|
+
tt.VIEW_MODE = {
|
|
2190
|
+
HOUR: x[0],
|
|
2191
|
+
QUARTER_DAY: x[1],
|
|
2192
|
+
HALF_DAY: x[2],
|
|
2193
|
+
DAY: x[3],
|
|
2194
|
+
WEEK: x[4],
|
|
2195
|
+
MONTH: x[5],
|
|
2196
|
+
YEAR: x[6]
|
|
2066
2197
|
};
|
|
2067
|
-
function
|
|
2198
|
+
function et(r) {
|
|
2068
2199
|
return r.name + "_" + Math.random().toString(36).slice(2, 12);
|
|
2069
2200
|
}
|
|
2070
|
-
function
|
|
2201
|
+
function D(r) {
|
|
2071
2202
|
return r.replaceAll(" ", "_").replaceAll(":", "_").replaceAll(".", "_");
|
|
2072
2203
|
}
|
|
2073
2204
|
export {
|
|
2074
|
-
|
|
2205
|
+
tt as default
|
|
2075
2206
|
};
|