@workiom/frappe-gantt 1.0.20 → 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 +8 -5
- package/dist/frappe-gantt.es.js +554 -544
- package/dist/frappe-gantt.umd.js +25 -25
- package/package.json +1 -1
- package/src/dependency_shifting.js +56 -33
- package/src/index.js +15 -0
package/dist/frappe-gantt.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second", W = "millisecond",
|
|
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,25 +22,25 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "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
45
|
MM: L(+a[1] + 1, 2, 0),
|
|
46
46
|
DD: a[2],
|
|
@@ -50,26 +50,26 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "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
|
|
@@ -106,11 +106,11 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
106
106
|
[X]: 1,
|
|
107
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
115
|
i(A) ? 0 : r.getMonth(),
|
|
116
116
|
i(E) ? 1 : r.getDate(),
|
|
@@ -119,7 +119,7 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
119
119
|
i(H) ? 0 : r.getSeconds(),
|
|
120
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 A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "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();
|
|
@@ -161,7 +161,7 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
|
|
|
161
161
|
function L(r, t, e) {
|
|
162
162
|
return r = r + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), r.length > t ? String(r) : (t = t - r.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(r));
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function m(r, t) {
|
|
165
165
|
return typeof r == "string" ? (t || document).querySelector(r) : r || null;
|
|
166
166
|
}
|
|
167
167
|
function w(r, t) {
|
|
@@ -171,37 +171,37 @@ function w(r, t) {
|
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
173
|
function z(r, t, e, i) {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
|
|
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
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,120 +210,123 @@ function V(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
|
-
function
|
|
241
|
+
function I(r, t, e, i, s = "downstream") {
|
|
242
242
|
if (i === "none" || e === 0) return /* @__PURE__ */ new Map();
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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: _ });
|
|
252
253
|
}
|
|
253
|
-
return i === "maintain_buffer_all" ? q(t, e,
|
|
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();
|
|
254
255
|
}
|
|
255
|
-
function q(r, t, e, i, n) {
|
|
256
|
-
const
|
|
257
|
-
for (const { id:
|
|
258
|
-
|
|
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));
|
|
259
260
|
};
|
|
260
|
-
for (
|
|
261
|
-
const
|
|
262
|
-
|
|
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(_) || []));
|
|
263
264
|
}
|
|
264
|
-
return
|
|
265
|
+
return o;
|
|
265
266
|
}
|
|
266
|
-
function
|
|
267
|
-
const
|
|
267
|
+
function R(r, t, e, i, s, n) {
|
|
268
|
+
const o = /* @__PURE__ */ new Map();
|
|
268
269
|
for (const [l] of e)
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
for (const [l,
|
|
272
|
-
|
|
273
|
-
for (;
|
|
274
|
-
const l =
|
|
275
|
-
|
|
276
|
-
for (const { id:
|
|
277
|
-
const
|
|
278
|
-
|
|
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);
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
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);
|
|
288
292
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
+
}
|
|
300
304
|
}
|
|
305
|
+
u < 0 && d.set(f, (d.get(f) || 0) + u);
|
|
301
306
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
l !== r && c !== 0 && g.set(l, c);
|
|
307
|
-
return g;
|
|
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;
|
|
308
311
|
}
|
|
309
|
-
function F(r, t, e, i,
|
|
310
|
-
const
|
|
312
|
+
function F(r, t, e, i, s) {
|
|
313
|
+
const n = i(r), o = s(r), a = i(t), h = s(t);
|
|
311
314
|
switch (e) {
|
|
312
315
|
case "finish-to-start":
|
|
313
316
|
return o > a ? o - a : 0;
|
|
314
317
|
case "start-to-start":
|
|
315
|
-
return
|
|
318
|
+
return n > a ? n - a : 0;
|
|
316
319
|
case "finish-to-finish":
|
|
317
320
|
return o > h ? o - h : 0;
|
|
318
321
|
case "start-to-finish":
|
|
319
|
-
return
|
|
322
|
+
return n > h ? n - h : 0;
|
|
320
323
|
default:
|
|
321
324
|
return o > a ? o - a : 0;
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
|
-
class
|
|
325
|
-
constructor(t, e, i,
|
|
326
|
-
this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type =
|
|
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();
|
|
327
330
|
}
|
|
328
331
|
check_critical_path() {
|
|
329
332
|
return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
|
|
@@ -343,18 +346,18 @@ class G {
|
|
|
343
346
|
return !1;
|
|
344
347
|
}
|
|
345
348
|
calculate_path() {
|
|
346
|
-
const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve,
|
|
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;
|
|
347
350
|
switch (this.dependency_type) {
|
|
348
351
|
case "finish-to-start":
|
|
349
352
|
this.path = this._path_finish_to_start(
|
|
350
|
-
|
|
353
|
+
n,
|
|
351
354
|
o,
|
|
352
355
|
a,
|
|
353
356
|
h,
|
|
354
357
|
_,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
+
c,
|
|
359
|
+
p,
|
|
360
|
+
s,
|
|
358
361
|
i
|
|
359
362
|
);
|
|
360
363
|
break;
|
|
@@ -363,18 +366,18 @@ class G {
|
|
|
363
366
|
o,
|
|
364
367
|
h,
|
|
365
368
|
_,
|
|
366
|
-
|
|
367
|
-
|
|
369
|
+
c,
|
|
370
|
+
s,
|
|
368
371
|
i
|
|
369
372
|
);
|
|
370
373
|
break;
|
|
371
374
|
case "finish-to-finish":
|
|
372
375
|
this.path = this._path_finish_to_finish(
|
|
373
|
-
|
|
376
|
+
n,
|
|
374
377
|
a,
|
|
375
378
|
_,
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
c,
|
|
380
|
+
s,
|
|
378
381
|
i
|
|
379
382
|
);
|
|
380
383
|
break;
|
|
@@ -383,84 +386,84 @@ class G {
|
|
|
383
386
|
o,
|
|
384
387
|
a,
|
|
385
388
|
_,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
+
c,
|
|
390
|
+
p,
|
|
391
|
+
s,
|
|
389
392
|
i
|
|
390
393
|
);
|
|
391
394
|
break;
|
|
392
395
|
default:
|
|
393
396
|
this.path = this._path_finish_to_start(
|
|
394
|
-
|
|
397
|
+
n,
|
|
395
398
|
o,
|
|
396
399
|
a,
|
|
397
400
|
h,
|
|
398
401
|
_,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
+
c,
|
|
403
|
+
p,
|
|
404
|
+
s,
|
|
402
405
|
i
|
|
403
406
|
);
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
|
-
_path_finish_to_start(t, e, i,
|
|
409
|
+
_path_finish_to_start(t, e, i, s, n, o, a, h, d) {
|
|
407
410
|
const _ = t + h;
|
|
408
|
-
if (_ <
|
|
411
|
+
if (_ < s)
|
|
409
412
|
return `
|
|
410
|
-
M ${t} ${
|
|
413
|
+
M ${t} ${n}
|
|
411
414
|
H ${_ - d}
|
|
412
415
|
a ${d} ${d} 0 0 1 ${d} ${d}
|
|
413
416
|
V ${o - d}
|
|
414
417
|
a ${d} ${d} 0 0 0 ${d} ${d}
|
|
415
|
-
H ${
|
|
418
|
+
H ${s}
|
|
416
419
|
m -5 -5 l 5 5 l -5 5`;
|
|
417
|
-
const
|
|
420
|
+
const c = s - h;
|
|
418
421
|
return `
|
|
419
|
-
M ${t} ${
|
|
422
|
+
M ${t} ${n}
|
|
420
423
|
H ${_ - d}
|
|
421
424
|
a ${d} ${d} 0 0 1 ${d} ${d}
|
|
422
425
|
V ${a - d}
|
|
423
426
|
a ${d} ${d} 0 0 1 ${-d} ${d}
|
|
424
|
-
H ${
|
|
427
|
+
H ${c + d}
|
|
425
428
|
a ${d} ${d} 0 0 0 ${-d} ${d}
|
|
426
429
|
V ${o - d}
|
|
427
430
|
a ${d} ${d} 0 0 0 ${d} ${d}
|
|
428
|
-
H ${
|
|
431
|
+
H ${s}
|
|
429
432
|
m -5 -5 l 5 5 l -5 5`;
|
|
430
433
|
}
|
|
431
|
-
_path_start_to_start(t, e, i,
|
|
432
|
-
const a = Math.min(t, e) -
|
|
434
|
+
_path_start_to_start(t, e, i, s, n, o) {
|
|
435
|
+
const a = Math.min(t, e) - n;
|
|
433
436
|
return `
|
|
434
437
|
M ${t} ${i}
|
|
435
438
|
H ${a + o}
|
|
436
439
|
a ${o} ${o} 0 0 0 ${-o} ${o}
|
|
437
|
-
V ${
|
|
440
|
+
V ${s - o}
|
|
438
441
|
a ${o} ${o} 0 0 0 ${o} ${o}
|
|
439
442
|
H ${e}
|
|
440
443
|
m -5 -5 l 5 5 l -5 5`;
|
|
441
444
|
}
|
|
442
|
-
_path_finish_to_finish(t, e, i,
|
|
443
|
-
const a = Math.max(t, e) +
|
|
445
|
+
_path_finish_to_finish(t, e, i, s, n, o) {
|
|
446
|
+
const a = Math.max(t, e) + n;
|
|
444
447
|
return `
|
|
445
448
|
M ${t} ${i}
|
|
446
449
|
H ${a - o}
|
|
447
450
|
a ${o} ${o} 0 0 1 ${o} ${o}
|
|
448
|
-
V ${
|
|
451
|
+
V ${s - o}
|
|
449
452
|
a ${o} ${o} 0 0 1 ${-o} ${o}
|
|
450
453
|
H ${e}
|
|
451
454
|
m 5 -5 l -5 5 l 5 5`;
|
|
452
455
|
}
|
|
453
|
-
_path_start_to_finish(t, e, i,
|
|
456
|
+
_path_start_to_finish(t, e, i, s, n, o, a) {
|
|
454
457
|
const h = t - o, d = e + o;
|
|
455
458
|
return `
|
|
456
459
|
M ${t} ${i}
|
|
457
460
|
H ${h + a}
|
|
458
461
|
a ${a} ${a} 0 0 0 ${-a} ${a}
|
|
459
|
-
V ${
|
|
462
|
+
V ${n - a}
|
|
460
463
|
a ${a} ${a} 0 0 0 ${a} ${a}
|
|
461
464
|
H ${d - a}
|
|
462
465
|
a ${a} ${a} 0 0 1 ${a} ${a}
|
|
463
|
-
V ${
|
|
466
|
+
V ${s - a}
|
|
464
467
|
a ${a} ${a} 0 0 1 ${-a} ${a}
|
|
465
468
|
H ${e}
|
|
466
469
|
m 5 -5 l -5 5 l 5 5`;
|
|
@@ -490,8 +493,8 @@ class G {
|
|
|
490
493
|
this.is_hovered = !0, this.element.classList.add("arrow-hover");
|
|
491
494
|
const e = this.is_invalid ? "bar-arrow-invalid" : this.is_critical ? "bar-arrow-critical" : "bar-arrow-hover";
|
|
492
495
|
this._get_connected_bars().forEach((i) => {
|
|
493
|
-
const
|
|
494
|
-
|
|
496
|
+
const s = i.querySelector(".bar");
|
|
497
|
+
s && s.classList.add(e);
|
|
495
498
|
});
|
|
496
499
|
}), this.hit_element.addEventListener("mouseleave", () => {
|
|
497
500
|
this.is_hovered = !1, this.element.classList.remove("arrow-hover"), this._get_connected_bars().forEach((e) => {
|
|
@@ -506,7 +509,7 @@ class G {
|
|
|
506
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());
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
|
-
class
|
|
512
|
+
class Q {
|
|
510
513
|
constructor(t, e) {
|
|
511
514
|
this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
|
|
512
515
|
}
|
|
@@ -593,7 +596,7 @@ class R {
|
|
|
593
596
|
class: "bar-progress",
|
|
594
597
|
append_to: this.bar_group
|
|
595
598
|
}), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
|
|
596
|
-
const e =
|
|
599
|
+
const e = g.diff(
|
|
597
600
|
this.task._start,
|
|
598
601
|
this.gantt.gantt_start,
|
|
599
602
|
this.gantt.config.unit
|
|
@@ -608,17 +611,17 @@ class R {
|
|
|
608
611
|
}
|
|
609
612
|
calculate_progress_width() {
|
|
610
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;
|
|
611
|
-
let
|
|
612
|
-
const
|
|
613
|
-
|
|
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;
|
|
614
617
|
let a = this.gantt.get_ignored_region(
|
|
615
|
-
this.x +
|
|
618
|
+
this.x + s
|
|
616
619
|
);
|
|
617
620
|
for (; a.length; )
|
|
618
|
-
|
|
619
|
-
this.x +
|
|
621
|
+
s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
|
|
622
|
+
this.x + s
|
|
620
623
|
);
|
|
621
|
-
return this.progress_width =
|
|
624
|
+
return this.progress_width = s, s;
|
|
622
625
|
}
|
|
623
626
|
draw_label() {
|
|
624
627
|
let t = this.x + this.$bar.getWidth() / 2;
|
|
@@ -633,7 +636,7 @@ class R {
|
|
|
633
636
|
}), this.task.color_text && (this.$bar_label.style.fill = this.task.color_text), requestAnimationFrame(() => this.update_label_position());
|
|
634
637
|
}
|
|
635
638
|
draw_thumbnail() {
|
|
636
|
-
let t = 10, e = 2, i,
|
|
639
|
+
let t = 10, e = 2, i, s;
|
|
637
640
|
i = w("defs", {
|
|
638
641
|
append_to: this.bar_group
|
|
639
642
|
}), w("rect", {
|
|
@@ -645,12 +648,12 @@ class R {
|
|
|
645
648
|
rx: "15",
|
|
646
649
|
class: "img_mask",
|
|
647
650
|
append_to: i
|
|
648
|
-
}),
|
|
651
|
+
}), s = w("clipPath", {
|
|
649
652
|
id: "clip_" + this.task.id,
|
|
650
653
|
append_to: i
|
|
651
654
|
}), w("use", {
|
|
652
655
|
href: "#rect_" + this.task.id,
|
|
653
|
-
append_to:
|
|
656
|
+
append_to: s
|
|
654
657
|
}), w("image", {
|
|
655
658
|
x: this.x + t,
|
|
656
659
|
y: this.y + e,
|
|
@@ -671,39 +674,39 @@ class R {
|
|
|
671
674
|
i = this.x + this.$bar.getWidth() + 5;
|
|
672
675
|
else
|
|
673
676
|
return;
|
|
674
|
-
const
|
|
677
|
+
const s = this.y + (this.height - 20) / 2;
|
|
675
678
|
this.$add_icon_group = w("g", {
|
|
676
679
|
class: "add-task-icon hide",
|
|
677
680
|
append_to: this.handle_group
|
|
678
681
|
}), this.$add_icon_circle = w("circle", {
|
|
679
682
|
cx: i + 20 / 2,
|
|
680
|
-
cy:
|
|
683
|
+
cy: s + 20 / 2,
|
|
681
684
|
r: 20 / 2,
|
|
682
685
|
class: "add-task-icon-bg",
|
|
683
686
|
append_to: this.$add_icon_group
|
|
684
687
|
}), this.$add_icon_vertical = w("line", {
|
|
685
688
|
x1: i + 20 / 2,
|
|
686
|
-
y1:
|
|
689
|
+
y1: s + 5,
|
|
687
690
|
x2: i + 20 / 2,
|
|
688
|
-
y2:
|
|
691
|
+
y2: s + 20 - 5,
|
|
689
692
|
class: "add-task-icon-plus",
|
|
690
693
|
append_to: this.$add_icon_group
|
|
691
694
|
}), this.$add_icon_horizontal = w("line", {
|
|
692
695
|
x1: i + 5,
|
|
693
|
-
y1:
|
|
696
|
+
y1: s + 20 / 2,
|
|
694
697
|
x2: i + 20 - 5,
|
|
695
|
-
y2:
|
|
698
|
+
y2: s + 20 / 2,
|
|
696
699
|
class: "add-task-icon-plus",
|
|
697
700
|
append_to: this.$add_icon_group
|
|
698
|
-
}),
|
|
699
|
-
|
|
700
|
-
}),
|
|
701
|
-
|
|
702
|
-
}),
|
|
703
|
-
|
|
704
|
-
}),
|
|
705
|
-
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"),
|
|
706
|
-
}),
|
|
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", () => {
|
|
707
710
|
this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
|
|
708
711
|
});
|
|
709
712
|
}
|
|
@@ -743,102 +746,102 @@ class R {
|
|
|
743
746
|
}), this.handles.push(this.$handle_progress);
|
|
744
747
|
}
|
|
745
748
|
for (let i of this.handles)
|
|
746
|
-
|
|
749
|
+
m.on(i, "mouseenter", () => i.classList.add("active")), m.on(i, "mouseleave", () => i.classList.remove("active"));
|
|
747
750
|
}
|
|
748
751
|
bind() {
|
|
749
752
|
this.invalid || this.setup_click_event();
|
|
750
753
|
}
|
|
751
754
|
unbind() {
|
|
752
755
|
this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
|
|
753
|
-
|
|
756
|
+
m.off(this.group, t, e);
|
|
754
757
|
}), this.event_listeners = []);
|
|
755
758
|
}
|
|
756
759
|
setup_click_event() {
|
|
757
760
|
this.event_listeners = [];
|
|
758
761
|
let t = this.task.id;
|
|
759
|
-
const e = (
|
|
762
|
+
const e = (p) => {
|
|
760
763
|
this.gantt.trigger_event("hover", [
|
|
761
764
|
this.task,
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
+
p.screenX,
|
|
766
|
+
p.screenY,
|
|
767
|
+
p
|
|
765
768
|
]);
|
|
766
769
|
};
|
|
767
|
-
if (
|
|
768
|
-
const
|
|
769
|
-
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;
|
|
770
773
|
if (this.$handle_progress) {
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
774
|
+
const u = +this.$handle_progress.getAttribute("cx");
|
|
775
|
+
if (u > f - 1 && u < f + 1 || this.gantt.bar_being_dragged) return;
|
|
773
776
|
}
|
|
774
777
|
this.gantt.show_popup({
|
|
775
|
-
x:
|
|
776
|
-
y:
|
|
778
|
+
x: l.offsetX || l.layerX,
|
|
779
|
+
y: l.offsetY || l.layerY,
|
|
777
780
|
task: this.task,
|
|
778
781
|
target: this.$bar
|
|
779
782
|
});
|
|
780
783
|
};
|
|
781
|
-
|
|
784
|
+
m.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
|
|
782
785
|
}
|
|
783
786
|
let i;
|
|
784
|
-
const
|
|
787
|
+
const s = (p) => {
|
|
785
788
|
i = setTimeout(() => {
|
|
786
789
|
this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
|
|
787
|
-
x:
|
|
788
|
-
y:
|
|
790
|
+
x: p.offsetX || p.layerX,
|
|
791
|
+
y: p.offsetY || p.layerY,
|
|
789
792
|
task: this.task,
|
|
790
793
|
target: this.$bar
|
|
791
794
|
});
|
|
792
|
-
const
|
|
793
|
-
|
|
795
|
+
const l = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
|
|
796
|
+
l && l.classList.remove("hide");
|
|
794
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"));
|
|
795
798
|
};
|
|
796
|
-
|
|
797
|
-
const
|
|
798
|
-
var
|
|
799
|
-
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((
|
|
800
|
-
const
|
|
801
|
-
|
|
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(() => {
|
|
802
805
|
this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
|
|
803
806
|
}, 200));
|
|
804
807
|
};
|
|
805
|
-
|
|
808
|
+
m.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
|
|
806
809
|
const o = () => {
|
|
807
810
|
this.is_dragging = !0, this.hide_add_icon();
|
|
808
811
|
};
|
|
809
|
-
|
|
812
|
+
m.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
|
|
810
813
|
const a = () => {
|
|
811
814
|
setTimeout(() => {
|
|
812
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"));
|
|
813
816
|
}, 0);
|
|
814
817
|
};
|
|
815
|
-
|
|
818
|
+
m.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
|
|
816
819
|
const h = () => {
|
|
817
820
|
this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
|
|
818
821
|
};
|
|
819
|
-
|
|
822
|
+
m.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
|
|
820
823
|
const d = () => {
|
|
821
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]));
|
|
822
825
|
};
|
|
823
|
-
|
|
826
|
+
m.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
|
|
824
827
|
let _ = !1;
|
|
825
|
-
const
|
|
828
|
+
const c = (p) => {
|
|
826
829
|
if (!_)
|
|
827
830
|
return _ = !0, setTimeout(function() {
|
|
828
831
|
_ = !1;
|
|
829
832
|
}, 300), !1;
|
|
830
|
-
|
|
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]));
|
|
831
834
|
};
|
|
832
|
-
|
|
835
|
+
m.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
|
|
833
836
|
}
|
|
834
837
|
update_bar_position({ x: t = null, width: e = null }) {
|
|
835
838
|
const i = this.$bar;
|
|
836
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();
|
|
837
840
|
}
|
|
838
841
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
|
839
|
-
const i = this.gantt.$container,
|
|
840
|
-
let a = this.$bar.getX() + this.$bar.getWidth(), h =
|
|
841
|
-
|
|
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)));
|
|
842
845
|
}
|
|
843
846
|
date_changed() {
|
|
844
847
|
let t = !1;
|
|
@@ -846,7 +849,7 @@ class R {
|
|
|
846
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", [
|
|
847
850
|
this.task,
|
|
848
851
|
e,
|
|
849
|
-
|
|
852
|
+
g.add(i, -1, "second")
|
|
850
853
|
]);
|
|
851
854
|
}
|
|
852
855
|
progress_changed() {
|
|
@@ -860,32 +863,32 @@ class R {
|
|
|
860
863
|
}
|
|
861
864
|
compute_start_end_date() {
|
|
862
865
|
const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
|
|
863
|
-
let i =
|
|
866
|
+
let i = g.add(
|
|
864
867
|
this.gantt.gantt_start,
|
|
865
868
|
e * this.gantt.config.step,
|
|
866
869
|
this.gantt.config.unit
|
|
867
870
|
);
|
|
868
|
-
const
|
|
871
|
+
const s = t.getWidth() / this.gantt.config.column_width, n = g.add(
|
|
869
872
|
i,
|
|
870
|
-
|
|
873
|
+
s * this.gantt.config.step,
|
|
871
874
|
this.gantt.config.unit
|
|
872
875
|
);
|
|
873
|
-
return { new_start_date: i, new_end_date:
|
|
876
|
+
return { new_start_date: i, new_end_date: n };
|
|
874
877
|
}
|
|
875
878
|
compute_progress() {
|
|
876
879
|
this.progress_width = this.$bar_progress.getWidth(), this.x = this.$bar_progress.getBBox().x;
|
|
877
|
-
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;
|
|
878
881
|
if (e < 0) return 0;
|
|
879
882
|
const i = this.$bar.getWidth() - this.ignored_duration_raw * this.gantt.config.column_width;
|
|
880
883
|
return parseInt(e / i * 100, 10);
|
|
881
884
|
}
|
|
882
885
|
compute_expected_progress() {
|
|
883
|
-
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;
|
|
884
887
|
}
|
|
885
888
|
compute_x() {
|
|
886
889
|
const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
|
|
887
|
-
let
|
|
888
|
-
this.x =
|
|
890
|
+
let n = g.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
|
|
891
|
+
this.x = n;
|
|
889
892
|
}
|
|
890
893
|
compute_y() {
|
|
891
894
|
this.y = this.gantt.config.header_height + this.gantt.options.padding / 2 + this.task._index * (this.height + this.gantt.options.padding);
|
|
@@ -894,12 +897,12 @@ class R {
|
|
|
894
897
|
let t = 0, e = 0;
|
|
895
898
|
for (let i = new Date(this.task._start); i < this.task._end; i.setDate(i.getDate() + 1))
|
|
896
899
|
e++, !this.gantt.config.ignored_dates.find(
|
|
897
|
-
(
|
|
900
|
+
(s) => s.getTime() === i.getTime()
|
|
898
901
|
) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
|
|
899
|
-
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(
|
|
900
903
|
e + "d",
|
|
901
904
|
this.gantt.config.unit
|
|
902
|
-
) / this.gantt.config.step, this.actual_duration_raw =
|
|
905
|
+
) / this.gantt.config.step, this.actual_duration_raw = g.convert_scales(
|
|
903
906
|
t + "d",
|
|
904
907
|
this.gantt.config.unit
|
|
905
908
|
) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
|
|
@@ -920,10 +923,10 @@ class R {
|
|
|
920
923
|
));
|
|
921
924
|
}
|
|
922
925
|
update_label_position() {
|
|
923
|
-
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"),
|
|
924
|
-
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;
|
|
925
928
|
const a = i.getBBox().width, h = e.getWidth();
|
|
926
|
-
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(
|
|
927
930
|
"x",
|
|
928
931
|
e.getX() + h / 2 + o
|
|
929
932
|
)) : i.setAttribute(
|
|
@@ -948,8 +951,8 @@ class R {
|
|
|
948
951
|
i = this.x + this.$bar.getWidth() + e;
|
|
949
952
|
else
|
|
950
953
|
return;
|
|
951
|
-
const
|
|
952
|
-
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);
|
|
953
956
|
}
|
|
954
957
|
hide_add_icon() {
|
|
955
958
|
this.$add_icon_group && this.$add_icon_group.classList.add("hide");
|
|
@@ -960,7 +963,7 @@ class R {
|
|
|
960
963
|
t.update();
|
|
961
964
|
}
|
|
962
965
|
}
|
|
963
|
-
class
|
|
966
|
+
class K {
|
|
964
967
|
constructor(t, e, i) {
|
|
965
968
|
this.parent = t, this.popup_func = e, this.gantt = i, this.make();
|
|
966
969
|
}
|
|
@@ -972,9 +975,9 @@ class U {
|
|
|
972
975
|
<div class="actions"></div>
|
|
973
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");
|
|
974
977
|
}
|
|
975
|
-
show({ x: t, y: e, task: i, target:
|
|
978
|
+
show({ x: t, y: e, task: i, target: s }) {
|
|
976
979
|
this.actions.innerHTML = "";
|
|
977
|
-
let
|
|
980
|
+
let n = this.popup_func({
|
|
978
981
|
task: i,
|
|
979
982
|
chart: this.gantt,
|
|
980
983
|
get_title: () => this.title,
|
|
@@ -992,7 +995,7 @@ class U {
|
|
|
992
995
|
typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
|
|
993
996
|
}
|
|
994
997
|
});
|
|
995
|
-
|
|
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"));
|
|
996
999
|
}
|
|
997
1000
|
hide() {
|
|
998
1001
|
this.parent.classList.add("hide");
|
|
@@ -1002,18 +1005,18 @@ function C(r) {
|
|
|
1002
1005
|
const t = r.getFullYear();
|
|
1003
1006
|
return t - t % 10 + "";
|
|
1004
1007
|
}
|
|
1005
|
-
function
|
|
1006
|
-
let i =
|
|
1007
|
-
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)}`;
|
|
1008
1011
|
}
|
|
1009
|
-
const
|
|
1012
|
+
const x = [
|
|
1010
1013
|
{
|
|
1011
1014
|
name: "Hour",
|
|
1012
1015
|
padding: "7d",
|
|
1013
1016
|
step: "1h",
|
|
1014
1017
|
date_format: "YYYY-MM-DD HH:",
|
|
1015
1018
|
lower_text: "HH",
|
|
1016
|
-
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) : "",
|
|
1017
1020
|
upper_text_frequency: 24
|
|
1018
1021
|
},
|
|
1019
1022
|
{
|
|
@@ -1022,7 +1025,7 @@ const y = [
|
|
|
1022
1025
|
step: "6h",
|
|
1023
1026
|
date_format: "YYYY-MM-DD HH:",
|
|
1024
1027
|
lower_text: "HH",
|
|
1025
|
-
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) : "",
|
|
1026
1029
|
upper_text_frequency: 4
|
|
1027
1030
|
},
|
|
1028
1031
|
{
|
|
@@ -1031,7 +1034,7 @@ const y = [
|
|
|
1031
1034
|
step: "12h",
|
|
1032
1035
|
date_format: "YYYY-MM-DD HH:",
|
|
1033
1036
|
lower_text: "HH",
|
|
1034
|
-
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) : "",
|
|
1035
1038
|
upper_text_frequency: 2
|
|
1036
1039
|
},
|
|
1037
1040
|
{
|
|
@@ -1039,8 +1042,8 @@ const y = [
|
|
|
1039
1042
|
padding: "7d",
|
|
1040
1043
|
date_format: "YYYY-MM-DD",
|
|
1041
1044
|
step: "1d",
|
|
1042
|
-
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
1043
|
-
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) : "",
|
|
1044
1047
|
thick_line: (r) => r.getDay() === 1
|
|
1045
1048
|
},
|
|
1046
1049
|
{
|
|
@@ -1049,8 +1052,8 @@ const y = [
|
|
|
1049
1052
|
step: "7d",
|
|
1050
1053
|
date_format: "YYYY-MM-DD",
|
|
1051
1054
|
column_width: 140,
|
|
1052
|
-
lower_text:
|
|
1053
|
-
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) : "",
|
|
1054
1057
|
thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
|
|
1055
1058
|
upper_text_frequency: 4
|
|
1056
1059
|
},
|
|
@@ -1061,7 +1064,7 @@ const y = [
|
|
|
1061
1064
|
column_width: 120,
|
|
1062
1065
|
date_format: "YYYY-MM",
|
|
1063
1066
|
lower_text: "MMMM",
|
|
1064
|
-
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) : "",
|
|
1065
1068
|
thick_line: (r) => r.getMonth() % 3 === 0,
|
|
1066
1069
|
snap_at: "7d"
|
|
1067
1070
|
},
|
|
@@ -1075,7 +1078,7 @@ const y = [
|
|
|
1075
1078
|
lower_text: "YYYY",
|
|
1076
1079
|
snap_at: "30d"
|
|
1077
1080
|
}
|
|
1078
|
-
],
|
|
1081
|
+
], Z = {
|
|
1079
1082
|
arrow_curve: 5,
|
|
1080
1083
|
auto_move_label: !1,
|
|
1081
1084
|
bar_corner_radius: 3,
|
|
@@ -1099,12 +1102,12 @@ const y = [
|
|
|
1099
1102
|
padding: 18,
|
|
1100
1103
|
popup: (r) => {
|
|
1101
1104
|
r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
|
|
1102
|
-
const t =
|
|
1105
|
+
const t = g.format(
|
|
1103
1106
|
r.task._start,
|
|
1104
1107
|
"MMM D",
|
|
1105
1108
|
r.chart.options.language
|
|
1106
|
-
), e =
|
|
1107
|
-
|
|
1109
|
+
), e = g.format(
|
|
1110
|
+
g.add(r.task._end, -1, "second"),
|
|
1108
1111
|
"MMM D",
|
|
1109
1112
|
r.chart.options.language
|
|
1110
1113
|
);
|
|
@@ -1122,7 +1125,7 @@ const y = [
|
|
|
1122
1125
|
today_button: !0,
|
|
1123
1126
|
view_mode: "Day",
|
|
1124
1127
|
view_mode_select: !1,
|
|
1125
|
-
view_modes:
|
|
1128
|
+
view_modes: x,
|
|
1126
1129
|
is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6,
|
|
1127
1130
|
task_column: {
|
|
1128
1131
|
enabled: !1,
|
|
@@ -1131,19 +1134,19 @@ const y = [
|
|
|
1131
1134
|
content: null
|
|
1132
1135
|
}
|
|
1133
1136
|
};
|
|
1134
|
-
class
|
|
1137
|
+
class tt {
|
|
1135
1138
|
constructor(t, e, i) {
|
|
1136
1139
|
this.setup_wrapper(t), this.setup_options(i), this.apply_rtl_direction(), this.setup_tasks(e), this.change_view_mode(), this.bind_events();
|
|
1137
1140
|
}
|
|
1138
1141
|
setup_wrapper(t) {
|
|
1139
1142
|
let e, i;
|
|
1140
1143
|
if (typeof t == "string") {
|
|
1141
|
-
let
|
|
1142
|
-
if (!
|
|
1144
|
+
let s = document.querySelector(t);
|
|
1145
|
+
if (!s)
|
|
1143
1146
|
throw new ReferenceError(
|
|
1144
1147
|
`CSS selector "${t}" could not be found in DOM`
|
|
1145
1148
|
);
|
|
1146
|
-
t =
|
|
1149
|
+
t = s;
|
|
1147
1150
|
}
|
|
1148
1151
|
if (t instanceof HTMLElement)
|
|
1149
1152
|
i = t, e = t.querySelector("svg");
|
|
@@ -1172,31 +1175,31 @@ class J {
|
|
|
1172
1175
|
}
|
|
1173
1176
|
setup_options(t) {
|
|
1174
1177
|
var i;
|
|
1175
|
-
this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((
|
|
1176
|
-
if (typeof
|
|
1177
|
-
const
|
|
1178
|
-
(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
|
|
1179
1182
|
);
|
|
1180
|
-
return
|
|
1181
|
-
`The view mode "${
|
|
1182
|
-
),
|
|
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;
|
|
1183
1186
|
}
|
|
1184
|
-
return
|
|
1185
|
-
}), t.view_mode = t.view_modes[0]), this.options = { ...
|
|
1187
|
+
return s;
|
|
1188
|
+
}), t.view_mode = t.view_modes[0]), this.options = { ...Z, ...t };
|
|
1186
1189
|
const e = {
|
|
1187
1190
|
"grid-height": "container_height",
|
|
1188
1191
|
"bar-height": "bar_height",
|
|
1189
1192
|
"lower-header-height": "lower_header_height",
|
|
1190
1193
|
"upper-header-height": "upper_header_height"
|
|
1191
1194
|
};
|
|
1192
|
-
for (let
|
|
1193
|
-
let
|
|
1194
|
-
|
|
1195
|
-
"--gv-" +
|
|
1196
|
-
|
|
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"
|
|
1197
1200
|
), this.$container.style.setProperty(
|
|
1198
|
-
"--gv-" +
|
|
1199
|
-
|
|
1201
|
+
"--gv-" + s,
|
|
1202
|
+
n + "px"
|
|
1200
1203
|
));
|
|
1201
1204
|
}
|
|
1202
1205
|
if ((i = this.options.task_column) != null && i.enabled && (this.$wrapper.style.setProperty(
|
|
@@ -1211,12 +1214,12 @@ class J {
|
|
|
1211
1214
|
extend_by_units: 10
|
|
1212
1215
|
}, typeof this.options.ignore != "function") {
|
|
1213
1216
|
typeof this.options.ignore == "string" && (this.options.ignore = [this.options.ignore]);
|
|
1214
|
-
for (let
|
|
1215
|
-
if (typeof
|
|
1216
|
-
this.config.ignored_function =
|
|
1217
|
+
for (let s of this.options.ignore) {
|
|
1218
|
+
if (typeof s == "function") {
|
|
1219
|
+
this.config.ignored_function = s;
|
|
1217
1220
|
continue;
|
|
1218
1221
|
}
|
|
1219
|
-
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 + " ")));
|
|
1220
1223
|
}
|
|
1221
1224
|
} else
|
|
1222
1225
|
this.config.ignored_function = this.options.ignore;
|
|
@@ -1226,10 +1229,10 @@ class J {
|
|
|
1226
1229
|
}
|
|
1227
1230
|
setup_tasks(t) {
|
|
1228
1231
|
this.tasks = t.map((e, i) => {
|
|
1229
|
-
var
|
|
1232
|
+
var s;
|
|
1230
1233
|
if (!e.start || !e.end)
|
|
1231
1234
|
if (!e.start && !e.end) {
|
|
1232
|
-
if (!((
|
|
1235
|
+
if (!((s = this.options.task_column) != null && s.enabled))
|
|
1233
1236
|
return console.warn(
|
|
1234
1237
|
`task "${e.id || e.name}" has no dates and will be hidden (task column is disabled)`
|
|
1235
1238
|
), !1;
|
|
@@ -1243,20 +1246,20 @@ class J {
|
|
|
1243
1246
|
return console.error(`task "${e.id}" doesn't have an end date`), !1;
|
|
1244
1247
|
}
|
|
1245
1248
|
if (!e._has_no_dates) {
|
|
1246
|
-
if (e._start =
|
|
1247
|
-
let { duration: d, scale: _ } =
|
|
1248
|
-
e.end =
|
|
1249
|
-
})), 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)
|
|
1250
1253
|
return console.error(
|
|
1251
1254
|
`start of task can't be after end of task: in task "${e.id}"`
|
|
1252
1255
|
), !1;
|
|
1253
|
-
if (
|
|
1256
|
+
if (g.diff(e._end, e._start, "year") > 10)
|
|
1254
1257
|
return console.error(
|
|
1255
1258
|
`the duration of task "${e.id}" is too long (above ten years)`
|
|
1256
1259
|
), !1;
|
|
1257
|
-
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"));
|
|
1258
1261
|
}
|
|
1259
|
-
return (typeof e.dependencies == "string" || Array.isArray(e.dependencies) && e.dependencies.some((
|
|
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;
|
|
1260
1263
|
}).filter((e) => e).map((e, i) => (e._index = i, e)), this.setup_dependencies();
|
|
1261
1264
|
}
|
|
1262
1265
|
setup_dependencies() {
|
|
@@ -1269,17 +1272,17 @@ class J {
|
|
|
1269
1272
|
this.setup_tasks(t), this.change_view_mode(this.options.view_mode, e);
|
|
1270
1273
|
}
|
|
1271
1274
|
update_task(t, e) {
|
|
1272
|
-
let i = this.tasks.find((o) => o.id === t),
|
|
1273
|
-
const
|
|
1274
|
-
Object.assign(i, e),
|
|
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();
|
|
1275
1278
|
}
|
|
1276
1279
|
change_view_mode(t = this.options.view_mode, e = !1) {
|
|
1277
|
-
typeof t == "string" && (t = this.options.view_modes.find((
|
|
1278
|
-
let i,
|
|
1279
|
-
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]);
|
|
1280
1283
|
}
|
|
1281
1284
|
update_view_scale(t) {
|
|
1282
|
-
let { duration: e, scale: i } =
|
|
1285
|
+
let { duration: e, scale: i } = g.parse_duration(t.step);
|
|
1283
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(
|
|
1284
1287
|
"--gv-column-width",
|
|
1285
1288
|
this.config.column_width + "px"
|
|
@@ -1291,15 +1294,15 @@ class J {
|
|
|
1291
1294
|
setup_gantt_dates(t) {
|
|
1292
1295
|
let e, i;
|
|
1293
1296
|
this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
|
|
1294
|
-
for (let
|
|
1295
|
-
(!e ||
|
|
1296
|
-
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)
|
|
1297
1300
|
if (this.options.infinite_padding)
|
|
1298
|
-
this.gantt_start =
|
|
1301
|
+
this.gantt_start = g.add(
|
|
1299
1302
|
e,
|
|
1300
1303
|
-this.config.extend_by_units * 3,
|
|
1301
1304
|
this.config.unit
|
|
1302
|
-
), this.gantt_end =
|
|
1305
|
+
), this.gantt_end = g.add(
|
|
1303
1306
|
i,
|
|
1304
1307
|
this.config.extend_by_units * 3,
|
|
1305
1308
|
this.config.unit
|
|
@@ -1309,17 +1312,17 @@ class J {
|
|
|
1309
1312
|
this.config.view_mode.padding,
|
|
1310
1313
|
this.config.view_mode.padding
|
|
1311
1314
|
]);
|
|
1312
|
-
let [
|
|
1313
|
-
|
|
1315
|
+
let [s, n] = this.config.view_mode.padding.map(
|
|
1316
|
+
g.parse_duration
|
|
1314
1317
|
);
|
|
1315
|
-
this.gantt_start =
|
|
1318
|
+
this.gantt_start = g.add(
|
|
1316
1319
|
e,
|
|
1317
|
-
-
|
|
1318
|
-
n.scale
|
|
1319
|
-
), this.gantt_end = p.add(
|
|
1320
|
-
i,
|
|
1321
|
-
s.duration,
|
|
1320
|
+
-s.duration,
|
|
1322
1321
|
s.scale
|
|
1322
|
+
), this.gantt_end = g.add(
|
|
1323
|
+
i,
|
|
1324
|
+
n.duration,
|
|
1325
|
+
n.scale
|
|
1323
1326
|
);
|
|
1324
1327
|
}
|
|
1325
1328
|
this.config.date_format = this.config.view_mode.date_format || this.options.date_format, this.gantt_start.setHours(0, 0, 0, 0);
|
|
@@ -1327,7 +1330,7 @@ class J {
|
|
|
1327
1330
|
setup_date_values() {
|
|
1328
1331
|
let t = this.gantt_start;
|
|
1329
1332
|
for (this.dates = [t]; t < this.gantt_end; )
|
|
1330
|
-
t =
|
|
1333
|
+
t = g.add(
|
|
1331
1334
|
t,
|
|
1332
1335
|
this.config.step,
|
|
1333
1336
|
this.config.unit
|
|
@@ -1374,7 +1377,7 @@ class J {
|
|
|
1374
1377
|
height: e,
|
|
1375
1378
|
class: "grid-background",
|
|
1376
1379
|
append_to: this.$svg
|
|
1377
|
-
}),
|
|
1380
|
+
}), m.attr(this.$svg, {
|
|
1378
1381
|
height: e,
|
|
1379
1382
|
width: "100%"
|
|
1380
1383
|
}), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
|
|
@@ -1382,10 +1385,10 @@ class J {
|
|
|
1382
1385
|
make_grid_rows() {
|
|
1383
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;
|
|
1384
1387
|
this.config.header_height;
|
|
1385
|
-
for (let
|
|
1388
|
+
for (let s = this.config.header_height; s < this.grid_height; s += i)
|
|
1386
1389
|
w("rect", {
|
|
1387
1390
|
x: 0,
|
|
1388
|
-
y:
|
|
1391
|
+
y: s,
|
|
1389
1392
|
width: e,
|
|
1390
1393
|
height: i,
|
|
1391
1394
|
class: "grid-row",
|
|
@@ -1412,8 +1415,8 @@ class J {
|
|
|
1412
1415
|
const e = document.createElement("option");
|
|
1413
1416
|
e.selected = !0, e.disabled = !0, e.textContent = "Mode", t.appendChild(e);
|
|
1414
1417
|
for (const i of this.options.view_modes) {
|
|
1415
|
-
const
|
|
1416
|
-
|
|
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);
|
|
1417
1420
|
}
|
|
1418
1421
|
t.addEventListener(
|
|
1419
1422
|
"change",
|
|
@@ -1428,9 +1431,9 @@ class J {
|
|
|
1428
1431
|
}
|
|
1429
1432
|
}
|
|
1430
1433
|
make_task_column() {
|
|
1431
|
-
var i,
|
|
1432
|
-
if ((i = this.$task_column) == null || i.remove(), !((
|
|
1433
|
-
(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");
|
|
1434
1437
|
return;
|
|
1435
1438
|
}
|
|
1436
1439
|
(h = (a = this.$wrapper) == null ? void 0 : a.classList) == null || h.add("has-task-column"), this.$task_column = this.create_el({
|
|
@@ -1453,39 +1456,39 @@ class J {
|
|
|
1453
1456
|
), this.$container.style.setProperty(
|
|
1454
1457
|
"--gv-task-column-content-height",
|
|
1455
1458
|
e + "px"
|
|
1456
|
-
), this.tasks.forEach((
|
|
1457
|
-
const
|
|
1459
|
+
), this.tasks.forEach((l) => {
|
|
1460
|
+
const f = this.options.bar_height + this.options.padding, u = this.create_el({
|
|
1458
1461
|
classes: "task-row",
|
|
1459
1462
|
append_to: this.$task_column_content
|
|
1460
1463
|
});
|
|
1461
|
-
if (
|
|
1462
|
-
const
|
|
1463
|
-
typeof
|
|
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);
|
|
1464
1467
|
} else
|
|
1465
|
-
|
|
1466
|
-
|
|
1468
|
+
u.textContent = l.name, u.title = l.name;
|
|
1469
|
+
u.setAttribute("data-task-id", l.id);
|
|
1467
1470
|
}), this.$task_column.style.width = this.options.task_column.width + "px", this.$task_column_resize_handle = this.create_el({
|
|
1468
1471
|
classes: "task-column-resize-handle",
|
|
1469
1472
|
append_to: this.$task_column
|
|
1470
|
-
}), 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");
|
|
1471
1474
|
}
|
|
1472
1475
|
make_grid_ticks() {
|
|
1473
1476
|
if (this.options.lines === "none") return;
|
|
1474
|
-
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", {
|
|
1475
1478
|
class: "lines_layer",
|
|
1476
1479
|
append_to: this.layers.grid
|
|
1477
|
-
}),
|
|
1480
|
+
}), n = this.config.header_height;
|
|
1478
1481
|
const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
|
|
1479
1482
|
if (this.options.lines !== "vertical")
|
|
1480
1483
|
for (let h = this.config.header_height; h < this.grid_height; h += a)
|
|
1481
1484
|
w("line", {
|
|
1482
1485
|
x1: 0,
|
|
1483
|
-
y1:
|
|
1486
|
+
y1: n + a,
|
|
1484
1487
|
x2: o,
|
|
1485
|
-
y2:
|
|
1488
|
+
y2: n + a,
|
|
1486
1489
|
class: "row-line",
|
|
1487
|
-
append_to:
|
|
1488
|
-
}),
|
|
1490
|
+
append_to: s
|
|
1491
|
+
}), n += a;
|
|
1489
1492
|
if (this.options.lines !== "horizontal")
|
|
1490
1493
|
for (let h of this.dates) {
|
|
1491
1494
|
let d = "tick";
|
|
@@ -1493,7 +1496,7 @@ class J {
|
|
|
1493
1496
|
d: `M ${t} ${e} v ${i}`,
|
|
1494
1497
|
class: d,
|
|
1495
1498
|
append_to: this.layers.grid
|
|
1496
|
-
}), 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;
|
|
1497
1500
|
}
|
|
1498
1501
|
}
|
|
1499
1502
|
highlight_holidays() {
|
|
@@ -1502,10 +1505,10 @@ class J {
|
|
|
1502
1505
|
for (let e in this.options.holidays) {
|
|
1503
1506
|
let i = this.options.holidays[e];
|
|
1504
1507
|
i === "weekend" && (i = this.options.is_weekend);
|
|
1505
|
-
let
|
|
1508
|
+
let s;
|
|
1506
1509
|
if (typeof i == "object") {
|
|
1507
|
-
let
|
|
1508
|
-
if (
|
|
1510
|
+
let n = i.find((o) => typeof o == "function");
|
|
1511
|
+
if (n && (s = n), this.options.holidays.name) {
|
|
1509
1512
|
let o = /* @__PURE__ */ new Date(i.date + " ");
|
|
1510
1513
|
i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
|
|
1511
1514
|
} else
|
|
@@ -1517,26 +1520,26 @@ class J {
|
|
|
1517
1520
|
return (/* @__PURE__ */ new Date(a + " ")).getTime();
|
|
1518
1521
|
}).includes(o.getTime());
|
|
1519
1522
|
}
|
|
1520
|
-
for (let
|
|
1523
|
+
for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
|
|
1521
1524
|
if (!(this.config.ignored_dates.find(
|
|
1522
|
-
(o) => o.getTime() ==
|
|
1523
|
-
) || this.config.ignored_function && this.config.ignored_function(
|
|
1524
|
-
const o =
|
|
1525
|
-
|
|
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,
|
|
1526
1529
|
this.gantt_start,
|
|
1527
1530
|
this.config.unit
|
|
1528
|
-
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h =
|
|
1529
|
-
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]) {
|
|
1530
1533
|
let d = this.create_el({
|
|
1531
1534
|
classes: "holiday-label label_" + h,
|
|
1532
1535
|
append_to: this.$extras
|
|
1533
1536
|
});
|
|
1534
|
-
d.textContent = t[
|
|
1537
|
+
d.textContent = t[n];
|
|
1535
1538
|
}
|
|
1536
1539
|
w("rect", {
|
|
1537
1540
|
x: Math.round(o),
|
|
1538
1541
|
y: this.config.header_height,
|
|
1539
|
-
width: this.config.column_width /
|
|
1542
|
+
width: this.config.column_width / g.convert_scales(
|
|
1540
1543
|
this.config.view_mode.step,
|
|
1541
1544
|
"day"
|
|
1542
1545
|
),
|
|
@@ -1558,20 +1561,20 @@ class J {
|
|
|
1558
1561
|
if (!t) return;
|
|
1559
1562
|
const [e, i] = t;
|
|
1560
1563
|
i.classList.add("current-date-highlight");
|
|
1561
|
-
const
|
|
1564
|
+
const n = g.diff(
|
|
1562
1565
|
/* @__PURE__ */ new Date(),
|
|
1563
1566
|
this.gantt_start,
|
|
1564
1567
|
this.config.unit
|
|
1565
1568
|
) / this.config.step * this.config.column_width;
|
|
1566
1569
|
this.$current_highlight = this.create_el({
|
|
1567
1570
|
top: this.config.header_height,
|
|
1568
|
-
left:
|
|
1571
|
+
left: n,
|
|
1569
1572
|
height: this.grid_height - this.config.header_height,
|
|
1570
1573
|
classes: "current-highlight",
|
|
1571
1574
|
append_to: this.$container
|
|
1572
1575
|
}), this.$current_ball_highlight = this.create_el({
|
|
1573
1576
|
top: this.config.header_height - 6,
|
|
1574
|
-
left:
|
|
1577
|
+
left: n - 2.5,
|
|
1575
1578
|
width: 6,
|
|
1576
1579
|
height: 6,
|
|
1577
1580
|
classes: "current-ball-highlight",
|
|
@@ -1589,15 +1592,15 @@ class J {
|
|
|
1589
1592
|
</pattern>`;
|
|
1590
1593
|
for (let i = new Date(this.gantt_start); i <= this.gantt_end; i.setDate(i.getDate() + 1)) {
|
|
1591
1594
|
if (!this.config.ignored_dates.find(
|
|
1592
|
-
(
|
|
1595
|
+
(n) => n.getTime() == i.getTime()
|
|
1593
1596
|
) && (!this.config.ignored_function || !this.config.ignored_function(i)))
|
|
1594
1597
|
continue;
|
|
1595
|
-
let
|
|
1596
|
-
|
|
1598
|
+
let s = g.convert_scales(
|
|
1599
|
+
g.diff(i, this.gantt_start) + "d",
|
|
1597
1600
|
this.config.unit
|
|
1598
1601
|
) / this.config.step;
|
|
1599
|
-
this.config.ignored_positions.push(
|
|
1600
|
-
x:
|
|
1602
|
+
this.config.ignored_positions.push(s * this.config.column_width), w("rect", {
|
|
1603
|
+
x: s * this.config.column_width,
|
|
1601
1604
|
y: this.config.header_height,
|
|
1602
1605
|
width: this.config.column_width,
|
|
1603
1606
|
height: t,
|
|
@@ -1610,10 +1613,10 @@ class J {
|
|
|
1610
1613
|
this.config.view_mode
|
|
1611
1614
|
);
|
|
1612
1615
|
}
|
|
1613
|
-
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 }) {
|
|
1614
1617
|
let d = document.createElement(h || "div");
|
|
1615
1618
|
for (let _ of o.split(" ")) d.classList.add(_);
|
|
1616
|
-
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;
|
|
1617
1620
|
}
|
|
1618
1621
|
make_dates() {
|
|
1619
1622
|
this.get_dates_to_draw().forEach((t, e) => {
|
|
@@ -1641,27 +1644,27 @@ class J {
|
|
|
1641
1644
|
}
|
|
1642
1645
|
get_dates_to_draw() {
|
|
1643
1646
|
let t = null;
|
|
1644
|
-
return this.dates.map((i,
|
|
1645
|
-
const
|
|
1646
|
-
return t =
|
|
1647
|
+
return this.dates.map((i, s) => {
|
|
1648
|
+
const n = this.get_date_info(i, t, s);
|
|
1649
|
+
return t = n, n;
|
|
1647
1650
|
});
|
|
1648
1651
|
}
|
|
1649
1652
|
get_date_info(t, e) {
|
|
1650
1653
|
let i = e ? e.date : null;
|
|
1651
1654
|
this.config.column_width;
|
|
1652
|
-
const
|
|
1653
|
-
let
|
|
1654
|
-
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 = () => "", {
|
|
1655
1658
|
date: t,
|
|
1656
1659
|
formatted_date: D(
|
|
1657
|
-
|
|
1660
|
+
g.format(
|
|
1658
1661
|
t,
|
|
1659
1662
|
this.config.date_format,
|
|
1660
1663
|
this.options.language
|
|
1661
1664
|
)
|
|
1662
1665
|
),
|
|
1663
1666
|
column_width: this.config.column_width,
|
|
1664
|
-
x:
|
|
1667
|
+
x: s,
|
|
1665
1668
|
upper_text: this.config.view_mode.upper_text(
|
|
1666
1669
|
t,
|
|
1667
1670
|
i,
|
|
@@ -1680,7 +1683,7 @@ class J {
|
|
|
1680
1683
|
this.bars = this.tasks.map((t) => {
|
|
1681
1684
|
if (t._has_no_dates)
|
|
1682
1685
|
return null;
|
|
1683
|
-
const e = new
|
|
1686
|
+
const e = new Q(this, t);
|
|
1684
1687
|
return this.layers.bar.appendChild(e.group), e;
|
|
1685
1688
|
}).filter((t) => t !== null);
|
|
1686
1689
|
}
|
|
@@ -1689,13 +1692,13 @@ class J {
|
|
|
1689
1692
|
for (let t of this.tasks) {
|
|
1690
1693
|
let e = [];
|
|
1691
1694
|
e = t.dependencies.map((i) => {
|
|
1692
|
-
const
|
|
1693
|
-
if (!
|
|
1694
|
-
const
|
|
1695
|
-
if (!
|
|
1696
|
-
const a = i.type || this.options.dependencies_type || "finish-to-start", h = 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(
|
|
1697
1700
|
this,
|
|
1698
|
-
|
|
1701
|
+
n,
|
|
1699
1702
|
o,
|
|
1700
1703
|
a
|
|
1701
1704
|
);
|
|
@@ -1704,42 +1707,42 @@ class J {
|
|
|
1704
1707
|
}
|
|
1705
1708
|
}
|
|
1706
1709
|
calculate_critical_path() {
|
|
1707
|
-
this.tasks.forEach((
|
|
1710
|
+
this.tasks.forEach((n) => n._is_critical = !1);
|
|
1708
1711
|
const t = {};
|
|
1709
|
-
this.tasks.forEach((
|
|
1710
|
-
t[
|
|
1712
|
+
this.tasks.forEach((n) => {
|
|
1713
|
+
t[n.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
|
|
1711
1714
|
});
|
|
1712
|
-
const e = (
|
|
1713
|
-
if (t[
|
|
1715
|
+
const e = (n) => {
|
|
1716
|
+
if (t[n.id].ef > 0) return t[n.id];
|
|
1714
1717
|
let o = 0;
|
|
1715
|
-
|
|
1718
|
+
n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
|
|
1716
1719
|
const d = this.get_task(h.id);
|
|
1717
1720
|
if (d) {
|
|
1718
1721
|
const _ = e(d);
|
|
1719
1722
|
o = Math.max(o, _.ef);
|
|
1720
1723
|
}
|
|
1721
|
-
}), t[
|
|
1722
|
-
const a =
|
|
1723
|
-
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];
|
|
1724
1727
|
};
|
|
1725
|
-
this.tasks.forEach((
|
|
1726
|
-
const i = Math.max(...Object.values(t).map((
|
|
1727
|
-
if (t[
|
|
1728
|
-
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];
|
|
1729
1732
|
const o = this.tasks.filter(
|
|
1730
|
-
(d) => d.dependencies && d.dependencies.some((_) => _.id ===
|
|
1733
|
+
(d) => d.dependencies && d.dependencies.some((_) => _.id === n.id)
|
|
1731
1734
|
);
|
|
1732
1735
|
let a = i;
|
|
1733
1736
|
o.length > 0 && o.forEach((d) => {
|
|
1734
|
-
const _ =
|
|
1737
|
+
const _ = s(d);
|
|
1735
1738
|
a = Math.min(a, _.ls);
|
|
1736
1739
|
});
|
|
1737
|
-
const h =
|
|
1738
|
-
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];
|
|
1739
1742
|
};
|
|
1740
|
-
this.tasks.forEach((
|
|
1741
|
-
const o = t[
|
|
1742
|
-
|
|
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;
|
|
1743
1746
|
});
|
|
1744
1747
|
}
|
|
1745
1748
|
update_arrow_critical_path() {
|
|
@@ -1768,9 +1771,9 @@ class J {
|
|
|
1768
1771
|
else {
|
|
1769
1772
|
if (t === "today")
|
|
1770
1773
|
return this.scroll_current();
|
|
1771
|
-
typeof t == "string" && (t =
|
|
1774
|
+
typeof t == "string" && (t = g.parse(t));
|
|
1772
1775
|
}
|
|
1773
|
-
const i =
|
|
1776
|
+
const i = g.diff(
|
|
1774
1777
|
t,
|
|
1775
1778
|
this.gantt_start,
|
|
1776
1779
|
this.config.unit
|
|
@@ -1778,27 +1781,27 @@ class J {
|
|
|
1778
1781
|
this.$container.scrollTo({
|
|
1779
1782
|
left: i - this.config.column_width / 6,
|
|
1780
1783
|
behavior: "smooth"
|
|
1781
|
-
}), 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(
|
|
1782
1785
|
this.gantt_start,
|
|
1783
1786
|
this.$container.scrollLeft / this.config.column_width,
|
|
1784
1787
|
this.config.unit
|
|
1785
1788
|
);
|
|
1786
|
-
let
|
|
1789
|
+
let s = this.config.view_mode.upper_text(
|
|
1787
1790
|
this.current_date,
|
|
1788
1791
|
null,
|
|
1789
1792
|
this.options.language
|
|
1790
|
-
),
|
|
1791
|
-
(o) => o.textContent ===
|
|
1793
|
+
), n = this.upperTexts.find(
|
|
1794
|
+
(o) => o.textContent === s
|
|
1792
1795
|
);
|
|
1793
|
-
this.current_date =
|
|
1796
|
+
this.current_date = g.add(
|
|
1794
1797
|
this.gantt_start,
|
|
1795
|
-
(this.$container.scrollLeft +
|
|
1798
|
+
(this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
|
|
1796
1799
|
this.config.unit
|
|
1797
|
-
),
|
|
1800
|
+
), s = this.config.view_mode.upper_text(
|
|
1798
1801
|
this.current_date,
|
|
1799
1802
|
null,
|
|
1800
1803
|
this.options.language
|
|
1801
|
-
),
|
|
1804
|
+
), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
|
|
1802
1805
|
}
|
|
1803
1806
|
scroll_current() {
|
|
1804
1807
|
let t = this.get_closest_date();
|
|
@@ -1809,26 +1812,26 @@ class J {
|
|
|
1809
1812
|
if (t < this.gantt_start || t > this.gantt_end) return null;
|
|
1810
1813
|
let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
|
|
1811
1814
|
".date_" + D(
|
|
1812
|
-
|
|
1815
|
+
g.format(
|
|
1813
1816
|
e,
|
|
1814
1817
|
this.config.date_format,
|
|
1815
1818
|
this.options.language
|
|
1816
1819
|
)
|
|
1817
1820
|
)
|
|
1818
|
-
),
|
|
1819
|
-
for (; !i &&
|
|
1820
|
-
e =
|
|
1821
|
+
), s = 0;
|
|
1822
|
+
for (; !i && s < this.config.step; )
|
|
1823
|
+
e = g.add(e, -1, this.config.unit), i = this.$container.querySelector(
|
|
1821
1824
|
".date_" + D(
|
|
1822
|
-
|
|
1825
|
+
g.format(
|
|
1823
1826
|
e,
|
|
1824
1827
|
this.config.date_format,
|
|
1825
1828
|
this.options.language
|
|
1826
1829
|
)
|
|
1827
1830
|
)
|
|
1828
|
-
),
|
|
1831
|
+
), s++;
|
|
1829
1832
|
return [
|
|
1830
1833
|
/* @__PURE__ */ new Date(
|
|
1831
|
-
|
|
1834
|
+
g.format(
|
|
1832
1835
|
e,
|
|
1833
1836
|
this.config.date_format,
|
|
1834
1837
|
this.options.language
|
|
@@ -1838,22 +1841,22 @@ class J {
|
|
|
1838
1841
|
];
|
|
1839
1842
|
}
|
|
1840
1843
|
bind_grid_click() {
|
|
1841
|
-
|
|
1844
|
+
m.on(
|
|
1842
1845
|
this.$container,
|
|
1843
1846
|
"click",
|
|
1844
1847
|
".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
|
|
1845
1848
|
(t, e) => {
|
|
1846
1849
|
if (e && e.classList.contains("grid-row")) {
|
|
1847
|
-
const i = this.$svg,
|
|
1848
|
-
|
|
1849
|
-
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];
|
|
1850
1853
|
if (h && h._has_no_dates) {
|
|
1851
|
-
const d =
|
|
1854
|
+
const d = n.x / this.config.column_width, _ = Math.floor(d * this.config.step), c = g.add(
|
|
1852
1855
|
this.gantt_start,
|
|
1853
1856
|
_,
|
|
1854
1857
|
this.config.unit
|
|
1855
1858
|
);
|
|
1856
|
-
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", [
|
|
1857
1860
|
h,
|
|
1858
1861
|
h._start,
|
|
1859
1862
|
h._end
|
|
@@ -1876,249 +1879,256 @@ class J {
|
|
|
1876
1879
|
".label_" + e.classList[1]
|
|
1877
1880
|
);
|
|
1878
1881
|
if (!i) continue;
|
|
1879
|
-
let
|
|
1880
|
-
e.onmouseenter = (
|
|
1881
|
-
|
|
1882
|
-
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";
|
|
1883
1886
|
}, 300);
|
|
1884
|
-
}, e.onmouseleave = (
|
|
1885
|
-
clearTimeout(
|
|
1887
|
+
}, e.onmouseleave = (n) => {
|
|
1888
|
+
clearTimeout(s), i.classList.remove("show");
|
|
1886
1889
|
};
|
|
1887
1890
|
}
|
|
1888
1891
|
}
|
|
1889
1892
|
get_start_end_positions() {
|
|
1890
1893
|
if (!this.bars.length) return [0, 0, 0];
|
|
1891
|
-
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;
|
|
1892
1895
|
return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
|
|
1893
1896
|
let { x: h, width: d } = o.getBBox();
|
|
1894
|
-
h < i && (i = h), h >
|
|
1895
|
-
}), [i,
|
|
1897
|
+
h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
|
|
1898
|
+
}), [i, s, n];
|
|
1896
1899
|
}
|
|
1897
1900
|
bind_bar_events() {
|
|
1898
|
-
let t = !1, e = 0, i = 0,
|
|
1901
|
+
let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
|
|
1899
1902
|
this.bar_being_dragged = null;
|
|
1900
|
-
const h = () => t ||
|
|
1903
|
+
const h = () => t || s || n;
|
|
1901
1904
|
this.$svg.onclick = (_) => {
|
|
1902
1905
|
_.target.classList.contains("grid-row") && this.unselect_all();
|
|
1903
1906
|
};
|
|
1904
1907
|
let d = 0;
|
|
1905
|
-
if (
|
|
1908
|
+
if (m.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
|
|
1906
1909
|
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
|
|
1907
|
-
}),
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1910
|
-
const
|
|
1911
|
-
|
|
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;
|
|
1912
1915
|
});
|
|
1913
1916
|
}), this.options.infinite_padding) {
|
|
1914
1917
|
let _ = !1;
|
|
1915
|
-
|
|
1916
|
-
let
|
|
1917
|
-
if (!_ &&
|
|
1918
|
-
let
|
|
1919
|
-
_ = !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(
|
|
1920
1923
|
this.gantt_start,
|
|
1921
1924
|
-this.config.extend_by_units,
|
|
1922
1925
|
this.config.unit
|
|
1923
|
-
), 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);
|
|
1924
1927
|
}
|
|
1925
|
-
if (!_ &&
|
|
1926
|
-
let
|
|
1927
|
-
_ = !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(
|
|
1928
1931
|
this.gantt_end,
|
|
1929
1932
|
this.config.extend_by_units,
|
|
1930
1933
|
this.config.unit
|
|
1931
|
-
), this.setup_date_values(), this.render(),
|
|
1934
|
+
), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l, setTimeout(() => _ = !1, 300);
|
|
1932
1935
|
}
|
|
1933
1936
|
});
|
|
1934
1937
|
}
|
|
1935
|
-
|
|
1938
|
+
m.on(this.$container, "scroll", (_) => {
|
|
1936
1939
|
this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = _.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
1937
1940
|
this._syncing_scroll = !1;
|
|
1938
1941
|
}));
|
|
1939
|
-
let
|
|
1940
|
-
const
|
|
1941
|
-
({ group:
|
|
1942
|
+
let c = [];
|
|
1943
|
+
const p = this.bars.map(
|
|
1944
|
+
({ group: $ }) => $.getAttribute("data-id")
|
|
1942
1945
|
);
|
|
1943
|
-
let
|
|
1944
|
-
i && (
|
|
1946
|
+
let l;
|
|
1947
|
+
i && (l = _.currentTarget.scrollLeft - i), this.current_date = g.add(
|
|
1945
1948
|
this.gantt_start,
|
|
1946
1949
|
_.currentTarget.scrollLeft / this.config.column_width * this.config.step,
|
|
1947
1950
|
this.config.unit
|
|
1948
1951
|
);
|
|
1949
|
-
let
|
|
1952
|
+
let f = this.config.view_mode.upper_text(
|
|
1950
1953
|
this.current_date,
|
|
1951
1954
|
null,
|
|
1952
1955
|
this.options.language
|
|
1953
|
-
),
|
|
1954
|
-
(
|
|
1956
|
+
), u = this.upperTexts.find(
|
|
1957
|
+
($) => $.textContent === f
|
|
1955
1958
|
);
|
|
1956
|
-
this.current_date =
|
|
1959
|
+
this.current_date = g.add(
|
|
1957
1960
|
this.gantt_start,
|
|
1958
|
-
(_.currentTarget.scrollLeft +
|
|
1961
|
+
(_.currentTarget.scrollLeft + u.clientWidth) / this.config.column_width * this.config.step,
|
|
1959
1962
|
this.config.unit
|
|
1960
|
-
),
|
|
1963
|
+
), f = this.config.view_mode.upper_text(
|
|
1961
1964
|
this.current_date,
|
|
1962
1965
|
null,
|
|
1963
1966
|
this.options.language
|
|
1964
|
-
),
|
|
1965
|
-
(
|
|
1966
|
-
),
|
|
1967
|
-
let [
|
|
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();
|
|
1968
1971
|
i > k + 100 ? (this.$adjust.innerHTML = "←", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1969
1972
|
this.$container.scrollTo({
|
|
1970
|
-
left:
|
|
1973
|
+
left: y,
|
|
1971
1974
|
behavior: "smooth"
|
|
1972
1975
|
});
|
|
1973
|
-
}) : i + _.currentTarget.offsetWidth <
|
|
1976
|
+
}) : i + _.currentTarget.offsetWidth < b - 100 ? (this.$adjust.innerHTML = "→", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1974
1977
|
this.$container.scrollTo({
|
|
1975
|
-
left:
|
|
1978
|
+
left: b,
|
|
1976
1979
|
behavior: "smooth"
|
|
1977
1980
|
});
|
|
1978
|
-
}) : this.$adjust.classList.add("hide"),
|
|
1979
|
-
|
|
1980
|
-
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,
|
|
1981
1984
|
sx: _.currentTarget.scrollLeft
|
|
1982
1985
|
});
|
|
1983
1986
|
}));
|
|
1984
|
-
}),
|
|
1987
|
+
}), m.on(this.$svg, "mousemove", (_) => {
|
|
1985
1988
|
if (!h()) return;
|
|
1986
|
-
const
|
|
1987
|
-
a.forEach((
|
|
1988
|
-
const
|
|
1989
|
-
|
|
1990
|
-
x:
|
|
1991
|
-
width:
|
|
1992
|
-
}) :
|
|
1993
|
-
x:
|
|
1994
|
-
}) :
|
|
1995
|
-
width:
|
|
1996
|
-
}) : 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 });
|
|
1997
2000
|
});
|
|
1998
2001
|
}), document.addEventListener("mouseup", () => {
|
|
1999
|
-
var
|
|
2002
|
+
var p, l, f;
|
|
2000
2003
|
const _ = this.bar_being_dragged === !0;
|
|
2001
2004
|
this.bar_being_dragged = null;
|
|
2002
|
-
const
|
|
2003
|
-
a.forEach((
|
|
2004
|
-
if (!
|
|
2005
|
-
_ &&
|
|
2005
|
+
const c = [];
|
|
2006
|
+
if (a.forEach((u) => {
|
|
2007
|
+
if (!u.$bar.finaldx) {
|
|
2008
|
+
_ && u.set_action_completed();
|
|
2006
2009
|
return;
|
|
2007
2010
|
}
|
|
2008
|
-
|
|
2009
|
-
task:
|
|
2010
|
-
start:
|
|
2011
|
-
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")
|
|
2012
2015
|
});
|
|
2013
|
-
}), this.options.critical_path && a.some((
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
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
|
+
});
|
|
2031
2040
|
});
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
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");
|
|
2037
2047
|
}), this.bind_bar_progress();
|
|
2038
2048
|
}
|
|
2039
2049
|
bind_task_column_resize() {
|
|
2040
2050
|
if (!this.$task_column_resize_handle) return;
|
|
2041
2051
|
let t = !1, e = 0, i = 0;
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2052
|
+
const s = 100, n = 600;
|
|
2053
|
+
m.on(this.$task_column_resize_handle, "mousedown", (o) => {
|
|
2044
2054
|
t = !0, e = o.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), o.preventDefault();
|
|
2045
|
-
}),
|
|
2055
|
+
}), m.on(document, "mousemove", (o) => {
|
|
2046
2056
|
if (!t) return;
|
|
2047
2057
|
let a = o.clientX - e;
|
|
2048
2058
|
this.options.isRTL && (a = -a);
|
|
2049
2059
|
let h = i + a;
|
|
2050
|
-
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(
|
|
2051
2061
|
"--gv-task-column-width",
|
|
2052
2062
|
h + "px"
|
|
2053
2063
|
), this.$container.style.setProperty(
|
|
2054
2064
|
"--gv-task-column-width",
|
|
2055
2065
|
h + "px"
|
|
2056
2066
|
), this.trigger_event("task_column_resize", [h]);
|
|
2057
|
-
}),
|
|
2067
|
+
}), m.on(document, "mouseup", () => {
|
|
2058
2068
|
t && (t = !1, this.$task_column.classList.remove("resizing"), this.trigger_event("task_after_column_resize", [this.options.task_column.width]));
|
|
2059
2069
|
});
|
|
2060
2070
|
}
|
|
2061
2071
|
bind_task_column_scroll() {
|
|
2062
|
-
this.$task_column &&
|
|
2072
|
+
this.$task_column && m.on(this.$task_column, "scroll", (t) => {
|
|
2063
2073
|
this._syncing_scroll || (this._syncing_scroll = !0, this.$container.scrollTop = t.currentTarget.scrollTop, requestAnimationFrame(() => {
|
|
2064
2074
|
this._syncing_scroll = !1;
|
|
2065
2075
|
}));
|
|
2066
2076
|
});
|
|
2067
2077
|
}
|
|
2068
2078
|
bind_bar_progress() {
|
|
2069
|
-
let t = 0, e = null, i = null,
|
|
2070
|
-
|
|
2079
|
+
let t = 0, e = null, i = null, s = null, n = null;
|
|
2080
|
+
m.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
|
|
2071
2081
|
e = !0, t = a.offsetX || a.layerX;
|
|
2072
|
-
const _ =
|
|
2073
|
-
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();
|
|
2074
2084
|
});
|
|
2075
2085
|
const o = this.config.ignored_positions.map((a) => [
|
|
2076
2086
|
a,
|
|
2077
2087
|
a + this.config.column_width
|
|
2078
2088
|
]);
|
|
2079
|
-
|
|
2089
|
+
m.on(this.$svg, "mousemove", (a) => {
|
|
2080
2090
|
if (!e) return;
|
|
2081
2091
|
let h = a.offsetX || a.layerX;
|
|
2082
2092
|
if (h > t) {
|
|
2083
|
-
let
|
|
2084
|
-
([
|
|
2093
|
+
let c = o.find(
|
|
2094
|
+
([p, l]) => h >= p && h < l
|
|
2085
2095
|
);
|
|
2086
|
-
for (;
|
|
2087
|
-
h =
|
|
2088
|
-
([
|
|
2096
|
+
for (; c; )
|
|
2097
|
+
h = c[1], c = o.find(
|
|
2098
|
+
([p, l]) => h >= p && h < l
|
|
2089
2099
|
);
|
|
2090
2100
|
} else {
|
|
2091
|
-
let
|
|
2092
|
-
([
|
|
2101
|
+
let c = o.find(
|
|
2102
|
+
([p, l]) => h > p && h <= l
|
|
2093
2103
|
);
|
|
2094
|
-
for (;
|
|
2095
|
-
h =
|
|
2096
|
-
([
|
|
2104
|
+
for (; c; )
|
|
2105
|
+
h = c[0], c = o.find(
|
|
2106
|
+
([p, l]) => h > p && h <= l
|
|
2097
2107
|
);
|
|
2098
2108
|
}
|
|
2099
2109
|
let _ = h - t;
|
|
2100
|
-
console.log(
|
|
2101
|
-
}),
|
|
2102
|
-
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);
|
|
2103
2113
|
});
|
|
2104
2114
|
}
|
|
2105
2115
|
get_all_dependent_tasks(t) {
|
|
2106
2116
|
let e = [], i = [t];
|
|
2107
2117
|
for (; i.length; ) {
|
|
2108
|
-
const
|
|
2109
|
-
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));
|
|
2110
2120
|
}
|
|
2111
2121
|
return e.filter(Boolean);
|
|
2112
2122
|
}
|
|
2113
2123
|
get_snap_position(t, e) {
|
|
2114
2124
|
let i = 1;
|
|
2115
|
-
const
|
|
2116
|
-
if (
|
|
2117
|
-
const { duration: _, scale:
|
|
2118
|
-
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) / _;
|
|
2119
2129
|
}
|
|
2120
|
-
const
|
|
2121
|
-
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;
|
|
2122
2132
|
const h = o > 0 ? 1 : -1;
|
|
2123
2133
|
let d = this.get_ignored_region(a, h);
|
|
2124
2134
|
for (; d.length; )
|
|
@@ -2143,7 +2153,7 @@ class J {
|
|
|
2143
2153
|
return this.bars.find((e) => e.task.id === t);
|
|
2144
2154
|
}
|
|
2145
2155
|
show_popup(t) {
|
|
2146
|
-
this.options.popup !== !1 && (this.popup || (this.popup = new
|
|
2156
|
+
this.options.popup !== !1 && (this.popup || (this.popup = new K(
|
|
2147
2157
|
this.$popup_wrapper,
|
|
2148
2158
|
this.options.popup,
|
|
2149
2159
|
this
|
|
@@ -2172,25 +2182,25 @@ class J {
|
|
|
2172
2182
|
* @memberof Gantt
|
|
2173
2183
|
*/
|
|
2174
2184
|
clear() {
|
|
2175
|
-
var t, e, i,
|
|
2176
|
-
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");
|
|
2177
2187
|
}
|
|
2178
2188
|
}
|
|
2179
|
-
|
|
2180
|
-
HOUR:
|
|
2181
|
-
QUARTER_DAY:
|
|
2182
|
-
HALF_DAY:
|
|
2183
|
-
DAY:
|
|
2184
|
-
WEEK:
|
|
2185
|
-
MONTH:
|
|
2186
|
-
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]
|
|
2187
2197
|
};
|
|
2188
|
-
function
|
|
2198
|
+
function et(r) {
|
|
2189
2199
|
return r.name + "_" + Math.random().toString(36).slice(2, 12);
|
|
2190
2200
|
}
|
|
2191
2201
|
function D(r) {
|
|
2192
2202
|
return r.replaceAll(" ", "_").replaceAll(":", "_").replaceAll(".", "_");
|
|
2193
2203
|
}
|
|
2194
2204
|
export {
|
|
2195
|
-
|
|
2205
|
+
tt as default
|
|
2196
2206
|
};
|