@workiom/frappe-gantt 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frappe-gantt.css +1 -1
- package/dist/frappe-gantt.es.js +448 -416
- package/dist/frappe-gantt.umd.js +9 -9
- package/package.json +1 -1
- package/src/arrow.js +54 -1
- package/src/bar.js +69 -30
- package/src/index.js +7 -6
- package/src/styles/dark.css +6 -1
- package/src/styles/gantt.css +4 -0
- package/src/styles/light.css +3 -2
package/dist/frappe-gantt.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second",
|
|
1
|
+
const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second", S = "millisecond", l = {
|
|
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", Y = "minute", A = "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, n;
|
|
26
|
+
const s = r.split(" ");
|
|
27
|
+
i = s[0].split(t).map((a) => parseInt(a, 10)), n = s[1] && s[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
|
|
28
28
|
let o = i;
|
|
29
|
-
return
|
|
29
|
+
return n && n.length && (n.length === 4 && (n[3] = "0." + n[3], n[3] = parseFloat(n[3]) * 1e3), o = o.concat(n)), 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((s, o) => (o === 1 && (s = s + 1), o === 6 ? x(s + "", 3, "0") : x(s + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, n = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
|
|
36
|
+
return i + (t ? " " + n : "");
|
|
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
|
+
}), n = new Intl.DateTimeFormat(e, {
|
|
42
42
|
month: "short"
|
|
43
|
-
}),
|
|
43
|
+
}), s = i.format(r), o = s.charAt(0).toUpperCase() + s.slice(1), a = this.get_date_values(r).map((c) => x(c, 2, 0)), h = {
|
|
44
44
|
YYYY: a[0],
|
|
45
|
-
MM:
|
|
45
|
+
MM: x(+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", Y = "minute", A = "second"
|
|
|
50
50
|
SSS: a[6],
|
|
51
51
|
D: a[2],
|
|
52
52
|
MMMM: o,
|
|
53
|
-
MMM:
|
|
53
|
+
MMM: n.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, g) => g.length - c.length).forEach((c) => {
|
|
58
|
+
d.includes(c) && (d = d.replaceAll(c, `$${_.length}`), _.push(h[c]));
|
|
59
|
+
}), _.forEach((c, g) => {
|
|
60
|
+
d = d.replaceAll(`$${g}`, 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, n, s, o, a, h, d;
|
|
65
|
+
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, n = i / 1e3, o = n / 60, s = o / 60, a = s / 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: n,
|
|
71
71
|
minutes: o,
|
|
72
|
-
hours:
|
|
72
|
+
hours: s,
|
|
73
73
|
days: a,
|
|
74
74
|
months: h,
|
|
75
75
|
years: d
|
|
@@ -92,7 +92,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
|
|
|
92
92
|
r.getHours() + (e === T ? t : 0),
|
|
93
93
|
r.getMinutes() + (e === Y ? t : 0),
|
|
94
94
|
r.getSeconds() + (e === A ? t : 0),
|
|
95
|
-
r.getMilliseconds() + (e ===
|
|
95
|
+
r.getMilliseconds() + (e === S ? t : 0)
|
|
96
96
|
];
|
|
97
97
|
return new Date(...i);
|
|
98
98
|
},
|
|
@@ -104,13 +104,13 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
|
|
|
104
104
|
[T]: 3,
|
|
105
105
|
[Y]: 2,
|
|
106
106
|
[A]: 1,
|
|
107
|
-
[
|
|
107
|
+
[S]: 0
|
|
108
108
|
};
|
|
109
|
-
function i(
|
|
109
|
+
function i(s) {
|
|
110
110
|
const o = e[t];
|
|
111
|
-
return e[
|
|
111
|
+
return e[s] <= o;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const n = [
|
|
114
114
|
r.getFullYear(),
|
|
115
115
|
i(M) ? 0 : r.getMonth(),
|
|
116
116
|
i(D) ? 1 : r.getDate(),
|
|
@@ -119,7 +119,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
|
|
|
119
119
|
i(Y) ? 0 : r.getSeconds(),
|
|
120
120
|
i(A) ? 0 : r.getMilliseconds()
|
|
121
121
|
];
|
|
122
|
-
return new Date(...
|
|
122
|
+
return new Date(...n);
|
|
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", Y = "minute", A = "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: n } = this.parse_duration(r);
|
|
148
|
+
return i * e[n] / 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,7 +158,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
|
|
|
158
158
|
return r.getFullYear() % 4 ? 365 : 366;
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
function
|
|
161
|
+
function x(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
164
|
function u(r, t) {
|
|
@@ -171,29 +171,29 @@ function f(r, t) {
|
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
173
|
function E(r, t, e, i) {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
|
|
174
|
+
const n = z(r, t, e, i);
|
|
175
|
+
if (n === r) {
|
|
176
|
+
const s = document.createEvent("HTMLEvents");
|
|
177
|
+
s.initEvent("click", !0, !0), s.eventName = "click", n.dispatchEvent(s);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function z(r, t, e, i,
|
|
180
|
+
function z(r, t, e, i, n = "0.4s", s = "0.1s") {
|
|
181
181
|
const o = r.querySelector("animate");
|
|
182
182
|
if (o)
|
|
183
183
|
return u.attr(o, {
|
|
184
184
|
attributeName: t,
|
|
185
185
|
from: e,
|
|
186
186
|
to: i,
|
|
187
|
-
dur:
|
|
188
|
-
begin: "click + " +
|
|
187
|
+
dur: n,
|
|
188
|
+
begin: "click + " + s
|
|
189
189
|
// artificial click
|
|
190
190
|
}), r;
|
|
191
191
|
const a = f("animate", {
|
|
192
192
|
attributeName: t,
|
|
193
193
|
from: e,
|
|
194
194
|
to: i,
|
|
195
|
-
dur:
|
|
196
|
-
begin:
|
|
195
|
+
dur: n,
|
|
196
|
+
begin: s,
|
|
197
197
|
calcMode: "spline",
|
|
198
198
|
values: e + ";" + i,
|
|
199
199
|
keyTimes: "0; 1",
|
|
@@ -222,9 +222,9 @@ u.bind = (r, t, e) => {
|
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
224
|
u.delegate = (r, t, e, i) => {
|
|
225
|
-
r.addEventListener(t, function(
|
|
226
|
-
const
|
|
227
|
-
|
|
225
|
+
r.addEventListener(t, function(n) {
|
|
226
|
+
const s = n.target.closest(e);
|
|
227
|
+
s && (n.delegatedTarget = s, i.call(this, n, s));
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
230
|
u.closest = (r, t) => t ? t.matches(r) ? t : u.closest(r, t.parentNode) : null;
|
|
@@ -240,18 +240,35 @@ u.attr = (r, t, e) => {
|
|
|
240
240
|
};
|
|
241
241
|
class C {
|
|
242
242
|
constructor(t, e, i) {
|
|
243
|
-
this.gantt = t, this.from_task = e, this.to_task = i, this.is_critical = this.check_critical_path(), this.calculate_path(), this.draw();
|
|
243
|
+
this.gantt = t, this.from_task = e, this.to_task = i, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.calculate_path(), this.draw();
|
|
244
244
|
}
|
|
245
245
|
check_critical_path() {
|
|
246
246
|
return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
|
|
247
247
|
}
|
|
248
|
+
check_invalid_dependency() {
|
|
249
|
+
const t = this.to_task.task.dependencies_type || this.gantt.options.dependencies_type;
|
|
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;
|
|
253
|
+
switch (t) {
|
|
254
|
+
case "finish-to-start":
|
|
255
|
+
return i._start < e._end;
|
|
256
|
+
case "start-to-start":
|
|
257
|
+
return i._start < e._start;
|
|
258
|
+
case "finish-to-finish":
|
|
259
|
+
return i._end < e._end;
|
|
260
|
+
case "start-to-finish":
|
|
261
|
+
return i._end < e._start;
|
|
262
|
+
}
|
|
263
|
+
return !1;
|
|
264
|
+
}
|
|
248
265
|
calculate_path() {
|
|
249
266
|
let t = this.from_task.$bar.getX() + this.from_task.$bar.getWidth() / 2;
|
|
250
267
|
const e = () => this.to_task.$bar.getX() < t + this.gantt.options.padding && t > this.from_task.$bar.getX() + this.gantt.options.padding;
|
|
251
268
|
for (; e(); )
|
|
252
269
|
t -= 10;
|
|
253
270
|
t -= 10;
|
|
254
|
-
let i = this.gantt.config.header_height + this.gantt.options.bar_height + (this.gantt.options.padding + this.gantt.options.bar_height) * this.from_task.task._index + this.gantt.options.padding / 2,
|
|
271
|
+
let i = this.gantt.config.header_height + this.gantt.options.bar_height + (this.gantt.options.padding + this.gantt.options.bar_height) * this.from_task.task._index + this.gantt.options.padding / 2, n = this.to_task.$bar.getX() - 13, s = this.gantt.config.header_height + this.gantt.options.bar_height / 2 + (this.gantt.options.padding + this.gantt.options.bar_height) * this.to_task.task._index + this.gantt.options.padding / 2;
|
|
255
272
|
const o = this.from_task.task._index > this.to_task.task._index;
|
|
256
273
|
let a = this.gantt.options.arrow_curve;
|
|
257
274
|
const h = o ? 1 : 0;
|
|
@@ -259,42 +276,45 @@ class C {
|
|
|
259
276
|
if (this.to_task.$bar.getX() <= this.from_task.$bar.getX() + this.gantt.options.padding) {
|
|
260
277
|
let _ = this.gantt.options.padding / 2 - a;
|
|
261
278
|
_ < 0 && (_ = 0, a = this.gantt.options.padding / 2, d = o ? -a : a);
|
|
262
|
-
const
|
|
279
|
+
const c = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, g = this.to_task.$bar.getX() - this.gantt.options.padding;
|
|
263
280
|
this.path = `
|
|
264
281
|
M ${t} ${i}
|
|
265
282
|
v ${_}
|
|
266
283
|
a ${a} ${a} 0 0 1 ${-a} ${a}
|
|
267
|
-
H ${
|
|
284
|
+
H ${g}
|
|
268
285
|
a ${a} ${a} 0 0 ${h} ${-a} ${d}
|
|
269
|
-
V ${
|
|
286
|
+
V ${c}
|
|
270
287
|
a ${a} ${a} 0 0 ${h} ${a} ${d}
|
|
271
|
-
L ${
|
|
288
|
+
L ${n} ${s}
|
|
272
289
|
m -5 -5
|
|
273
290
|
l 5 5
|
|
274
291
|
l -5 5`;
|
|
275
292
|
} else {
|
|
276
|
-
|
|
277
|
-
let _ = o ?
|
|
293
|
+
n < t + a && (a = n - t);
|
|
294
|
+
let _ = o ? s + a : s - a;
|
|
278
295
|
this.path = `
|
|
279
296
|
M ${t} ${i}
|
|
280
297
|
V ${_}
|
|
281
298
|
a ${a} ${a} 0 0 ${h} ${a} ${a}
|
|
282
|
-
L ${
|
|
299
|
+
L ${n} ${s}
|
|
283
300
|
m -5 -5
|
|
284
301
|
l 5 5
|
|
285
302
|
l -5 5`;
|
|
286
303
|
}
|
|
287
304
|
}
|
|
288
305
|
draw() {
|
|
289
|
-
|
|
306
|
+
let t = "";
|
|
307
|
+
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element = f("path", {
|
|
290
308
|
d: this.path,
|
|
291
309
|
"data-from": this.from_task.task.id,
|
|
292
310
|
"data-to": this.to_task.task.id,
|
|
293
|
-
class:
|
|
311
|
+
class: t
|
|
294
312
|
});
|
|
295
313
|
}
|
|
296
314
|
update() {
|
|
297
|
-
this.calculate_path(), this.element.setAttribute("d", this.path);
|
|
315
|
+
this.calculate_path(), this.element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
|
|
316
|
+
let t = "";
|
|
317
|
+
this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element.setAttribute("class", t);
|
|
298
318
|
}
|
|
299
319
|
}
|
|
300
320
|
class q {
|
|
@@ -302,7 +322,7 @@ class q {
|
|
|
302
322
|
this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
|
|
303
323
|
}
|
|
304
324
|
refresh() {
|
|
305
|
-
this.bar_group.innerHTML = "", this.handle_group.innerHTML = "", this.task.custom_class ? this.group.classList.add(this.task.custom_class) : this.group.classList = ["bar-wrapper"], this.prepare_values(), this.draw(), this.bind();
|
|
325
|
+
this.bar_group.innerHTML = "", this.handle_group.innerHTML = "", this.task.custom_class ? this.group.classList.add(this.task.custom_class) : this.group.classList = ["bar-wrapper"], this.unbind(), this.prepare_values(), this.draw(), this.bind();
|
|
306
326
|
}
|
|
307
327
|
set_defaults(t, e) {
|
|
308
328
|
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;
|
|
@@ -384,11 +404,12 @@ class q {
|
|
|
384
404
|
class: "bar-progress",
|
|
385
405
|
append_to: this.bar_group
|
|
386
406
|
}), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
|
|
387
|
-
const e =
|
|
407
|
+
const e = l.diff(
|
|
388
408
|
this.task._start,
|
|
389
409
|
this.gantt.gantt_start,
|
|
390
410
|
this.gantt.config.unit
|
|
391
411
|
) / this.gantt.config.step * this.gantt.config.column_width;
|
|
412
|
+
this.$date_highlight && this.$date_highlight.parentNode && this.$date_highlight.parentNode.removeChild(this.$date_highlight);
|
|
392
413
|
let i = this.gantt.create_el({
|
|
393
414
|
classes: `date-range-highlight hide highlight-${this.task.id}`,
|
|
394
415
|
width: this.width,
|
|
@@ -398,17 +419,17 @@ class q {
|
|
|
398
419
|
}
|
|
399
420
|
calculate_progress_width() {
|
|
400
421
|
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;
|
|
401
|
-
let
|
|
402
|
-
const
|
|
403
|
-
|
|
422
|
+
let n = (t - i) * this.task.progress / 100;
|
|
423
|
+
const s = this.x + n, o = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < s), 0) * this.gantt.config.column_width;
|
|
424
|
+
n += o;
|
|
404
425
|
let a = this.gantt.get_ignored_region(
|
|
405
|
-
this.x +
|
|
426
|
+
this.x + n
|
|
406
427
|
);
|
|
407
428
|
for (; a.length; )
|
|
408
|
-
|
|
409
|
-
this.x +
|
|
429
|
+
n += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
|
|
430
|
+
this.x + n
|
|
410
431
|
);
|
|
411
|
-
return this.progress_width =
|
|
432
|
+
return this.progress_width = n, n;
|
|
412
433
|
}
|
|
413
434
|
draw_label() {
|
|
414
435
|
let t = this.x + this.$bar.getWidth() / 2;
|
|
@@ -421,7 +442,7 @@ class q {
|
|
|
421
442
|
}), this.task.color_text && (this.$bar_label.style.fill = this.task.color_text), requestAnimationFrame(() => this.update_label_position());
|
|
422
443
|
}
|
|
423
444
|
draw_thumbnail() {
|
|
424
|
-
let t = 10, e = 2, i,
|
|
445
|
+
let t = 10, e = 2, i, n;
|
|
425
446
|
i = f("defs", {
|
|
426
447
|
append_to: this.bar_group
|
|
427
448
|
}), f("rect", {
|
|
@@ -433,12 +454,12 @@ class q {
|
|
|
433
454
|
rx: "15",
|
|
434
455
|
class: "img_mask",
|
|
435
456
|
append_to: i
|
|
436
|
-
}),
|
|
457
|
+
}), n = f("clipPath", {
|
|
437
458
|
id: "clip_" + this.task.id,
|
|
438
459
|
append_to: i
|
|
439
460
|
}), f("use", {
|
|
440
461
|
href: "#rect_" + this.task.id,
|
|
441
|
-
append_to:
|
|
462
|
+
append_to: n
|
|
442
463
|
}), f("image", {
|
|
443
464
|
x: this.x + t,
|
|
444
465
|
y: this.y + e,
|
|
@@ -459,51 +480,51 @@ class q {
|
|
|
459
480
|
i = this.x + this.$bar.getWidth() + 5;
|
|
460
481
|
else
|
|
461
482
|
return;
|
|
462
|
-
const
|
|
483
|
+
const n = this.y + (this.height - 20) / 2;
|
|
463
484
|
this.$add_icon_group = f("g", {
|
|
464
485
|
class: "add-task-icon hide",
|
|
465
486
|
append_to: this.handle_group
|
|
466
487
|
}), this.$add_icon_circle = f("circle", {
|
|
467
488
|
cx: i + 20 / 2,
|
|
468
|
-
cy:
|
|
489
|
+
cy: n + 20 / 2,
|
|
469
490
|
r: 20 / 2,
|
|
470
491
|
class: "add-task-icon-bg",
|
|
471
492
|
append_to: this.$add_icon_group
|
|
472
493
|
}), this.$add_icon_vertical = f("line", {
|
|
473
494
|
x1: i + 20 / 2,
|
|
474
|
-
y1:
|
|
495
|
+
y1: n + 5,
|
|
475
496
|
x2: i + 20 / 2,
|
|
476
|
-
y2:
|
|
497
|
+
y2: n + 20 - 5,
|
|
477
498
|
class: "add-task-icon-plus",
|
|
478
499
|
append_to: this.$add_icon_group
|
|
479
500
|
}), this.$add_icon_horizontal = f("line", {
|
|
480
501
|
x1: i + 5,
|
|
481
|
-
y1:
|
|
502
|
+
y1: n + 20 / 2,
|
|
482
503
|
x2: i + 20 - 5,
|
|
483
|
-
y2:
|
|
504
|
+
y2: n + 20 / 2,
|
|
484
505
|
class: "add-task-icon-plus",
|
|
485
506
|
append_to: this.$add_icon_group
|
|
486
|
-
}), u.on(this.$add_icon_group, "mousedown", (
|
|
487
|
-
|
|
488
|
-
}), u.on(this.$add_icon_group, "mouseup", (
|
|
489
|
-
|
|
490
|
-
}), u.on(this.$add_icon_group, "click", (
|
|
491
|
-
|
|
492
|
-
}), u.on(this.$add_icon_group, "mouseenter", (
|
|
493
|
-
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"),
|
|
507
|
+
}), u.on(this.$add_icon_group, "mousedown", (s) => {
|
|
508
|
+
s.stopPropagation();
|
|
509
|
+
}), u.on(this.$add_icon_group, "mouseup", (s) => {
|
|
510
|
+
s.stopPropagation();
|
|
511
|
+
}), u.on(this.$add_icon_group, "click", (s) => {
|
|
512
|
+
s.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
|
|
513
|
+
}), u.on(this.$add_icon_group, "mouseenter", (s) => {
|
|
514
|
+
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"), s.stopPropagation();
|
|
494
515
|
}), u.on(this.$add_icon_group, "mouseleave", () => {
|
|
495
516
|
this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
|
|
496
517
|
});
|
|
497
518
|
}
|
|
498
519
|
draw_resize_handles() {
|
|
499
520
|
if (this.invalid || this.gantt.options.readonly) return;
|
|
500
|
-
const t = this.$bar, e =
|
|
521
|
+
const t = this.$bar, e = 8;
|
|
501
522
|
if (this.handles = [], this.gantt.options.readonly_dates || (this.handles.push(
|
|
502
523
|
f("rect", {
|
|
503
|
-
x: t.getEndX() - e
|
|
504
|
-
y: t.getY() + this.height /
|
|
524
|
+
x: t.getEndX() - e,
|
|
525
|
+
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
505
526
|
width: e,
|
|
506
|
-
height: this.height
|
|
527
|
+
height: this.height * 0.8,
|
|
507
528
|
rx: 2,
|
|
508
529
|
ry: 2,
|
|
509
530
|
class: "handle right",
|
|
@@ -511,10 +532,10 @@ class q {
|
|
|
511
532
|
})
|
|
512
533
|
), this.handles.push(
|
|
513
534
|
f("rect", {
|
|
514
|
-
x: t.getX() - e
|
|
515
|
-
y: t.getY() + this.height /
|
|
535
|
+
x: t.getX() - e,
|
|
536
|
+
y: t.getY() + (this.height - this.height * 0.8) / 2,
|
|
516
537
|
width: e,
|
|
517
|
-
height: this.height
|
|
538
|
+
height: this.height * 0.8,
|
|
518
539
|
rx: 2,
|
|
519
540
|
ry: 2,
|
|
520
541
|
class: "handle left",
|
|
@@ -536,104 +557,121 @@ class q {
|
|
|
536
557
|
bind() {
|
|
537
558
|
this.invalid || this.setup_click_event();
|
|
538
559
|
}
|
|
560
|
+
unbind() {
|
|
561
|
+
this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
|
|
562
|
+
u.off(this.group, t, e);
|
|
563
|
+
}), this.event_listeners = []);
|
|
564
|
+
}
|
|
539
565
|
setup_click_event() {
|
|
566
|
+
this.event_listeners = [];
|
|
540
567
|
let t = this.task.id;
|
|
541
|
-
|
|
568
|
+
const e = (g) => {
|
|
542
569
|
this.gantt.trigger_event("hover", [
|
|
543
570
|
this.task,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
571
|
+
g.screenX,
|
|
572
|
+
g.screenY,
|
|
573
|
+
g
|
|
547
574
|
]);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
575
|
+
};
|
|
576
|
+
if (u.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
|
|
577
|
+
const g = (p) => {
|
|
578
|
+
const w = p.offsetX || p.layerX;
|
|
579
|
+
if (this.$handle_progress) {
|
|
580
|
+
const m = +this.$handle_progress.getAttribute("cx");
|
|
581
|
+
if (m > w - 1 && m < w + 1 || this.gantt.bar_being_dragged) return;
|
|
582
|
+
}
|
|
583
|
+
this.gantt.show_popup({
|
|
584
|
+
x: p.offsetX || p.layerX,
|
|
585
|
+
y: p.offsetY || p.layerY,
|
|
586
|
+
task: this.task,
|
|
587
|
+
target: this.$bar
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
u.on(this.group, "click", g), this.event_listeners.push({ event: "click", handler: g });
|
|
591
|
+
}
|
|
592
|
+
let i;
|
|
593
|
+
const n = (g) => {
|
|
594
|
+
i = setTimeout(() => {
|
|
564
595
|
this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
|
|
565
|
-
x:
|
|
566
|
-
y:
|
|
596
|
+
x: g.offsetX || g.layerX,
|
|
597
|
+
y: g.offsetY || g.layerY,
|
|
567
598
|
task: this.task,
|
|
568
599
|
target: this.$bar
|
|
569
600
|
}), this.gantt.$container.querySelector(`.highlight-${t}`).classList.remove("hide");
|
|
570
601
|
}, 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"));
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
602
|
+
};
|
|
603
|
+
u.on(this.group, "mouseenter", n), this.event_listeners.push({ event: "mouseenter", handler: n });
|
|
604
|
+
const s = () => {
|
|
605
|
+
var g, p;
|
|
606
|
+
clearTimeout(i), this.gantt.options.popup_on === "hover" && ((p = (g = this.gantt.popup) == null ? void 0 : g.hide) == null || p.call(g)), this.gantt.$container.querySelector(`.highlight-${t}`).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(() => {
|
|
574
607
|
this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
|
|
575
608
|
}, 200));
|
|
576
|
-
}
|
|
609
|
+
};
|
|
610
|
+
u.on(this.group, "mouseleave", s), this.event_listeners.push({ event: "mouseleave", handler: s });
|
|
611
|
+
const o = () => {
|
|
577
612
|
this.is_dragging = !0, this.hide_add_icon();
|
|
578
|
-
}
|
|
613
|
+
};
|
|
614
|
+
u.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
|
|
615
|
+
const a = () => {
|
|
579
616
|
setTimeout(() => {
|
|
580
617
|
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"));
|
|
581
618
|
}, 0);
|
|
582
|
-
}
|
|
619
|
+
};
|
|
620
|
+
u.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
|
|
621
|
+
const h = () => {
|
|
583
622
|
this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
|
|
584
|
-
}
|
|
623
|
+
};
|
|
624
|
+
u.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
|
|
625
|
+
const d = () => {
|
|
585
626
|
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]));
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
627
|
+
};
|
|
628
|
+
u.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
|
|
629
|
+
let _ = !1;
|
|
630
|
+
const c = (g) => {
|
|
631
|
+
if (!_)
|
|
632
|
+
return _ = !0, setTimeout(function() {
|
|
633
|
+
_ = !1;
|
|
592
634
|
}, 300), !1;
|
|
593
|
-
|
|
594
|
-
}
|
|
635
|
+
g.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]));
|
|
636
|
+
};
|
|
637
|
+
u.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
|
|
595
638
|
}
|
|
596
639
|
update_bar_position({ x: t = null, width: e = null }) {
|
|
597
640
|
const i = this.$bar;
|
|
598
|
-
|
|
599
|
-
if (!this.validate_dependency_constraints(t, e))
|
|
600
|
-
return;
|
|
601
|
-
this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px";
|
|
602
|
-
}
|
|
603
|
-
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();
|
|
641
|
+
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();
|
|
604
642
|
}
|
|
605
643
|
validate_dependency_constraints(t, e = null) {
|
|
606
644
|
const i = this.task.dependencies_type || this.gantt.options.dependencies_type;
|
|
607
645
|
if (i === "fixed")
|
|
608
|
-
return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_,
|
|
609
|
-
const
|
|
646
|
+
return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, c) => _ && t >= c, !0);
|
|
647
|
+
const n = t / this.gantt.config.column_width, s = l.add(
|
|
610
648
|
this.gantt.gantt_start,
|
|
611
|
-
|
|
649
|
+
n * this.gantt.config.step,
|
|
612
650
|
this.gantt.config.unit
|
|
613
|
-
), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h =
|
|
614
|
-
|
|
651
|
+
), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = l.add(
|
|
652
|
+
s,
|
|
615
653
|
a * this.gantt.config.step,
|
|
616
654
|
this.gantt.config.unit
|
|
617
655
|
);
|
|
618
656
|
for (const d of this.task.dependencies) {
|
|
619
657
|
const _ = this.gantt.get_bar(d);
|
|
620
658
|
if (!_) continue;
|
|
621
|
-
const
|
|
659
|
+
const c = _.task;
|
|
622
660
|
switch (i) {
|
|
623
661
|
case "finish-to-start":
|
|
624
|
-
if (
|
|
662
|
+
if (s < c._end)
|
|
625
663
|
return !1;
|
|
626
664
|
break;
|
|
627
665
|
case "start-to-start":
|
|
628
|
-
if (
|
|
666
|
+
if (s < c._start)
|
|
629
667
|
return !1;
|
|
630
668
|
break;
|
|
631
669
|
case "finish-to-finish":
|
|
632
|
-
if (h <
|
|
670
|
+
if (h < c._end)
|
|
633
671
|
return !1;
|
|
634
672
|
break;
|
|
635
673
|
case "start-to-finish":
|
|
636
|
-
if (h <
|
|
674
|
+
if (h < c._start)
|
|
637
675
|
return !1;
|
|
638
676
|
break;
|
|
639
677
|
}
|
|
@@ -641,9 +679,9 @@ class q {
|
|
|
641
679
|
return !0;
|
|
642
680
|
}
|
|
643
681
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
|
644
|
-
const i = this.gantt.$container,
|
|
645
|
-
let a = this.$bar.getX() + this.$bar.getWidth(), h =
|
|
646
|
-
|
|
682
|
+
const i = this.gantt.$container, n = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
|
|
683
|
+
let a = this.$bar.getX() + this.$bar.getWidth(), h = n.getX() + t, d = s && s.getX() + t || 0, _ = s && s.getBBox().width + 7 || 7, c = h + n.getBBox().width + 7, g = e + i.clientWidth / 2;
|
|
684
|
+
n.classList.contains("big") || (c < a && t > 0 && c < g || h - _ > this.$bar.getX() && t < 0 && c > g) && (n.setAttribute("x", h), s && (s.setAttribute("x", d), o.setAttribute("x", d)));
|
|
647
685
|
}
|
|
648
686
|
date_changed() {
|
|
649
687
|
let t = !1;
|
|
@@ -651,7 +689,7 @@ class q {
|
|
|
651
689
|
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", [
|
|
652
690
|
this.task,
|
|
653
691
|
e,
|
|
654
|
-
|
|
692
|
+
l.add(i, -1, "second")
|
|
655
693
|
]);
|
|
656
694
|
}
|
|
657
695
|
progress_changed() {
|
|
@@ -661,36 +699,36 @@ class q {
|
|
|
661
699
|
]);
|
|
662
700
|
}
|
|
663
701
|
set_action_completed() {
|
|
664
|
-
this.action_completed = !0, setTimeout(() => this.action_completed = !1,
|
|
702
|
+
this.action_completed = !0, setTimeout(() => this.action_completed = !1, 10), this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide");
|
|
665
703
|
}
|
|
666
704
|
compute_start_end_date() {
|
|
667
705
|
const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
|
|
668
|
-
let i =
|
|
706
|
+
let i = l.add(
|
|
669
707
|
this.gantt.gantt_start,
|
|
670
708
|
e * this.gantt.config.step,
|
|
671
709
|
this.gantt.config.unit
|
|
672
710
|
);
|
|
673
|
-
const
|
|
711
|
+
const n = t.getWidth() / this.gantt.config.column_width, s = l.add(
|
|
674
712
|
i,
|
|
675
|
-
|
|
713
|
+
n * this.gantt.config.step,
|
|
676
714
|
this.gantt.config.unit
|
|
677
715
|
);
|
|
678
|
-
return { new_start_date: i, new_end_date:
|
|
716
|
+
return { new_start_date: i, new_end_date: s };
|
|
679
717
|
}
|
|
680
718
|
compute_progress() {
|
|
681
719
|
this.progress_width = this.$bar_progress.getWidth(), this.x = this.$bar_progress.getBBox().x;
|
|
682
|
-
const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((
|
|
720
|
+
const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((n, s) => n + (s >= this.x && s <= t), 0) * this.gantt.config.column_width;
|
|
683
721
|
if (e < 0) return 0;
|
|
684
722
|
const i = this.$bar.getWidth() - this.ignored_duration_raw * this.gantt.config.column_width;
|
|
685
723
|
return parseInt(e / i * 100, 10);
|
|
686
724
|
}
|
|
687
725
|
compute_expected_progress() {
|
|
688
|
-
this.expected_progress =
|
|
726
|
+
this.expected_progress = l.diff(l.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;
|
|
689
727
|
}
|
|
690
728
|
compute_x() {
|
|
691
729
|
const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
|
|
692
|
-
let
|
|
693
|
-
this.x =
|
|
730
|
+
let s = l.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
|
|
731
|
+
this.x = s;
|
|
694
732
|
}
|
|
695
733
|
compute_y() {
|
|
696
734
|
this.y = this.gantt.config.header_height + this.gantt.options.padding / 2 + this.task._index * (this.height + this.gantt.options.padding);
|
|
@@ -699,12 +737,12 @@ class q {
|
|
|
699
737
|
let t = 0, e = 0;
|
|
700
738
|
for (let i = new Date(this.task._start); i < this.task._end; i.setDate(i.getDate() + 1))
|
|
701
739
|
e++, !this.gantt.config.ignored_dates.find(
|
|
702
|
-
(
|
|
740
|
+
(n) => n.getTime() === i.getTime()
|
|
703
741
|
) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
|
|
704
|
-
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration =
|
|
742
|
+
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = l.convert_scales(
|
|
705
743
|
e + "d",
|
|
706
744
|
this.gantt.config.unit
|
|
707
|
-
) / this.gantt.config.step, this.actual_duration_raw =
|
|
745
|
+
) / this.gantt.config.step, this.actual_duration_raw = l.convert_scales(
|
|
708
746
|
t + "d",
|
|
709
747
|
this.gantt.config.unit
|
|
710
748
|
) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
|
|
@@ -725,10 +763,10 @@ class q {
|
|
|
725
763
|
));
|
|
726
764
|
}
|
|
727
765
|
update_label_position() {
|
|
728
|
-
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"),
|
|
729
|
-
let
|
|
766
|
+
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img");
|
|
767
|
+
let s = 5, o = this.image_size + 10;
|
|
730
768
|
const a = i.getBBox().width, h = e.getWidth();
|
|
731
|
-
a > h ? (i.classList.add("big"),
|
|
769
|
+
a > h ? (i.classList.add("big"), n ? (n.setAttribute("x", e.getEndX() + s), t.setAttribute("x", e.getEndX() + s), i.setAttribute("x", e.getEndX() + o)) : i.setAttribute("x", e.getEndX() + s)) : (i.classList.remove("big"), n ? (n.setAttribute("x", e.getX() + s), t.setAttribute("x", e.getX() + s), i.setAttribute(
|
|
732
770
|
"x",
|
|
733
771
|
e.getX() + h / 2 + o
|
|
734
772
|
)) : i.setAttribute(
|
|
@@ -753,8 +791,8 @@ class q {
|
|
|
753
791
|
i = this.x + this.$bar.getWidth() + e;
|
|
754
792
|
else
|
|
755
793
|
return;
|
|
756
|
-
const
|
|
757
|
-
this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy",
|
|
794
|
+
const n = this.y + (this.height - t) / 2;
|
|
795
|
+
this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy", n + t / 2), this.$add_icon_vertical.setAttribute("x1", i + t / 2), this.$add_icon_vertical.setAttribute("y1", n + 5), this.$add_icon_vertical.setAttribute("x2", i + t / 2), this.$add_icon_vertical.setAttribute("y2", n + t - 5), this.$add_icon_horizontal.setAttribute("x1", i + 5), this.$add_icon_horizontal.setAttribute("y1", n + t / 2), this.$add_icon_horizontal.setAttribute("x2", i + t - 5), this.$add_icon_horizontal.setAttribute("y2", n + t / 2);
|
|
758
796
|
}
|
|
759
797
|
hide_add_icon() {
|
|
760
798
|
this.$add_icon_group && this.$add_icon_group.classList.add("hide");
|
|
@@ -777,9 +815,9 @@ class F {
|
|
|
777
815
|
<div class="actions"></div>
|
|
778
816
|
`, 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");
|
|
779
817
|
}
|
|
780
|
-
show({ x: t, y: e, task: i, target:
|
|
818
|
+
show({ x: t, y: e, task: i, target: n }) {
|
|
781
819
|
this.actions.innerHTML = "";
|
|
782
|
-
let
|
|
820
|
+
let s = this.popup_func({
|
|
783
821
|
task: i,
|
|
784
822
|
chart: this.gantt,
|
|
785
823
|
get_title: () => this.title,
|
|
@@ -797,28 +835,28 @@ class F {
|
|
|
797
835
|
typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
|
|
798
836
|
}
|
|
799
837
|
});
|
|
800
|
-
|
|
838
|
+
s !== !1 && (s && (this.parent.innerHTML = s), 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"));
|
|
801
839
|
}
|
|
802
840
|
hide() {
|
|
803
841
|
this.parent.classList.add("hide");
|
|
804
842
|
}
|
|
805
843
|
}
|
|
806
|
-
function
|
|
844
|
+
function H(r) {
|
|
807
845
|
const t = r.getFullYear();
|
|
808
846
|
return t - t % 10 + "";
|
|
809
847
|
}
|
|
810
848
|
function O(r, t, e) {
|
|
811
|
-
let i =
|
|
812
|
-
return `${
|
|
849
|
+
let i = l.add(r, 6, "day"), n = i.getMonth() !== r.getMonth() ? "D MMM" : "D", s = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
|
|
850
|
+
return `${l.format(r, s, e)} - ${l.format(i, n, e)}`;
|
|
813
851
|
}
|
|
814
|
-
const
|
|
852
|
+
const $ = [
|
|
815
853
|
{
|
|
816
854
|
name: "Hour",
|
|
817
855
|
padding: "7d",
|
|
818
856
|
step: "1h",
|
|
819
857
|
date_format: "YYYY-MM-DD HH:",
|
|
820
858
|
lower_text: "HH",
|
|
821
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
859
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D MMMM", e) : "",
|
|
822
860
|
upper_text_frequency: 24
|
|
823
861
|
},
|
|
824
862
|
{
|
|
@@ -827,7 +865,7 @@ const y = [
|
|
|
827
865
|
step: "6h",
|
|
828
866
|
date_format: "YYYY-MM-DD HH:",
|
|
829
867
|
lower_text: "HH",
|
|
830
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
868
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D MMM", e) : "",
|
|
831
869
|
upper_text_frequency: 4
|
|
832
870
|
},
|
|
833
871
|
{
|
|
@@ -836,7 +874,7 @@ const y = [
|
|
|
836
874
|
step: "12h",
|
|
837
875
|
date_format: "YYYY-MM-DD HH:",
|
|
838
876
|
lower_text: "HH",
|
|
839
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ?
|
|
877
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? l.format(r, "D MMM", e) : l.format(r, "D", e) : "",
|
|
840
878
|
upper_text_frequency: 2
|
|
841
879
|
},
|
|
842
880
|
{
|
|
@@ -844,8 +882,8 @@ const y = [
|
|
|
844
882
|
padding: "7d",
|
|
845
883
|
date_format: "YYYY-MM-DD",
|
|
846
884
|
step: "1d",
|
|
847
|
-
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
848
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
885
|
+
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D", e) : "",
|
|
886
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? l.format(r, "MMMM", e) : "",
|
|
849
887
|
thick_line: (r) => r.getDay() === 1
|
|
850
888
|
},
|
|
851
889
|
{
|
|
@@ -855,7 +893,7 @@ const y = [
|
|
|
855
893
|
date_format: "YYYY-MM-DD",
|
|
856
894
|
column_width: 140,
|
|
857
895
|
lower_text: O,
|
|
858
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
896
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? l.format(r, "MMMM", e) : "",
|
|
859
897
|
thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
|
|
860
898
|
upper_text_frequency: 4
|
|
861
899
|
},
|
|
@@ -866,7 +904,7 @@ const y = [
|
|
|
866
904
|
column_width: 120,
|
|
867
905
|
date_format: "YYYY-MM",
|
|
868
906
|
lower_text: "MMMM",
|
|
869
|
-
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ?
|
|
907
|
+
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? l.format(r, "YYYY", e) : "",
|
|
870
908
|
thick_line: (r) => r.getMonth() % 3 === 0,
|
|
871
909
|
snap_at: "7d"
|
|
872
910
|
},
|
|
@@ -876,7 +914,7 @@ const y = [
|
|
|
876
914
|
step: "1y",
|
|
877
915
|
column_width: 120,
|
|
878
916
|
date_format: "YYYY",
|
|
879
|
-
upper_text: (r, t, e) => !t ||
|
|
917
|
+
upper_text: (r, t, e) => !t || H(r) !== H(t) ? H(r) : "",
|
|
880
918
|
lower_text: "YYYY",
|
|
881
919
|
snap_at: "30d"
|
|
882
920
|
}
|
|
@@ -903,12 +941,12 @@ const y = [
|
|
|
903
941
|
padding: 18,
|
|
904
942
|
popup: (r) => {
|
|
905
943
|
r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
|
|
906
|
-
const t =
|
|
944
|
+
const t = l.format(
|
|
907
945
|
r.task._start,
|
|
908
946
|
"MMM D",
|
|
909
947
|
r.chart.options.language
|
|
910
|
-
), e =
|
|
911
|
-
|
|
948
|
+
), e = l.format(
|
|
949
|
+
l.add(r.task._end, -1, "second"),
|
|
912
950
|
"MMM D",
|
|
913
951
|
r.chart.options.language
|
|
914
952
|
);
|
|
@@ -926,7 +964,7 @@ const y = [
|
|
|
926
964
|
today_button: !0,
|
|
927
965
|
view_mode: "Day",
|
|
928
966
|
view_mode_select: !1,
|
|
929
|
-
view_modes:
|
|
967
|
+
view_modes: $,
|
|
930
968
|
is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6
|
|
931
969
|
};
|
|
932
970
|
class j {
|
|
@@ -936,12 +974,12 @@ class j {
|
|
|
936
974
|
setup_wrapper(t) {
|
|
937
975
|
let e, i;
|
|
938
976
|
if (typeof t == "string") {
|
|
939
|
-
let
|
|
940
|
-
if (!
|
|
977
|
+
let n = document.querySelector(t);
|
|
978
|
+
if (!n)
|
|
941
979
|
throw new ReferenceError(
|
|
942
980
|
`CSS selector "${t}" could not be found in DOM`
|
|
943
981
|
);
|
|
944
|
-
t =
|
|
982
|
+
t = n;
|
|
945
983
|
}
|
|
946
984
|
if (t instanceof HTMLElement)
|
|
947
985
|
i = t, e = t.querySelector("svg");
|
|
@@ -968,12 +1006,12 @@ class j {
|
|
|
968
1006
|
setup_options(t) {
|
|
969
1007
|
this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((i) => {
|
|
970
1008
|
if (typeof i == "string") {
|
|
971
|
-
const
|
|
972
|
-
(
|
|
1009
|
+
const n = $.find(
|
|
1010
|
+
(s) => s.name === i
|
|
973
1011
|
);
|
|
974
|
-
return
|
|
1012
|
+
return n || console.error(
|
|
975
1013
|
`The view mode "${i}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
|
|
976
|
-
),
|
|
1014
|
+
), n;
|
|
977
1015
|
}
|
|
978
1016
|
return i;
|
|
979
1017
|
}), t.view_mode = t.view_modes[0]), this.options = { ...I, ...t };
|
|
@@ -984,10 +1022,10 @@ class j {
|
|
|
984
1022
|
"upper-header-height": "upper_header_height"
|
|
985
1023
|
};
|
|
986
1024
|
for (let i in e) {
|
|
987
|
-
let
|
|
988
|
-
|
|
1025
|
+
let n = this.options[e[i]];
|
|
1026
|
+
n !== "auto" && this.$container.style.setProperty(
|
|
989
1027
|
"--gv-" + i,
|
|
990
|
-
|
|
1028
|
+
n + "px"
|
|
991
1029
|
);
|
|
992
1030
|
}
|
|
993
1031
|
if (this.config = {
|
|
@@ -1001,7 +1039,7 @@ class j {
|
|
|
1001
1039
|
this.config.ignored_function = i;
|
|
1002
1040
|
continue;
|
|
1003
1041
|
}
|
|
1004
|
-
typeof i == "string" && (i === "weekend" ? this.config.ignored_function = (
|
|
1042
|
+
typeof i == "string" && (i === "weekend" ? this.config.ignored_function = (n) => n.getDay() == 6 || n.getDay() == 0 : this.config.ignored_dates.push(/* @__PURE__ */ new Date(i + " ")));
|
|
1005
1043
|
}
|
|
1006
1044
|
} else
|
|
1007
1045
|
this.config.ignored_function = this.options.ignore;
|
|
@@ -1015,24 +1053,24 @@ class j {
|
|
|
1015
1053
|
return console.error(
|
|
1016
1054
|
`task "${e.id}" doesn't have a start date`
|
|
1017
1055
|
), !1;
|
|
1018
|
-
if (e._start =
|
|
1019
|
-
let { duration: h, scale: d } =
|
|
1020
|
-
e.end =
|
|
1056
|
+
if (e._start = l.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
|
|
1057
|
+
let { duration: h, scale: d } = l.parse_duration(a);
|
|
1058
|
+
e.end = l.add(e.end, h, d);
|
|
1021
1059
|
})), !e.end)
|
|
1022
1060
|
return console.error(`task "${e.id}" doesn't have an end date`), !1;
|
|
1023
|
-
if (e._end =
|
|
1061
|
+
if (e._end = l.parse(e.end), l.diff(e._end, e._start, "year") < 0)
|
|
1024
1062
|
return console.error(
|
|
1025
1063
|
`start of task can't be after end of task: in task "${e.id}"`
|
|
1026
1064
|
), !1;
|
|
1027
|
-
if (
|
|
1065
|
+
if (l.diff(e._end, e._start, "year") > 10)
|
|
1028
1066
|
return console.error(
|
|
1029
1067
|
`the duration of task "${e.id}" is too long (above ten years)`
|
|
1030
1068
|
), !1;
|
|
1031
|
-
if (e._index = i,
|
|
1069
|
+
if (e._index = i, l.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = l.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
|
|
1032
1070
|
let o = [];
|
|
1033
1071
|
e.dependencies && (o = e.dependencies.split(",").map((a) => a.trim().replaceAll(" ", "_")).filter((a) => a)), e.dependencies = o;
|
|
1034
1072
|
}
|
|
1035
|
-
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id =
|
|
1073
|
+
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = N(e), e;
|
|
1036
1074
|
}).filter((e) => e), this.setup_dependencies();
|
|
1037
1075
|
}
|
|
1038
1076
|
setup_dependencies() {
|
|
@@ -1045,16 +1083,16 @@ class j {
|
|
|
1045
1083
|
this.setup_tasks(t), this.change_view_mode();
|
|
1046
1084
|
}
|
|
1047
1085
|
update_task(t, e) {
|
|
1048
|
-
let i = this.tasks.find((
|
|
1049
|
-
Object.assign(i, e),
|
|
1086
|
+
let i = this.tasks.find((s) => s.id === t), n = this.bars[i._index];
|
|
1087
|
+
Object.assign(i, e), n.refresh();
|
|
1050
1088
|
}
|
|
1051
1089
|
change_view_mode(t = this.options.view_mode, e = !1) {
|
|
1052
|
-
typeof t == "string" && (t = this.options.view_modes.find((
|
|
1053
|
-
let i,
|
|
1054
|
-
e && (i = this.$container.scrollLeft,
|
|
1090
|
+
typeof t == "string" && (t = this.options.view_modes.find((s) => s.name === t));
|
|
1091
|
+
let i, n;
|
|
1092
|
+
e && (i = this.$container.scrollLeft, n = 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 = n), this.trigger_event("view_change", [t]);
|
|
1055
1093
|
}
|
|
1056
1094
|
update_view_scale(t) {
|
|
1057
|
-
let { duration: e, scale: i } =
|
|
1095
|
+
let { duration: e, scale: i } = l.parse_duration(t.step);
|
|
1058
1096
|
this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
|
|
1059
1097
|
"--gv-column-width",
|
|
1060
1098
|
this.config.column_width + "px"
|
|
@@ -1066,15 +1104,15 @@ class j {
|
|
|
1066
1104
|
setup_gantt_dates(t) {
|
|
1067
1105
|
let e, i;
|
|
1068
1106
|
this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
|
|
1069
|
-
for (let
|
|
1070
|
-
(!e ||
|
|
1071
|
-
if (e =
|
|
1107
|
+
for (let n of this.tasks)
|
|
1108
|
+
(!e || n._start < e) && (e = n._start), (!i || n._end > i) && (i = n._end);
|
|
1109
|
+
if (e = l.start_of(e, this.config.unit), i = l.start_of(i, this.config.unit), !t)
|
|
1072
1110
|
if (this.options.infinite_padding)
|
|
1073
|
-
this.gantt_start =
|
|
1111
|
+
this.gantt_start = l.add(
|
|
1074
1112
|
e,
|
|
1075
1113
|
-this.config.extend_by_units * 3,
|
|
1076
1114
|
this.config.unit
|
|
1077
|
-
), this.gantt_end =
|
|
1115
|
+
), this.gantt_end = l.add(
|
|
1078
1116
|
i,
|
|
1079
1117
|
this.config.extend_by_units * 3,
|
|
1080
1118
|
this.config.unit
|
|
@@ -1084,17 +1122,17 @@ class j {
|
|
|
1084
1122
|
this.config.view_mode.padding,
|
|
1085
1123
|
this.config.view_mode.padding
|
|
1086
1124
|
]);
|
|
1087
|
-
let [
|
|
1088
|
-
|
|
1125
|
+
let [n, s] = this.config.view_mode.padding.map(
|
|
1126
|
+
l.parse_duration
|
|
1089
1127
|
);
|
|
1090
|
-
this.gantt_start =
|
|
1128
|
+
this.gantt_start = l.add(
|
|
1091
1129
|
e,
|
|
1092
|
-
-
|
|
1093
|
-
s.scale
|
|
1094
|
-
), this.gantt_end = c.add(
|
|
1095
|
-
i,
|
|
1096
|
-
n.duration,
|
|
1130
|
+
-n.duration,
|
|
1097
1131
|
n.scale
|
|
1132
|
+
), this.gantt_end = l.add(
|
|
1133
|
+
i,
|
|
1134
|
+
s.duration,
|
|
1135
|
+
s.scale
|
|
1098
1136
|
);
|
|
1099
1137
|
}
|
|
1100
1138
|
this.config.date_format = this.config.view_mode.date_format || this.options.date_format, this.gantt_start.setHours(0, 0, 0, 0);
|
|
@@ -1102,7 +1140,7 @@ class j {
|
|
|
1102
1140
|
setup_date_values() {
|
|
1103
1141
|
let t = this.gantt_start;
|
|
1104
1142
|
for (this.dates = [t]; t < this.gantt_end; )
|
|
1105
|
-
t =
|
|
1143
|
+
t = l.add(
|
|
1106
1144
|
t,
|
|
1107
1145
|
this.config.step,
|
|
1108
1146
|
this.config.unit
|
|
@@ -1157,10 +1195,10 @@ class j {
|
|
|
1157
1195
|
make_grid_rows() {
|
|
1158
1196
|
const t = f("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
|
|
1159
1197
|
this.config.header_height;
|
|
1160
|
-
for (let
|
|
1198
|
+
for (let n = this.config.header_height; n < this.grid_height; n += i)
|
|
1161
1199
|
f("rect", {
|
|
1162
1200
|
x: 0,
|
|
1163
|
-
y:
|
|
1201
|
+
y: n,
|
|
1164
1202
|
width: e,
|
|
1165
1203
|
height: i,
|
|
1166
1204
|
class: "grid-row",
|
|
@@ -1187,8 +1225,8 @@ class j {
|
|
|
1187
1225
|
const e = document.createElement("option");
|
|
1188
1226
|
e.selected = !0, e.disabled = !0, e.textContent = "Mode", t.appendChild(e);
|
|
1189
1227
|
for (const i of this.options.view_modes) {
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1228
|
+
const n = document.createElement("option");
|
|
1229
|
+
n.value = i.name, n.textContent = i.name, i.name === this.config.view_mode.name && (n.selected = !0), t.appendChild(n);
|
|
1192
1230
|
}
|
|
1193
1231
|
t.addEventListener(
|
|
1194
1232
|
"change",
|
|
@@ -1204,21 +1242,21 @@ class j {
|
|
|
1204
1242
|
}
|
|
1205
1243
|
make_grid_ticks() {
|
|
1206
1244
|
if (this.options.lines === "none") return;
|
|
1207
|
-
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height,
|
|
1245
|
+
let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, n = f("g", {
|
|
1208
1246
|
class: "lines_layer",
|
|
1209
1247
|
append_to: this.layers.grid
|
|
1210
|
-
}),
|
|
1248
|
+
}), s = this.config.header_height;
|
|
1211
1249
|
const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
|
|
1212
1250
|
if (this.options.lines !== "vertical")
|
|
1213
1251
|
for (let h = this.config.header_height; h < this.grid_height; h += a)
|
|
1214
1252
|
f("line", {
|
|
1215
1253
|
x1: 0,
|
|
1216
|
-
y1:
|
|
1254
|
+
y1: s + a,
|
|
1217
1255
|
x2: o,
|
|
1218
|
-
y2:
|
|
1256
|
+
y2: s + a,
|
|
1219
1257
|
class: "row-line",
|
|
1220
|
-
append_to:
|
|
1221
|
-
}),
|
|
1258
|
+
append_to: n
|
|
1259
|
+
}), s += a;
|
|
1222
1260
|
if (this.options.lines !== "horizontal")
|
|
1223
1261
|
for (let h of this.dates) {
|
|
1224
1262
|
let d = "tick";
|
|
@@ -1226,7 +1264,7 @@ class j {
|
|
|
1226
1264
|
d: `M ${t} ${e} v ${i}`,
|
|
1227
1265
|
class: d,
|
|
1228
1266
|
append_to: this.layers.grid
|
|
1229
|
-
}), this.view_is("month") ? t +=
|
|
1267
|
+
}), this.view_is("month") ? t += l.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += l.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
|
|
1230
1268
|
}
|
|
1231
1269
|
}
|
|
1232
1270
|
highlight_holidays() {
|
|
@@ -1235,10 +1273,10 @@ class j {
|
|
|
1235
1273
|
for (let e in this.options.holidays) {
|
|
1236
1274
|
let i = this.options.holidays[e];
|
|
1237
1275
|
i === "weekend" && (i = this.options.is_weekend);
|
|
1238
|
-
let
|
|
1276
|
+
let n;
|
|
1239
1277
|
if (typeof i == "object") {
|
|
1240
|
-
let
|
|
1241
|
-
if (
|
|
1278
|
+
let s = i.find((o) => typeof o == "function");
|
|
1279
|
+
if (s && (n = s), this.options.holidays.name) {
|
|
1242
1280
|
let o = /* @__PURE__ */ new Date(i.date + " ");
|
|
1243
1281
|
i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
|
|
1244
1282
|
} else
|
|
@@ -1250,26 +1288,26 @@ class j {
|
|
|
1250
1288
|
return (/* @__PURE__ */ new Date(a + " ")).getTime();
|
|
1251
1289
|
}).includes(o.getTime());
|
|
1252
1290
|
}
|
|
1253
|
-
for (let
|
|
1291
|
+
for (let s = new Date(this.gantt_start); s <= this.gantt_end; s.setDate(s.getDate() + 1))
|
|
1254
1292
|
if (!(this.config.ignored_dates.find(
|
|
1255
|
-
(o) => o.getTime() ==
|
|
1256
|
-
) || this.config.ignored_function && this.config.ignored_function(
|
|
1257
|
-
const o =
|
|
1258
|
-
|
|
1293
|
+
(o) => o.getTime() == s.getTime()
|
|
1294
|
+
) || this.config.ignored_function && this.config.ignored_function(s)) && (i(s) || n && n(s))) {
|
|
1295
|
+
const o = l.diff(
|
|
1296
|
+
s,
|
|
1259
1297
|
this.gantt_start,
|
|
1260
1298
|
this.config.unit
|
|
1261
|
-
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h =
|
|
1262
|
-
if (t[
|
|
1299
|
+
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = l.format(s, "YYYY-MM-DD", this.options.language).replace(" ", "_");
|
|
1300
|
+
if (t[s]) {
|
|
1263
1301
|
let d = this.create_el({
|
|
1264
1302
|
classes: "holiday-label label_" + h,
|
|
1265
1303
|
append_to: this.$extras
|
|
1266
1304
|
});
|
|
1267
|
-
d.textContent = t[
|
|
1305
|
+
d.textContent = t[s];
|
|
1268
1306
|
}
|
|
1269
1307
|
f("rect", {
|
|
1270
1308
|
x: Math.round(o),
|
|
1271
1309
|
y: this.config.header_height,
|
|
1272
|
-
width: this.config.column_width /
|
|
1310
|
+
width: this.config.column_width / l.convert_scales(
|
|
1273
1311
|
this.config.view_mode.step,
|
|
1274
1312
|
"day"
|
|
1275
1313
|
),
|
|
@@ -1291,20 +1329,20 @@ class j {
|
|
|
1291
1329
|
if (!t) return;
|
|
1292
1330
|
const [e, i] = t;
|
|
1293
1331
|
i.classList.add("current-date-highlight");
|
|
1294
|
-
const
|
|
1332
|
+
const s = l.diff(
|
|
1295
1333
|
/* @__PURE__ */ new Date(),
|
|
1296
1334
|
this.gantt_start,
|
|
1297
1335
|
this.config.unit
|
|
1298
1336
|
) / this.config.step * this.config.column_width;
|
|
1299
1337
|
this.$current_highlight = this.create_el({
|
|
1300
1338
|
top: this.config.header_height,
|
|
1301
|
-
left:
|
|
1339
|
+
left: s,
|
|
1302
1340
|
height: this.grid_height - this.config.header_height,
|
|
1303
1341
|
classes: "current-highlight",
|
|
1304
1342
|
append_to: this.$container
|
|
1305
1343
|
}), this.$current_ball_highlight = this.create_el({
|
|
1306
1344
|
top: this.config.header_height - 6,
|
|
1307
|
-
left:
|
|
1345
|
+
left: s - 2.5,
|
|
1308
1346
|
width: 6,
|
|
1309
1347
|
height: 6,
|
|
1310
1348
|
classes: "current-ball-highlight",
|
|
@@ -1322,15 +1360,15 @@ class j {
|
|
|
1322
1360
|
</pattern>`;
|
|
1323
1361
|
for (let i = new Date(this.gantt_start); i <= this.gantt_end; i.setDate(i.getDate() + 1)) {
|
|
1324
1362
|
if (!this.config.ignored_dates.find(
|
|
1325
|
-
(
|
|
1363
|
+
(s) => s.getTime() == i.getTime()
|
|
1326
1364
|
) && (!this.config.ignored_function || !this.config.ignored_function(i)))
|
|
1327
1365
|
continue;
|
|
1328
|
-
let
|
|
1329
|
-
|
|
1366
|
+
let n = l.convert_scales(
|
|
1367
|
+
l.diff(i, this.gantt_start) + "d",
|
|
1330
1368
|
this.config.unit
|
|
1331
1369
|
) / this.config.step;
|
|
1332
|
-
this.config.ignored_positions.push(
|
|
1333
|
-
x:
|
|
1370
|
+
this.config.ignored_positions.push(n * this.config.column_width), f("rect", {
|
|
1371
|
+
x: n * this.config.column_width,
|
|
1334
1372
|
y: this.config.header_height,
|
|
1335
1373
|
width: this.config.column_width,
|
|
1336
1374
|
height: t,
|
|
@@ -1343,10 +1381,10 @@ class j {
|
|
|
1343
1381
|
this.config.view_mode
|
|
1344
1382
|
);
|
|
1345
1383
|
}
|
|
1346
|
-
create_el({ left: t, top: e, width: i, height:
|
|
1384
|
+
create_el({ left: t, top: e, width: i, height: n, id: s, classes: o, append_to: a, type: h }) {
|
|
1347
1385
|
let d = document.createElement(h || "div");
|
|
1348
1386
|
for (let _ of o.split(" ")) d.classList.add(_);
|
|
1349
|
-
return d.style.top = e + "px", d.style.left = t + "px",
|
|
1387
|
+
return d.style.top = e + "px", d.style.left = t + "px", s && (d.id = s), i && (d.style.width = i + "px"), n && (d.style.height = n + "px"), a && a.appendChild(d), d;
|
|
1350
1388
|
}
|
|
1351
1389
|
make_dates() {
|
|
1352
1390
|
this.get_dates_to_draw().forEach((t, e) => {
|
|
@@ -1374,27 +1412,27 @@ class j {
|
|
|
1374
1412
|
}
|
|
1375
1413
|
get_dates_to_draw() {
|
|
1376
1414
|
let t = null;
|
|
1377
|
-
return this.dates.map((i,
|
|
1378
|
-
const
|
|
1379
|
-
return t =
|
|
1415
|
+
return this.dates.map((i, n) => {
|
|
1416
|
+
const s = this.get_date_info(i, t, n);
|
|
1417
|
+
return t = s, s;
|
|
1380
1418
|
});
|
|
1381
1419
|
}
|
|
1382
1420
|
get_date_info(t, e) {
|
|
1383
1421
|
let i = e ? e.date : null;
|
|
1384
1422
|
this.config.column_width;
|
|
1385
|
-
const
|
|
1386
|
-
let
|
|
1387
|
-
return
|
|
1423
|
+
const n = e ? e.x + e.column_width : 0;
|
|
1424
|
+
let s = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
|
|
1425
|
+
return s ? typeof s == "string" && (this.config.view_mode.upper_text = (a) => l.format(a, s, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => l.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
|
|
1388
1426
|
date: t,
|
|
1389
1427
|
formatted_date: k(
|
|
1390
|
-
|
|
1428
|
+
l.format(
|
|
1391
1429
|
t,
|
|
1392
1430
|
this.config.date_format,
|
|
1393
1431
|
this.options.language
|
|
1394
1432
|
)
|
|
1395
1433
|
),
|
|
1396
1434
|
column_width: this.config.column_width,
|
|
1397
|
-
x:
|
|
1435
|
+
x: n,
|
|
1398
1436
|
upper_text: this.config.view_mode.upper_text(
|
|
1399
1437
|
t,
|
|
1400
1438
|
i,
|
|
@@ -1420,56 +1458,56 @@ class j {
|
|
|
1420
1458
|
for (let t of this.tasks) {
|
|
1421
1459
|
let e = [];
|
|
1422
1460
|
e = t.dependencies.map((i) => {
|
|
1423
|
-
const
|
|
1424
|
-
if (!
|
|
1425
|
-
const
|
|
1461
|
+
const n = this.get_task(i);
|
|
1462
|
+
if (!n) return;
|
|
1463
|
+
const s = new C(
|
|
1426
1464
|
this,
|
|
1427
|
-
this.bars[
|
|
1465
|
+
this.bars[n._index],
|
|
1428
1466
|
// from_task
|
|
1429
1467
|
this.bars[t._index]
|
|
1430
1468
|
// to_task
|
|
1431
1469
|
);
|
|
1432
|
-
return this.layers.arrow.appendChild(
|
|
1470
|
+
return this.layers.arrow.appendChild(s.element), s;
|
|
1433
1471
|
}).filter(Boolean), this.arrows = this.arrows.concat(e);
|
|
1434
1472
|
}
|
|
1435
1473
|
}
|
|
1436
1474
|
calculate_critical_path() {
|
|
1437
|
-
this.tasks.forEach((
|
|
1475
|
+
this.tasks.forEach((s) => s._is_critical = !1);
|
|
1438
1476
|
const t = {};
|
|
1439
|
-
this.tasks.forEach((
|
|
1440
|
-
t[
|
|
1477
|
+
this.tasks.forEach((s) => {
|
|
1478
|
+
t[s.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
|
|
1441
1479
|
});
|
|
1442
|
-
const e = (
|
|
1443
|
-
if (t[
|
|
1480
|
+
const e = (s) => {
|
|
1481
|
+
if (t[s.id].ef > 0) return t[s.id];
|
|
1444
1482
|
let o = 0;
|
|
1445
|
-
|
|
1483
|
+
s.dependencies && s.dependencies.length > 0 && s.dependencies.forEach((h) => {
|
|
1446
1484
|
const d = this.get_task(h);
|
|
1447
1485
|
if (d) {
|
|
1448
1486
|
const _ = e(d);
|
|
1449
1487
|
o = Math.max(o, _.ef);
|
|
1450
1488
|
}
|
|
1451
|
-
}), t[
|
|
1452
|
-
const a =
|
|
1453
|
-
return t[
|
|
1489
|
+
}), t[s.id].es = o;
|
|
1490
|
+
const a = l.diff(s._end, s._start, "hour") / 24;
|
|
1491
|
+
return t[s.id].ef = o + a, t[s.id];
|
|
1454
1492
|
};
|
|
1455
|
-
this.tasks.forEach((
|
|
1456
|
-
const i = Math.max(...Object.values(t).map((
|
|
1457
|
-
if (t[
|
|
1458
|
-
return t[
|
|
1493
|
+
this.tasks.forEach((s) => e(s));
|
|
1494
|
+
const i = Math.max(...Object.values(t).map((s) => s.ef)), n = (s) => {
|
|
1495
|
+
if (t[s.id].ls > 0 || t[s.id].lf > 0)
|
|
1496
|
+
return t[s.id];
|
|
1459
1497
|
const o = this.tasks.filter(
|
|
1460
|
-
(d) => d.dependencies && d.dependencies.includes(
|
|
1498
|
+
(d) => d.dependencies && d.dependencies.includes(s.id)
|
|
1461
1499
|
);
|
|
1462
1500
|
let a = i;
|
|
1463
1501
|
o.length > 0 && o.forEach((d) => {
|
|
1464
|
-
const _ =
|
|
1502
|
+
const _ = n(d);
|
|
1465
1503
|
a = Math.min(a, _.ls);
|
|
1466
1504
|
});
|
|
1467
|
-
const h =
|
|
1468
|
-
return t[
|
|
1505
|
+
const h = l.diff(s._end, s._start, "hour") / 24;
|
|
1506
|
+
return t[s.id].lf = a, t[s.id].ls = a - h, t[s.id];
|
|
1469
1507
|
};
|
|
1470
|
-
this.tasks.forEach((
|
|
1471
|
-
const o = t[
|
|
1472
|
-
|
|
1508
|
+
this.tasks.forEach((s) => n(s)), this.tasks.forEach((s) => {
|
|
1509
|
+
const o = t[s.id], a = o.ls - o.es;
|
|
1510
|
+
s._is_critical = Math.abs(a) < 0.01;
|
|
1473
1511
|
});
|
|
1474
1512
|
}
|
|
1475
1513
|
update_arrow_critical_path() {
|
|
@@ -1498,9 +1536,9 @@ class j {
|
|
|
1498
1536
|
else {
|
|
1499
1537
|
if (t === "today")
|
|
1500
1538
|
return this.scroll_current();
|
|
1501
|
-
typeof t == "string" && (t =
|
|
1539
|
+
typeof t == "string" && (t = l.parse(t));
|
|
1502
1540
|
}
|
|
1503
|
-
const i =
|
|
1541
|
+
const i = l.diff(
|
|
1504
1542
|
t,
|
|
1505
1543
|
this.gantt_start,
|
|
1506
1544
|
this.config.unit
|
|
@@ -1508,27 +1546,27 @@ class j {
|
|
|
1508
1546
|
this.$container.scrollTo({
|
|
1509
1547
|
left: i - this.config.column_width / 6,
|
|
1510
1548
|
behavior: "smooth"
|
|
1511
|
-
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date =
|
|
1549
|
+
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date = l.add(
|
|
1512
1550
|
this.gantt_start,
|
|
1513
1551
|
this.$container.scrollLeft / this.config.column_width,
|
|
1514
1552
|
this.config.unit
|
|
1515
1553
|
);
|
|
1516
|
-
let
|
|
1554
|
+
let n = this.config.view_mode.upper_text(
|
|
1517
1555
|
this.current_date,
|
|
1518
1556
|
null,
|
|
1519
1557
|
this.options.language
|
|
1520
|
-
),
|
|
1521
|
-
(o) => o.textContent ===
|
|
1558
|
+
), s = this.upperTexts.find(
|
|
1559
|
+
(o) => o.textContent === n
|
|
1522
1560
|
);
|
|
1523
|
-
this.current_date =
|
|
1561
|
+
this.current_date = l.add(
|
|
1524
1562
|
this.gantt_start,
|
|
1525
|
-
(this.$container.scrollLeft +
|
|
1563
|
+
(this.$container.scrollLeft + s.clientWidth) / this.config.column_width,
|
|
1526
1564
|
this.config.unit
|
|
1527
|
-
),
|
|
1565
|
+
), n = this.config.view_mode.upper_text(
|
|
1528
1566
|
this.current_date,
|
|
1529
1567
|
null,
|
|
1530
1568
|
this.options.language
|
|
1531
|
-
),
|
|
1569
|
+
), s = this.upperTexts.find((o) => o.textContent === n), s.classList.add("current-upper"), this.$current = s;
|
|
1532
1570
|
}
|
|
1533
1571
|
scroll_current() {
|
|
1534
1572
|
let t = this.get_closest_date();
|
|
@@ -1539,26 +1577,26 @@ class j {
|
|
|
1539
1577
|
if (t < this.gantt_start || t > this.gantt_end) return null;
|
|
1540
1578
|
let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
|
|
1541
1579
|
".date_" + k(
|
|
1542
|
-
|
|
1580
|
+
l.format(
|
|
1543
1581
|
e,
|
|
1544
1582
|
this.config.date_format,
|
|
1545
1583
|
this.options.language
|
|
1546
1584
|
)
|
|
1547
1585
|
)
|
|
1548
|
-
),
|
|
1549
|
-
for (; !i &&
|
|
1550
|
-
e =
|
|
1586
|
+
), n = 0;
|
|
1587
|
+
for (; !i && n < this.config.step; )
|
|
1588
|
+
e = l.add(e, -1, this.config.unit), i = this.$container.querySelector(
|
|
1551
1589
|
".date_" + k(
|
|
1552
|
-
|
|
1590
|
+
l.format(
|
|
1553
1591
|
e,
|
|
1554
1592
|
this.config.date_format,
|
|
1555
1593
|
this.options.language
|
|
1556
1594
|
)
|
|
1557
1595
|
)
|
|
1558
|
-
),
|
|
1596
|
+
), n++;
|
|
1559
1597
|
return [
|
|
1560
1598
|
/* @__PURE__ */ new Date(
|
|
1561
|
-
|
|
1599
|
+
l.format(
|
|
1562
1600
|
e,
|
|
1563
1601
|
this.config.date_format,
|
|
1564
1602
|
this.options.language
|
|
@@ -1584,157 +1622,151 @@ class j {
|
|
|
1584
1622
|
".label_" + e.classList[1]
|
|
1585
1623
|
);
|
|
1586
1624
|
if (!i) continue;
|
|
1587
|
-
let
|
|
1588
|
-
e.onmouseenter = (
|
|
1589
|
-
|
|
1590
|
-
i.classList.add("show"), i.style.left = (
|
|
1625
|
+
let n;
|
|
1626
|
+
e.onmouseenter = (s) => {
|
|
1627
|
+
n = setTimeout(() => {
|
|
1628
|
+
i.classList.add("show"), i.style.left = (s.offsetX || s.layerX) + "px", i.style.top = (s.offsetY || s.layerY) + "px";
|
|
1591
1629
|
}, 300);
|
|
1592
|
-
}, e.onmouseleave = (
|
|
1593
|
-
clearTimeout(
|
|
1630
|
+
}, e.onmouseleave = (s) => {
|
|
1631
|
+
clearTimeout(n), i.classList.remove("show");
|
|
1594
1632
|
};
|
|
1595
1633
|
}
|
|
1596
1634
|
}
|
|
1597
1635
|
get_start_end_positions() {
|
|
1598
1636
|
if (!this.bars.length) return [0, 0, 0];
|
|
1599
|
-
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t,
|
|
1637
|
+
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, n = t, s = t + e;
|
|
1600
1638
|
return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
|
|
1601
1639
|
let { x: h, width: d } = o.getBBox();
|
|
1602
|
-
h < i && (i = h), h >
|
|
1603
|
-
}), [i,
|
|
1640
|
+
h < i && (i = h), h > n && (n = h), h + d > s && (s = h + d);
|
|
1641
|
+
}), [i, n, s];
|
|
1604
1642
|
}
|
|
1605
1643
|
bind_bar_events() {
|
|
1606
|
-
let t = !1, e = 0, i = 0,
|
|
1644
|
+
let t = !1, e = 0, i = 0, n = !1, s = !1, o = null, a = [];
|
|
1607
1645
|
this.bar_being_dragged = null;
|
|
1608
|
-
const h = () => t ||
|
|
1646
|
+
const h = () => t || n || s;
|
|
1609
1647
|
this.$svg.onclick = (_) => {
|
|
1610
1648
|
_.target.classList.contains("grid-row") && this.unselect_all();
|
|
1611
1649
|
};
|
|
1612
1650
|
let d = 0;
|
|
1613
1651
|
if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
|
|
1614
1652
|
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
|
|
1615
|
-
}), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_,
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
const
|
|
1653
|
+
}), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, c) => {
|
|
1654
|
+
const g = u.closest(".bar-wrapper", c);
|
|
1655
|
+
c.classList.contains("left") ? (n = !0, c.classList.add("visible")) : c.classList.contains("right") ? (s = !0, c.classList.add("visible")) : c.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = g.getAttribute("data-id");
|
|
1656
|
+
const w = this.get_bar(o).task.dependencies_type || this.options.dependencies_type;
|
|
1619
1657
|
let m;
|
|
1620
|
-
this.options.move_dependencies &&
|
|
1658
|
+
this.options.move_dependencies && w === "fixed" ? m = [
|
|
1621
1659
|
o,
|
|
1622
1660
|
...this.get_all_dependent_tasks(o)
|
|
1623
|
-
] : m = [o], a = m.map((
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1661
|
+
] : m = [o], a = m.map((v) => this.get_bar(v)), this.bar_being_dragged = !1, d = e, a.forEach((v) => {
|
|
1662
|
+
const b = v.$bar;
|
|
1663
|
+
b.ox = b.getX(), b.oy = b.getY(), b.owidth = b.getWidth(), b.finaldx = 0;
|
|
1626
1664
|
});
|
|
1627
1665
|
}), this.options.infinite_padding) {
|
|
1628
1666
|
let _ = !1;
|
|
1629
|
-
u.on(this.$container, "mousewheel", (
|
|
1630
|
-
let
|
|
1631
|
-
if (!_ &&
|
|
1632
|
-
let
|
|
1633
|
-
_ = !0, this.gantt_start =
|
|
1667
|
+
u.on(this.$container, "mousewheel", (c) => {
|
|
1668
|
+
let g = this.$container.scrollWidth / 2;
|
|
1669
|
+
if (!_ && c.currentTarget.scrollLeft <= g) {
|
|
1670
|
+
let p = c.currentTarget.scrollLeft;
|
|
1671
|
+
_ = !0, this.gantt_start = l.add(
|
|
1634
1672
|
this.gantt_start,
|
|
1635
1673
|
-this.config.extend_by_units,
|
|
1636
1674
|
this.config.unit
|
|
1637
|
-
), this.setup_date_values(), this.render(),
|
|
1675
|
+
), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = p + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
|
|
1638
1676
|
}
|
|
1639
|
-
if (!_ &&
|
|
1640
|
-
let
|
|
1641
|
-
_ = !0, this.gantt_end =
|
|
1677
|
+
if (!_ && c.currentTarget.scrollWidth - (c.currentTarget.scrollLeft + c.currentTarget.clientWidth) <= g) {
|
|
1678
|
+
let p = c.currentTarget.scrollLeft;
|
|
1679
|
+
_ = !0, this.gantt_end = l.add(
|
|
1642
1680
|
this.gantt_end,
|
|
1643
1681
|
this.config.extend_by_units,
|
|
1644
1682
|
this.config.unit
|
|
1645
|
-
), this.setup_date_values(), this.render(),
|
|
1683
|
+
), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = p, setTimeout(() => _ = !1, 300);
|
|
1646
1684
|
}
|
|
1647
1685
|
});
|
|
1648
1686
|
}
|
|
1649
1687
|
u.on(this.$container, "scroll", (_) => {
|
|
1650
|
-
let
|
|
1651
|
-
const
|
|
1652
|
-
({ group:
|
|
1688
|
+
let c = [];
|
|
1689
|
+
const g = this.bars.map(
|
|
1690
|
+
({ group: y }) => y.getAttribute("data-id")
|
|
1653
1691
|
);
|
|
1654
|
-
let
|
|
1655
|
-
i && (
|
|
1692
|
+
let p;
|
|
1693
|
+
i && (p = _.currentTarget.scrollLeft - i), this.current_date = l.add(
|
|
1656
1694
|
this.gantt_start,
|
|
1657
1695
|
_.currentTarget.scrollLeft / this.config.column_width * this.config.step,
|
|
1658
1696
|
this.config.unit
|
|
1659
1697
|
);
|
|
1660
|
-
let
|
|
1698
|
+
let w = this.config.view_mode.upper_text(
|
|
1661
1699
|
this.current_date,
|
|
1662
1700
|
null,
|
|
1663
1701
|
this.options.language
|
|
1664
1702
|
), m = this.upperTexts.find(
|
|
1665
|
-
(
|
|
1703
|
+
(y) => y.textContent === w
|
|
1666
1704
|
);
|
|
1667
|
-
this.current_date =
|
|
1705
|
+
this.current_date = l.add(
|
|
1668
1706
|
this.gantt_start,
|
|
1669
1707
|
(_.currentTarget.scrollLeft + m.clientWidth) / this.config.column_width * this.config.step,
|
|
1670
1708
|
this.config.unit
|
|
1671
|
-
),
|
|
1709
|
+
), w = this.config.view_mode.upper_text(
|
|
1672
1710
|
this.current_date,
|
|
1673
1711
|
null,
|
|
1674
1712
|
this.options.language
|
|
1675
1713
|
), m = this.upperTexts.find(
|
|
1676
|
-
(
|
|
1714
|
+
(y) => y.textContent === w
|
|
1677
1715
|
), m !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), m.classList.add("current-upper"), this.$current = m), i = _.currentTarget.scrollLeft;
|
|
1678
|
-
let [
|
|
1716
|
+
let [v, b, X] = this.get_start_end_positions();
|
|
1679
1717
|
i > X + 100 ? (this.$adjust.innerHTML = "←", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1680
1718
|
this.$container.scrollTo({
|
|
1681
|
-
left:
|
|
1719
|
+
left: b,
|
|
1682
1720
|
behavior: "smooth"
|
|
1683
1721
|
});
|
|
1684
|
-
}) : i + _.currentTarget.offsetWidth <
|
|
1722
|
+
}) : i + _.currentTarget.offsetWidth < v - 100 ? (this.$adjust.innerHTML = "→", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
|
|
1685
1723
|
this.$container.scrollTo({
|
|
1686
|
-
left:
|
|
1724
|
+
left: v,
|
|
1687
1725
|
behavior: "smooth"
|
|
1688
1726
|
});
|
|
1689
|
-
}) : this.$adjust.classList.add("hide"),
|
|
1690
|
-
|
|
1691
|
-
x:
|
|
1727
|
+
}) : this.$adjust.classList.add("hide"), p && (c = g.map((y) => this.get_bar(y)), this.options.auto_move_label && c.forEach((y) => {
|
|
1728
|
+
y.update_label_position_on_horizontal_scroll({
|
|
1729
|
+
x: p,
|
|
1692
1730
|
sx: _.currentTarget.scrollLeft
|
|
1693
1731
|
});
|
|
1694
1732
|
}));
|
|
1695
1733
|
}), u.on(this.$svg, "mousemove", (_) => {
|
|
1696
1734
|
if (!h()) return;
|
|
1697
|
-
const
|
|
1698
|
-
a.forEach((
|
|
1699
|
-
const
|
|
1700
|
-
|
|
1701
|
-
x:
|
|
1702
|
-
width:
|
|
1703
|
-
}) :
|
|
1704
|
-
x:
|
|
1705
|
-
}) :
|
|
1706
|
-
width:
|
|
1707
|
-
}) : t && !this.options.readonly && !this.options.readonly_dates &&
|
|
1735
|
+
const c = (_.offsetX || _.layerX) - e;
|
|
1736
|
+
a.forEach((g) => {
|
|
1737
|
+
const p = g.$bar;
|
|
1738
|
+
p.finaldx = this.get_snap_position(c, p.ox), this.hide_popup(), n ? o === g.task.id ? g.update_bar_position({
|
|
1739
|
+
x: p.ox + p.finaldx,
|
|
1740
|
+
width: p.owidth - p.finaldx
|
|
1741
|
+
}) : g.update_bar_position({
|
|
1742
|
+
x: p.ox + p.finaldx
|
|
1743
|
+
}) : s ? o === g.task.id && g.update_bar_position({
|
|
1744
|
+
width: p.owidth + p.finaldx
|
|
1745
|
+
}) : t && !this.options.readonly && !this.options.readonly_dates && g.update_bar_position({ x: p.ox + p.finaldx });
|
|
1708
1746
|
});
|
|
1709
1747
|
}), document.addEventListener("mouseup", () => {
|
|
1710
|
-
var _,
|
|
1711
|
-
t = !1,
|
|
1748
|
+
var _, c, g;
|
|
1749
|
+
t = !1, n = !1, s = !1, (g = (c = (_ = this.$container.querySelector(".visible")) == null ? void 0 : _.classList) == null ? void 0 : c.remove) == null || g.call(c, "visible");
|
|
1712
1750
|
}), u.on(this.$svg, "mouseup", (_) => {
|
|
1713
1751
|
this.bar_being_dragged = null;
|
|
1714
|
-
const
|
|
1752
|
+
const c = [];
|
|
1715
1753
|
a.forEach((g) => {
|
|
1716
|
-
g.$bar.finaldx && (g.date_changed(), g.compute_progress(), g.set_action_completed(),
|
|
1754
|
+
g.$bar.finaldx && (g.date_changed(), g.compute_progress(), g.set_action_completed(), c.push({
|
|
1717
1755
|
task: g.task,
|
|
1718
1756
|
start: g.task._start,
|
|
1719
|
-
end:
|
|
1757
|
+
end: l.add(g.task._end, -1, "second")
|
|
1720
1758
|
}));
|
|
1721
|
-
})
|
|
1722
|
-
|
|
1723
|
-
if (p && p.$bar.finaldx) {
|
|
1724
|
-
const g = this.update_dependent_tasks_by_type(p);
|
|
1725
|
-
l.push(...g);
|
|
1726
|
-
}
|
|
1727
|
-
this.options.critical_path && a.some((g) => g.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && l.forEach(({ task: g, start: $, end: m }) => {
|
|
1728
|
-
this.trigger_event("after_date_change", [g, $, m]);
|
|
1759
|
+
}), this.options.critical_path && a.some((g) => g.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), c.length > 0 && c.forEach(({ task: g, start: p, end: w }) => {
|
|
1760
|
+
this.trigger_event("after_date_change", [g, p, w]);
|
|
1729
1761
|
});
|
|
1730
1762
|
}), this.bind_bar_progress();
|
|
1731
1763
|
}
|
|
1732
1764
|
bind_bar_progress() {
|
|
1733
|
-
let t = 0, e = null, i = null,
|
|
1765
|
+
let t = 0, e = null, i = null, n = null, s = null;
|
|
1734
1766
|
u.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
|
|
1735
1767
|
e = !0, t = a.offsetX || a.layerX;
|
|
1736
1768
|
const _ = u.closest(".bar-wrapper", h).getAttribute("data-id");
|
|
1737
|
-
i = this.get_bar(_),
|
|
1769
|
+
i = this.get_bar(_), n = i.$bar_progress, s = i.$bar, n.finaldx = 0, n.owidth = n.getWidth(), n.min_dx = -n.owidth, n.max_dx = s.getWidth() - n.getWidth();
|
|
1738
1770
|
});
|
|
1739
1771
|
const o = this.config.ignored_positions.map((a) => [
|
|
1740
1772
|
a,
|
|
@@ -1744,87 +1776,87 @@ class j {
|
|
|
1744
1776
|
if (!e) return;
|
|
1745
1777
|
let h = a.offsetX || a.layerX;
|
|
1746
1778
|
if (h > t) {
|
|
1747
|
-
let
|
|
1748
|
-
([
|
|
1779
|
+
let c = o.find(
|
|
1780
|
+
([g, p]) => h >= g && h < p
|
|
1749
1781
|
);
|
|
1750
|
-
for (;
|
|
1751
|
-
h =
|
|
1752
|
-
([
|
|
1782
|
+
for (; c; )
|
|
1783
|
+
h = c[1], c = o.find(
|
|
1784
|
+
([g, p]) => h >= g && h < p
|
|
1753
1785
|
);
|
|
1754
1786
|
} else {
|
|
1755
|
-
let
|
|
1756
|
-
([
|
|
1787
|
+
let c = o.find(
|
|
1788
|
+
([g, p]) => h > g && h <= p
|
|
1757
1789
|
);
|
|
1758
|
-
for (;
|
|
1759
|
-
h =
|
|
1760
|
-
([
|
|
1790
|
+
for (; c; )
|
|
1791
|
+
h = c[0], c = o.find(
|
|
1792
|
+
([g, p]) => h > g && h <= p
|
|
1761
1793
|
);
|
|
1762
1794
|
}
|
|
1763
1795
|
let _ = h - t;
|
|
1764
|
-
console.log(
|
|
1796
|
+
console.log(n), _ > n.max_dx && (_ = n.max_dx), _ < n.min_dx && (_ = n.min_dx), n.setAttribute("width", n.owidth + _), u.attr(i.$handle_progress, "cx", n.getEndX()), n.finaldx = _;
|
|
1765
1797
|
}), u.on(this.$svg, "mouseup", () => {
|
|
1766
|
-
e = !1,
|
|
1798
|
+
e = !1, n && n.finaldx && (n.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, n = null, s = null);
|
|
1767
1799
|
});
|
|
1768
1800
|
}
|
|
1769
1801
|
get_all_dependent_tasks(t) {
|
|
1770
1802
|
let e = [], i = [t];
|
|
1771
1803
|
for (; i.length; ) {
|
|
1772
|
-
const
|
|
1773
|
-
e = e.concat(
|
|
1804
|
+
const n = i.reduce((s, o) => (s = s.concat(this.dependency_map[o]), s), []);
|
|
1805
|
+
e = e.concat(n), i = n.filter((s) => !i.includes(s));
|
|
1774
1806
|
}
|
|
1775
1807
|
return e.filter(Boolean);
|
|
1776
1808
|
}
|
|
1777
1809
|
update_dependent_tasks_by_type(t) {
|
|
1778
1810
|
const e = t.task.dependencies_type || this.options.dependencies_type, i = [];
|
|
1779
|
-
return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((
|
|
1780
|
-
const o = this.get_bar(
|
|
1811
|
+
return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((s) => {
|
|
1812
|
+
const o = this.get_bar(s);
|
|
1781
1813
|
if (!o) return;
|
|
1782
1814
|
const a = o.task, h = a.dependencies_type || this.options.dependencies_type;
|
|
1783
1815
|
let d, _;
|
|
1784
|
-
const
|
|
1785
|
-
let
|
|
1816
|
+
const c = l.diff(a._end, a._start, "hour");
|
|
1817
|
+
let g = !1;
|
|
1786
1818
|
switch (h) {
|
|
1787
1819
|
case "finish-to-start":
|
|
1788
|
-
t.task._end > a._start && (d = new Date(t.task._end), _ =
|
|
1820
|
+
t.task._end > a._start && (d = new Date(t.task._end), _ = l.add(d, c, "hour"), g = !0);
|
|
1789
1821
|
break;
|
|
1790
1822
|
case "start-to-start":
|
|
1791
|
-
t.task._start > a._start && (d = new Date(t.task._start), _ =
|
|
1823
|
+
t.task._start > a._start && (d = new Date(t.task._start), _ = l.add(d, c, "hour"), g = !0);
|
|
1792
1824
|
break;
|
|
1793
1825
|
case "finish-to-finish":
|
|
1794
|
-
t.task._end > a._end && (_ = new Date(t.task._end), d =
|
|
1826
|
+
t.task._end > a._end && (_ = new Date(t.task._end), d = l.add(_, -c, "hour"), g = !0);
|
|
1795
1827
|
break;
|
|
1796
1828
|
case "start-to-finish":
|
|
1797
|
-
t.task._start > a._end && (_ = new Date(t.task._start), d =
|
|
1829
|
+
t.task._start > a._end && (_ = new Date(t.task._start), d = l.add(_, -c, "hour"), g = !0);
|
|
1798
1830
|
break;
|
|
1799
1831
|
default:
|
|
1800
1832
|
return;
|
|
1801
1833
|
}
|
|
1802
|
-
if (!
|
|
1834
|
+
if (!g) return;
|
|
1803
1835
|
a._start = d, a._end = _, o.compute_x(), o.compute_duration(), o.update_bar_position({
|
|
1804
1836
|
x: o.x,
|
|
1805
1837
|
width: o.width
|
|
1806
1838
|
}), this.trigger_event("date_change", [
|
|
1807
1839
|
a,
|
|
1808
1840
|
d,
|
|
1809
|
-
|
|
1841
|
+
l.add(_, -1, "second")
|
|
1810
1842
|
]), i.push({
|
|
1811
1843
|
task: a,
|
|
1812
1844
|
start: d,
|
|
1813
|
-
end:
|
|
1845
|
+
end: l.add(_, -1, "second")
|
|
1814
1846
|
});
|
|
1815
|
-
const
|
|
1816
|
-
i.push(...
|
|
1847
|
+
const p = this.update_dependent_tasks_by_type(o);
|
|
1848
|
+
i.push(...p);
|
|
1817
1849
|
}), i;
|
|
1818
1850
|
}
|
|
1819
1851
|
get_snap_position(t, e) {
|
|
1820
1852
|
let i = 1;
|
|
1821
|
-
const
|
|
1822
|
-
if (
|
|
1823
|
-
const { duration: _, scale:
|
|
1824
|
-
i =
|
|
1853
|
+
const n = this.options.snap_at || this.config.view_mode.snap_at || "1d";
|
|
1854
|
+
if (n !== "unit") {
|
|
1855
|
+
const { duration: _, scale: c } = l.parse_duration(n);
|
|
1856
|
+
i = l.convert_scales(this.config.view_mode.step, c) / _;
|
|
1825
1857
|
}
|
|
1826
|
-
const
|
|
1827
|
-
let o = t -
|
|
1858
|
+
const s = t % (this.config.column_width / i);
|
|
1859
|
+
let o = t - s + (s < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
|
|
1828
1860
|
const h = o > 0 ? 1 : -1;
|
|
1829
1861
|
let d = this.get_ignored_region(a, h);
|
|
1830
1862
|
for (; d.length; )
|
|
@@ -1878,20 +1910,20 @@ class j {
|
|
|
1878
1910
|
* @memberof Gantt
|
|
1879
1911
|
*/
|
|
1880
1912
|
clear() {
|
|
1881
|
-
var t, e, i,
|
|
1882
|
-
this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (
|
|
1913
|
+
var t, e, i, n, s, o, a, h, d, _;
|
|
1914
|
+
this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (n = (i = this.$side_header) == null ? void 0 : i.remove) == null || n.call(i), (o = (s = this.$current_highlight) == null ? void 0 : s.remove) == null || o.call(s), (h = (a = this.$extras) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.popup) == null ? void 0 : d.hide) == null || _.call(d);
|
|
1883
1915
|
}
|
|
1884
1916
|
}
|
|
1885
1917
|
j.VIEW_MODE = {
|
|
1886
|
-
HOUR:
|
|
1887
|
-
QUARTER_DAY:
|
|
1888
|
-
HALF_DAY:
|
|
1889
|
-
DAY:
|
|
1890
|
-
WEEK:
|
|
1891
|
-
MONTH:
|
|
1892
|
-
YEAR:
|
|
1918
|
+
HOUR: $[0],
|
|
1919
|
+
QUARTER_DAY: $[1],
|
|
1920
|
+
HALF_DAY: $[2],
|
|
1921
|
+
DAY: $[3],
|
|
1922
|
+
WEEK: $[4],
|
|
1923
|
+
MONTH: $[5],
|
|
1924
|
+
YEAR: $[6]
|
|
1893
1925
|
};
|
|
1894
|
-
function
|
|
1926
|
+
function N(r) {
|
|
1895
1927
|
return r.name + "_" + Math.random().toString(36).slice(2, 12);
|
|
1896
1928
|
}
|
|
1897
1929
|
function k(r) {
|