@workiom/frappe-gantt 1.0.6 → 1.0.7
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 +38 -1
- package/dist/frappe-gantt.css +1 -1
- package/dist/frappe-gantt.es.js +397 -312
- package/dist/frappe-gantt.umd.js +11 -11
- package/package.json +1 -1
- package/src/bar.js +182 -0
- package/src/defaults.js +1 -0
- package/src/index.js +32 -4
- package/src/styles/gantt.css +31 -0
package/dist/frappe-gantt.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const M = "year", D = "month", L = "day", T = "hour", Y = "minute",
|
|
1
|
+
const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second", H = "millisecond", c = {
|
|
2
2
|
parse_duration(r) {
|
|
3
3
|
const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(r);
|
|
4
4
|
if (e !== null) {
|
|
@@ -24,15 +24,15 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
24
24
|
if (typeof r == "string") {
|
|
25
25
|
let i, s;
|
|
26
26
|
const n = r.split(" ");
|
|
27
|
-
i = n[0].split(t).map((
|
|
28
|
-
let
|
|
29
|
-
return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3),
|
|
27
|
+
i = n[0].split(t).map((a) => parseInt(a, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
|
|
28
|
+
let o = i;
|
|
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((n,
|
|
35
|
+
const e = this.get_date_values(r).map((n, o) => (o === 1 && (n = n + 1), o === 6 ? v(n + "", 3, "0") : v(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
|
|
36
36
|
return i + (t ? " " + s : "");
|
|
37
37
|
},
|
|
38
38
|
format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
|
|
@@ -40,37 +40,37 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
40
40
|
month: "long"
|
|
41
41
|
}), s = new Intl.DateTimeFormat(e, {
|
|
42
42
|
month: "short"
|
|
43
|
-
}), n = i.format(r),
|
|
44
|
-
YYYY:
|
|
45
|
-
MM: v(+
|
|
46
|
-
DD:
|
|
47
|
-
HH:
|
|
48
|
-
mm:
|
|
49
|
-
ss:
|
|
50
|
-
SSS:
|
|
51
|
-
D:
|
|
52
|
-
MMMM:
|
|
43
|
+
}), n = i.format(r), o = n.charAt(0).toUpperCase() + n.slice(1), a = this.get_date_values(r).map((l) => v(l, 2, 0)), h = {
|
|
44
|
+
YYYY: a[0],
|
|
45
|
+
MM: v(+a[1] + 1, 2, 0),
|
|
46
|
+
DD: a[2],
|
|
47
|
+
HH: a[3],
|
|
48
|
+
mm: a[4],
|
|
49
|
+
ss: a[5],
|
|
50
|
+
SSS: a[6],
|
|
51
|
+
D: a[2],
|
|
52
|
+
MMMM: o,
|
|
53
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((l, p) => p.length - l.length).forEach((l) => {
|
|
58
|
+
d.includes(l) && (d = d.replaceAll(l, `$${_.length}`), _.push(h[l]));
|
|
59
|
+
}), _.forEach((l, p) => {
|
|
60
|
+
d = d.replaceAll(`$${p}`, l);
|
|
61
61
|
}), d;
|
|
62
62
|
},
|
|
63
63
|
diff(r, t, e = "day") {
|
|
64
|
-
let i, s, n,
|
|
65
|
-
i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3,
|
|
66
|
-
let _ = r.getFullYear() - t.getFullYear(),
|
|
67
|
-
return
|
|
64
|
+
let i, s, n, 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(), l = r.getMonth() - t.getMonth();
|
|
67
|
+
return l += a % 30 / 30, h = _ * 12 + l, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
|
|
68
68
|
{
|
|
69
69
|
milliseconds: i,
|
|
70
70
|
seconds: s,
|
|
71
|
-
minutes:
|
|
71
|
+
minutes: o,
|
|
72
72
|
hours: n,
|
|
73
|
-
days:
|
|
73
|
+
days: a,
|
|
74
74
|
months: h,
|
|
75
75
|
years: d
|
|
76
76
|
}[e] * 100
|
|
@@ -91,7 +91,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
91
91
|
r.getDate() + (e === L ? t : 0),
|
|
92
92
|
r.getHours() + (e === T ? t : 0),
|
|
93
93
|
r.getMinutes() + (e === Y ? t : 0),
|
|
94
|
-
r.getSeconds() + (e ===
|
|
94
|
+
r.getSeconds() + (e === A ? t : 0),
|
|
95
95
|
r.getMilliseconds() + (e === H ? t : 0)
|
|
96
96
|
];
|
|
97
97
|
return new Date(...i);
|
|
@@ -103,12 +103,12 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
103
103
|
[L]: 4,
|
|
104
104
|
[T]: 3,
|
|
105
105
|
[Y]: 2,
|
|
106
|
-
[
|
|
106
|
+
[A]: 1,
|
|
107
107
|
[H]: 0
|
|
108
108
|
};
|
|
109
109
|
function i(n) {
|
|
110
|
-
const
|
|
111
|
-
return e[n] <=
|
|
110
|
+
const o = e[t];
|
|
111
|
+
return e[n] <= o;
|
|
112
112
|
}
|
|
113
113
|
const s = [
|
|
114
114
|
r.getFullYear(),
|
|
@@ -117,7 +117,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
117
117
|
i(L) ? 0 : r.getHours(),
|
|
118
118
|
i(T) ? 0 : r.getMinutes(),
|
|
119
119
|
i(Y) ? 0 : r.getSeconds(),
|
|
120
|
-
i(
|
|
120
|
+
i(A) ? 0 : r.getMilliseconds()
|
|
121
121
|
];
|
|
122
122
|
return new Date(...s);
|
|
123
123
|
},
|
|
@@ -161,7 +161,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", E = "second"
|
|
|
161
161
|
function v(r, t, e) {
|
|
162
162
|
return r = r + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), r.length > t ? String(r) : (t = t - r.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(r));
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function u(r, t) {
|
|
165
165
|
return typeof r == "string" ? (t || document).querySelector(r) : r || null;
|
|
166
166
|
}
|
|
167
167
|
function f(r, t) {
|
|
@@ -170,17 +170,17 @@ function f(r, t) {
|
|
|
170
170
|
i === "append_to" ? t.append_to.appendChild(e) : i === "innerHTML" ? e.innerHTML = t.innerHTML : i === "clipPath" ? e.setAttribute("clip-path", "url(#" + t[i] + ")") : e.setAttribute(i, t[i]);
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const s =
|
|
173
|
+
function E(r, t, e, i) {
|
|
174
|
+
const s = z(r, t, e, i);
|
|
175
175
|
if (s === r) {
|
|
176
176
|
const n = document.createEvent("HTMLEvents");
|
|
177
177
|
n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
180
|
+
function z(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
181
|
+
const o = r.querySelector("animate");
|
|
182
|
+
if (o)
|
|
183
|
+
return u.attr(o, {
|
|
184
184
|
attributeName: t,
|
|
185
185
|
from: e,
|
|
186
186
|
to: i,
|
|
@@ -188,7 +188,7 @@ function W(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
|
188
188
|
begin: "click + " + n
|
|
189
189
|
// artificial click
|
|
190
190
|
}), r;
|
|
191
|
-
const
|
|
191
|
+
const a = f("animate", {
|
|
192
192
|
attributeName: t,
|
|
193
193
|
from: e,
|
|
194
194
|
to: i,
|
|
@@ -197,11 +197,11 @@ function W(r, t, e, i, s = "0.4s", n = "0.1s") {
|
|
|
197
197
|
calcMode: "spline",
|
|
198
198
|
values: e + ";" + i,
|
|
199
199
|
keyTimes: "0; 1",
|
|
200
|
-
keySplines:
|
|
200
|
+
keySplines: W("ease-out")
|
|
201
201
|
});
|
|
202
|
-
return r.appendChild(
|
|
202
|
+
return r.appendChild(a), r;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function W(r) {
|
|
205
205
|
return {
|
|
206
206
|
ease: ".25 .1 .25 1",
|
|
207
207
|
linear: "0 0 1 1",
|
|
@@ -210,35 +210,35 @@ function C(r) {
|
|
|
210
210
|
"ease-in-out": ".42 0 .58 1"
|
|
211
211
|
}[r];
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
i ?
|
|
213
|
+
u.on = (r, t, e, i) => {
|
|
214
|
+
i ? u.delegate(r, t, e, i) : (i = e, u.bind(r, t, i));
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
u.off = (r, t, e) => {
|
|
217
217
|
r.removeEventListener(t, e);
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
u.bind = (r, t, e) => {
|
|
220
220
|
t.split(/\s+/).forEach(function(i) {
|
|
221
221
|
r.addEventListener(i, e);
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
|
-
|
|
224
|
+
u.delegate = (r, t, e, i) => {
|
|
225
225
|
r.addEventListener(t, function(s) {
|
|
226
226
|
const n = s.target.closest(e);
|
|
227
227
|
n && (s.delegatedTarget = n, i.call(this, s, n));
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
u.closest = (r, t) => t ? t.matches(r) ? t : u.closest(r, t.parentNode) : null;
|
|
231
|
+
u.attr = (r, t, e) => {
|
|
232
232
|
if (!e && typeof t == "string")
|
|
233
233
|
return r.getAttribute(t);
|
|
234
234
|
if (typeof t == "object") {
|
|
235
235
|
for (let i in t)
|
|
236
|
-
|
|
236
|
+
u.attr(r, i, t[i]);
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
r.setAttribute(t, e);
|
|
240
240
|
};
|
|
241
|
-
class
|
|
241
|
+
class C {
|
|
242
242
|
constructor(t, e, i) {
|
|
243
243
|
this.gantt = t, this.from_task = e, this.to_task = i, this.is_critical = this.check_critical_path(), this.calculate_path(), this.draw();
|
|
244
244
|
}
|
|
@@ -252,33 +252,33 @@ class q {
|
|
|
252
252
|
t -= 10;
|
|
253
253
|
t -= 10;
|
|
254
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, s = this.to_task.$bar.getX() - 13, n = 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
|
-
const
|
|
256
|
-
let
|
|
257
|
-
const h =
|
|
258
|
-
let d =
|
|
255
|
+
const o = this.from_task.task._index > this.to_task.task._index;
|
|
256
|
+
let a = this.gantt.options.arrow_curve;
|
|
257
|
+
const h = o ? 1 : 0;
|
|
258
|
+
let d = o ? -a : a;
|
|
259
259
|
if (this.to_task.$bar.getX() <= this.from_task.$bar.getX() + this.gantt.options.padding) {
|
|
260
|
-
let _ = this.gantt.options.padding / 2 -
|
|
261
|
-
_ < 0 && (_ = 0,
|
|
262
|
-
const
|
|
260
|
+
let _ = this.gantt.options.padding / 2 - a;
|
|
261
|
+
_ < 0 && (_ = 0, a = this.gantt.options.padding / 2, d = o ? -a : a);
|
|
262
|
+
const l = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, p = this.to_task.$bar.getX() - this.gantt.options.padding;
|
|
263
263
|
this.path = `
|
|
264
264
|
M ${t} ${i}
|
|
265
265
|
v ${_}
|
|
266
|
-
a ${
|
|
267
|
-
H ${
|
|
268
|
-
a ${
|
|
269
|
-
V ${
|
|
270
|
-
a ${
|
|
266
|
+
a ${a} ${a} 0 0 1 ${-a} ${a}
|
|
267
|
+
H ${p}
|
|
268
|
+
a ${a} ${a} 0 0 ${h} ${-a} ${d}
|
|
269
|
+
V ${l}
|
|
270
|
+
a ${a} ${a} 0 0 ${h} ${a} ${d}
|
|
271
271
|
L ${s} ${n}
|
|
272
272
|
m -5 -5
|
|
273
273
|
l 5 5
|
|
274
274
|
l -5 5`;
|
|
275
275
|
} else {
|
|
276
|
-
s < t +
|
|
277
|
-
let _ =
|
|
276
|
+
s < t + a && (a = s - t);
|
|
277
|
+
let _ = o ? n + a : n - a;
|
|
278
278
|
this.path = `
|
|
279
279
|
M ${t} ${i}
|
|
280
280
|
V ${_}
|
|
281
|
-
a ${
|
|
281
|
+
a ${a} ${a} 0 0 ${h} ${a} ${a}
|
|
282
282
|
L ${s} ${n}
|
|
283
283
|
m -5 -5
|
|
284
284
|
l 5 5
|
|
@@ -297,7 +297,7 @@ class q {
|
|
|
297
297
|
this.calculate_path(), this.element.setAttribute("d", this.path);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
class
|
|
300
|
+
class q {
|
|
301
301
|
constructor(t, e) {
|
|
302
302
|
this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
|
|
303
303
|
}
|
|
@@ -305,7 +305,7 @@ class F {
|
|
|
305
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();
|
|
306
306
|
}
|
|
307
307
|
set_defaults(t, e) {
|
|
308
|
-
this.action_completed = !1, this.gantt = t, this.task = e, this.name = this.name || "";
|
|
308
|
+
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;
|
|
309
309
|
}
|
|
310
310
|
prepare_wrappers() {
|
|
311
311
|
this.group = f("g", {
|
|
@@ -339,7 +339,7 @@ class F {
|
|
|
339
339
|
this.compute_expected_progress(), this.expected_progress_width = this.gantt.options.column_width * this.duration * (this.expected_progress / 100) || 0;
|
|
340
340
|
}
|
|
341
341
|
draw() {
|
|
342
|
-
this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail();
|
|
342
|
+
this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail(), this.gantt.options.task_add_icon_position && this.draw_add_task_icon();
|
|
343
343
|
}
|
|
344
344
|
draw_bar() {
|
|
345
345
|
this.$bar = f("rect", {
|
|
@@ -351,7 +351,7 @@ class F {
|
|
|
351
351
|
ry: this.corner_radius,
|
|
352
352
|
class: "bar",
|
|
353
353
|
append_to: this.bar_group
|
|
354
|
-
}), this.task.color && (this.$bar.style.fill = this.task.color),
|
|
354
|
+
}), this.task.color && (this.$bar.style.fill = this.task.color), E(this.$bar, "width", 0, this.width), this.invalid && this.$bar.classList.add("bar-invalid");
|
|
355
355
|
}
|
|
356
356
|
draw_expected_progress_bar() {
|
|
357
357
|
this.invalid || (this.$expected_bar_progress = f("rect", {
|
|
@@ -363,7 +363,7 @@ class F {
|
|
|
363
363
|
ry: this.corner_radius,
|
|
364
364
|
class: "bar-expected-progress",
|
|
365
365
|
append_to: this.bar_group
|
|
366
|
-
}),
|
|
366
|
+
}), E(
|
|
367
367
|
this.$expected_bar_progress,
|
|
368
368
|
"width",
|
|
369
369
|
0,
|
|
@@ -384,7 +384,7 @@ class F {
|
|
|
384
384
|
class: "bar-progress",
|
|
385
385
|
append_to: this.bar_group
|
|
386
386
|
}), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
|
|
387
|
-
const e =
|
|
387
|
+
const e = c.diff(
|
|
388
388
|
this.task._start,
|
|
389
389
|
this.gantt.gantt_start,
|
|
390
390
|
this.gantt.config.unit
|
|
@@ -394,18 +394,18 @@ class F {
|
|
|
394
394
|
width: this.width,
|
|
395
395
|
left: e
|
|
396
396
|
});
|
|
397
|
-
this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight),
|
|
397
|
+
this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), E(this.$bar_progress, "width", 0, this.progress_width);
|
|
398
398
|
}
|
|
399
399
|
calculate_progress_width() {
|
|
400
400
|
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
401
|
let s = (t - i) * this.task.progress / 100;
|
|
402
|
-
const n = this.x + s,
|
|
403
|
-
s +=
|
|
404
|
-
let
|
|
402
|
+
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;
|
|
403
|
+
s += o;
|
|
404
|
+
let a = this.gantt.get_ignored_region(
|
|
405
405
|
this.x + s
|
|
406
406
|
);
|
|
407
|
-
for (;
|
|
408
|
-
s += this.gantt.config.column_width,
|
|
407
|
+
for (; a.length; )
|
|
408
|
+
s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
|
|
409
409
|
this.x + s
|
|
410
410
|
);
|
|
411
411
|
return this.progress_width = s, s;
|
|
@@ -450,6 +450,51 @@ class F {
|
|
|
450
450
|
append_to: this.bar_group
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
|
+
draw_add_task_icon() {
|
|
454
|
+
this.icon_size = 20, this.icon_padding = 5;
|
|
455
|
+
let i;
|
|
456
|
+
if (this.gantt.options.task_add_icon_position === "before")
|
|
457
|
+
i = this.x - 20 - 5;
|
|
458
|
+
else if (this.gantt.options.task_add_icon_position === "after")
|
|
459
|
+
i = this.x + this.$bar.getWidth() + 5;
|
|
460
|
+
else
|
|
461
|
+
return;
|
|
462
|
+
const s = this.y + (this.height - 20) / 2;
|
|
463
|
+
this.$add_icon_group = f("g", {
|
|
464
|
+
class: "add-task-icon hide",
|
|
465
|
+
append_to: this.handle_group
|
|
466
|
+
}), this.$add_icon_circle = f("circle", {
|
|
467
|
+
cx: i + 20 / 2,
|
|
468
|
+
cy: s + 20 / 2,
|
|
469
|
+
r: 20 / 2,
|
|
470
|
+
class: "add-task-icon-bg",
|
|
471
|
+
append_to: this.$add_icon_group
|
|
472
|
+
}), this.$add_icon_vertical = f("line", {
|
|
473
|
+
x1: i + 20 / 2,
|
|
474
|
+
y1: s + 5,
|
|
475
|
+
x2: i + 20 / 2,
|
|
476
|
+
y2: s + 20 - 5,
|
|
477
|
+
class: "add-task-icon-plus",
|
|
478
|
+
append_to: this.$add_icon_group
|
|
479
|
+
}), this.$add_icon_horizontal = f("line", {
|
|
480
|
+
x1: i + 5,
|
|
481
|
+
y1: s + 20 / 2,
|
|
482
|
+
x2: i + 20 - 5,
|
|
483
|
+
y2: s + 20 / 2,
|
|
484
|
+
class: "add-task-icon-plus",
|
|
485
|
+
append_to: this.$add_icon_group
|
|
486
|
+
}), u.on(this.$add_icon_group, "mousedown", (n) => {
|
|
487
|
+
n.stopPropagation();
|
|
488
|
+
}), u.on(this.$add_icon_group, "mouseup", (n) => {
|
|
489
|
+
n.stopPropagation();
|
|
490
|
+
}), u.on(this.$add_icon_group, "click", (n) => {
|
|
491
|
+
n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
|
|
492
|
+
}), u.on(this.$add_icon_group, "mouseenter", (n) => {
|
|
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"), n.stopPropagation();
|
|
494
|
+
}), u.on(this.$add_icon_group, "mouseleave", () => {
|
|
495
|
+
this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
|
|
496
|
+
});
|
|
497
|
+
}
|
|
453
498
|
draw_resize_handles() {
|
|
454
499
|
if (this.invalid || this.gantt.options.readonly) return;
|
|
455
500
|
const t = this.$bar, e = 3;
|
|
@@ -486,25 +531,25 @@ class F {
|
|
|
486
531
|
}), this.handles.push(this.$handle_progress);
|
|
487
532
|
}
|
|
488
533
|
for (let i of this.handles)
|
|
489
|
-
|
|
534
|
+
u.on(i, "mouseenter", () => i.classList.add("active")), u.on(i, "mouseleave", () => i.classList.remove("active"));
|
|
490
535
|
}
|
|
491
536
|
bind() {
|
|
492
537
|
this.invalid || this.setup_click_event();
|
|
493
538
|
}
|
|
494
539
|
setup_click_event() {
|
|
495
540
|
let t = this.task.id;
|
|
496
|
-
|
|
541
|
+
u.on(this.group, "mouseover", (s) => {
|
|
497
542
|
this.gantt.trigger_event("hover", [
|
|
498
543
|
this.task,
|
|
499
544
|
s.screenX,
|
|
500
545
|
s.screenY,
|
|
501
546
|
s
|
|
502
547
|
]);
|
|
503
|
-
}), this.gantt.options.popup_on === "click" &&
|
|
548
|
+
}), this.gantt.options.popup_on === "click" && u.on(this.group, "mouseup", (s) => {
|
|
504
549
|
const n = s.offsetX || s.layerX;
|
|
505
550
|
if (this.$handle_progress) {
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
551
|
+
const o = +this.$handle_progress.getAttribute("cx");
|
|
552
|
+
if (o > n - 1 && o < n + 1 || this.gantt.bar_being_dragged) return;
|
|
508
553
|
}
|
|
509
554
|
this.gantt.show_popup({
|
|
510
555
|
x: s.offsetX || s.layerX,
|
|
@@ -514,7 +559,7 @@ class F {
|
|
|
514
559
|
});
|
|
515
560
|
});
|
|
516
561
|
let e;
|
|
517
|
-
|
|
562
|
+
u.on(this.group, "mouseenter", (s) => {
|
|
518
563
|
e = setTimeout(() => {
|
|
519
564
|
this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
|
|
520
565
|
x: s.offsetX || s.layerX,
|
|
@@ -522,17 +567,21 @@ class F {
|
|
|
522
567
|
task: this.task,
|
|
523
568
|
target: this.$bar
|
|
524
569
|
}), this.gantt.$container.querySelector(`.highlight-${t}`).classList.remove("hide");
|
|
525
|
-
}, 200);
|
|
526
|
-
}),
|
|
570
|
+
}, 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
|
+
}), u.on(this.group, "mouseleave", () => {
|
|
527
572
|
var s, n;
|
|
528
|
-
clearTimeout(e), this.gantt.options.popup_on === "hover" && ((n = (s = this.gantt.popup) == null ? void 0 : s.hide) == null || n.call(s)), this.gantt.$container.querySelector(`.highlight-${t}`).classList.add("hide")
|
|
529
|
-
|
|
573
|
+
clearTimeout(e), this.gantt.options.popup_on === "hover" && ((n = (s = this.gantt.popup) == null ? void 0 : s.hide) == null || n.call(s)), 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
|
+
this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
|
|
575
|
+
}, 200));
|
|
576
|
+
}), u.on(this.group, "mousedown", () => {
|
|
577
|
+
this.is_dragging = !0, this.hide_add_icon();
|
|
578
|
+
}), u.on(this.group, "click", () => {
|
|
530
579
|
this.gantt.trigger_event("click", [this.task]);
|
|
531
|
-
}),
|
|
580
|
+
}), u.on(this.group, "dblclick", (s) => {
|
|
532
581
|
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]));
|
|
533
582
|
});
|
|
534
583
|
let i = !1;
|
|
535
|
-
|
|
584
|
+
u.on(this.group, "touchstart", (s) => {
|
|
536
585
|
if (!i)
|
|
537
586
|
return i = !0, setTimeout(function() {
|
|
538
587
|
i = !1;
|
|
@@ -547,40 +596,40 @@ class F {
|
|
|
547
596
|
return;
|
|
548
597
|
this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px";
|
|
549
598
|
}
|
|
550
|
-
e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_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();
|
|
599
|
+
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();
|
|
551
600
|
}
|
|
552
601
|
validate_dependency_constraints(t, e = null) {
|
|
553
602
|
const i = this.task.dependencies_type || this.gantt.options.dependencies_type;
|
|
554
603
|
if (i === "fixed")
|
|
555
|
-
return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_,
|
|
556
|
-
const s = t / this.gantt.config.column_width, n =
|
|
604
|
+
return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, l) => _ && t >= l, !0);
|
|
605
|
+
const s = t / this.gantt.config.column_width, n = c.add(
|
|
557
606
|
this.gantt.gantt_start,
|
|
558
607
|
s * this.gantt.config.step,
|
|
559
608
|
this.gantt.config.unit
|
|
560
|
-
),
|
|
609
|
+
), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = c.add(
|
|
561
610
|
n,
|
|
562
|
-
|
|
611
|
+
a * this.gantt.config.step,
|
|
563
612
|
this.gantt.config.unit
|
|
564
613
|
);
|
|
565
614
|
for (const d of this.task.dependencies) {
|
|
566
615
|
const _ = this.gantt.get_bar(d);
|
|
567
616
|
if (!_) continue;
|
|
568
|
-
const
|
|
617
|
+
const l = _.task;
|
|
569
618
|
switch (i) {
|
|
570
619
|
case "finish-to-start":
|
|
571
|
-
if (n <
|
|
620
|
+
if (n < l._end)
|
|
572
621
|
return !1;
|
|
573
622
|
break;
|
|
574
623
|
case "start-to-start":
|
|
575
|
-
if (n <
|
|
624
|
+
if (n < l._start)
|
|
576
625
|
return !1;
|
|
577
626
|
break;
|
|
578
627
|
case "finish-to-finish":
|
|
579
|
-
if (h <
|
|
628
|
+
if (h < l._end)
|
|
580
629
|
return !1;
|
|
581
630
|
break;
|
|
582
631
|
case "start-to-finish":
|
|
583
|
-
if (h <
|
|
632
|
+
if (h < l._start)
|
|
584
633
|
return !1;
|
|
585
634
|
break;
|
|
586
635
|
}
|
|
@@ -588,9 +637,9 @@ class F {
|
|
|
588
637
|
return !0;
|
|
589
638
|
}
|
|
590
639
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
|
591
|
-
const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "",
|
|
592
|
-
let
|
|
593
|
-
s.classList.contains("big") || (
|
|
640
|
+
const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
|
|
641
|
+
let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, l = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
|
|
642
|
+
s.classList.contains("big") || (l < a && t > 0 && l < p || h - _ > this.$bar.getX() && t < 0 && l > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
|
|
594
643
|
}
|
|
595
644
|
date_changed() {
|
|
596
645
|
let t = !1;
|
|
@@ -598,7 +647,7 @@ class F {
|
|
|
598
647
|
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", [
|
|
599
648
|
this.task,
|
|
600
649
|
e,
|
|
601
|
-
|
|
650
|
+
c.add(i, -1, "second")
|
|
602
651
|
]);
|
|
603
652
|
}
|
|
604
653
|
progress_changed() {
|
|
@@ -608,16 +657,16 @@ class F {
|
|
|
608
657
|
]);
|
|
609
658
|
}
|
|
610
659
|
set_action_completed() {
|
|
611
|
-
this.action_completed = !0, setTimeout(() => this.action_completed = !1, 1e3);
|
|
660
|
+
this.action_completed = !0, setTimeout(() => this.action_completed = !1, 1e3), this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide");
|
|
612
661
|
}
|
|
613
662
|
compute_start_end_date() {
|
|
614
663
|
const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
|
|
615
|
-
let i =
|
|
664
|
+
let i = c.add(
|
|
616
665
|
this.gantt.gantt_start,
|
|
617
666
|
e * this.gantt.config.step,
|
|
618
667
|
this.gantt.config.unit
|
|
619
668
|
);
|
|
620
|
-
const s = t.getWidth() / this.gantt.config.column_width, n =
|
|
669
|
+
const s = t.getWidth() / this.gantt.config.column_width, n = c.add(
|
|
621
670
|
i,
|
|
622
671
|
s * this.gantt.config.step,
|
|
623
672
|
this.gantt.config.unit
|
|
@@ -632,11 +681,11 @@ class F {
|
|
|
632
681
|
return parseInt(e / i * 100, 10);
|
|
633
682
|
}
|
|
634
683
|
compute_expected_progress() {
|
|
635
|
-
this.expected_progress =
|
|
684
|
+
this.expected_progress = c.diff(c.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;
|
|
636
685
|
}
|
|
637
686
|
compute_x() {
|
|
638
687
|
const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
|
|
639
|
-
let n =
|
|
688
|
+
let n = c.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
|
|
640
689
|
this.x = n;
|
|
641
690
|
}
|
|
642
691
|
compute_y() {
|
|
@@ -648,10 +697,10 @@ class F {
|
|
|
648
697
|
e++, !this.gantt.config.ignored_dates.find(
|
|
649
698
|
(s) => s.getTime() === i.getTime()
|
|
650
699
|
) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
|
|
651
|
-
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration =
|
|
700
|
+
this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = c.convert_scales(
|
|
652
701
|
e + "d",
|
|
653
702
|
this.gantt.config.unit
|
|
654
|
-
) / this.gantt.config.step, this.actual_duration_raw =
|
|
703
|
+
) / this.gantt.config.step, this.actual_duration_raw = c.convert_scales(
|
|
655
704
|
t + "d",
|
|
656
705
|
this.gantt.config.unit
|
|
657
706
|
) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
|
|
@@ -673,14 +722,14 @@ class F {
|
|
|
673
722
|
}
|
|
674
723
|
update_label_position() {
|
|
675
724
|
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
|
|
676
|
-
let n = 5,
|
|
677
|
-
const
|
|
678
|
-
|
|
725
|
+
let n = 5, o = this.image_size + 10;
|
|
726
|
+
const a = i.getBBox().width, h = e.getWidth();
|
|
727
|
+
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(
|
|
679
728
|
"x",
|
|
680
|
-
e.getX() + h / 2 +
|
|
729
|
+
e.getX() + h / 2 + o
|
|
681
730
|
)) : i.setAttribute(
|
|
682
731
|
"x",
|
|
683
|
-
e.getX() + h / 2 -
|
|
732
|
+
e.getX() + h / 2 - a / 2
|
|
684
733
|
));
|
|
685
734
|
}
|
|
686
735
|
update_handle_position() {
|
|
@@ -690,13 +739,29 @@ class F {
|
|
|
690
739
|
const e = this.group.querySelector(".handle.progress");
|
|
691
740
|
e && e.setAttribute("cx", this.$bar_progress.getEndX());
|
|
692
741
|
}
|
|
742
|
+
update_add_icon_position() {
|
|
743
|
+
if (!this.$add_icon_group) return;
|
|
744
|
+
const t = this.icon_size, e = this.icon_padding;
|
|
745
|
+
let i;
|
|
746
|
+
if (this.gantt.options.task_add_icon_position === "before")
|
|
747
|
+
i = this.x - t - e;
|
|
748
|
+
else if (this.gantt.options.task_add_icon_position === "after")
|
|
749
|
+
i = this.x + this.$bar.getWidth() + e;
|
|
750
|
+
else
|
|
751
|
+
return;
|
|
752
|
+
const s = this.y + (this.height - t) / 2;
|
|
753
|
+
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);
|
|
754
|
+
}
|
|
755
|
+
hide_add_icon() {
|
|
756
|
+
this.$add_icon_group && this.$add_icon_group.classList.add("hide");
|
|
757
|
+
}
|
|
693
758
|
update_arrow_position() {
|
|
694
759
|
this.arrows = this.arrows || [];
|
|
695
760
|
for (let t of this.arrows)
|
|
696
761
|
t.update();
|
|
697
762
|
}
|
|
698
763
|
}
|
|
699
|
-
class
|
|
764
|
+
class F {
|
|
700
765
|
constructor(t, e, i) {
|
|
701
766
|
this.parent = t, this.popup_func = e, this.gantt = i, this.make();
|
|
702
767
|
}
|
|
@@ -714,18 +779,18 @@ class O {
|
|
|
714
779
|
task: i,
|
|
715
780
|
chart: this.gantt,
|
|
716
781
|
get_title: () => this.title,
|
|
717
|
-
set_title: (
|
|
782
|
+
set_title: (o) => this.title.innerHTML = o,
|
|
718
783
|
get_subtitle: () => this.subtitle,
|
|
719
|
-
set_subtitle: (
|
|
784
|
+
set_subtitle: (o) => this.subtitle.innerHTML = o,
|
|
720
785
|
get_details: () => this.details,
|
|
721
|
-
set_details: (
|
|
722
|
-
add_action: (
|
|
786
|
+
set_details: (o) => this.details.innerHTML = o,
|
|
787
|
+
add_action: (o, a) => {
|
|
723
788
|
let h = this.gantt.create_el({
|
|
724
789
|
classes: "action-btn",
|
|
725
790
|
type: "button",
|
|
726
791
|
append_to: this.actions
|
|
727
792
|
});
|
|
728
|
-
typeof
|
|
793
|
+
typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
|
|
729
794
|
}
|
|
730
795
|
});
|
|
731
796
|
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"));
|
|
@@ -738,9 +803,9 @@ function S(r) {
|
|
|
738
803
|
const t = r.getFullYear();
|
|
739
804
|
return t - t % 10 + "";
|
|
740
805
|
}
|
|
741
|
-
function
|
|
742
|
-
let i =
|
|
743
|
-
return `${
|
|
806
|
+
function O(r, t, e) {
|
|
807
|
+
let i = c.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
|
|
808
|
+
return `${c.format(r, n, e)} - ${c.format(i, s, e)}`;
|
|
744
809
|
}
|
|
745
810
|
const y = [
|
|
746
811
|
{
|
|
@@ -749,7 +814,7 @@ const y = [
|
|
|
749
814
|
step: "1h",
|
|
750
815
|
date_format: "YYYY-MM-DD HH:",
|
|
751
816
|
lower_text: "HH",
|
|
752
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
817
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMMM", e) : "",
|
|
753
818
|
upper_text_frequency: 24
|
|
754
819
|
},
|
|
755
820
|
{
|
|
@@ -758,7 +823,7 @@ const y = [
|
|
|
758
823
|
step: "6h",
|
|
759
824
|
date_format: "YYYY-MM-DD HH:",
|
|
760
825
|
lower_text: "HH",
|
|
761
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
826
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMM", e) : "",
|
|
762
827
|
upper_text_frequency: 4
|
|
763
828
|
},
|
|
764
829
|
{
|
|
@@ -767,7 +832,7 @@ const y = [
|
|
|
767
832
|
step: "12h",
|
|
768
833
|
date_format: "YYYY-MM-DD HH:",
|
|
769
834
|
lower_text: "HH",
|
|
770
|
-
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ?
|
|
835
|
+
upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? c.format(r, "D MMM", e) : c.format(r, "D", e) : "",
|
|
771
836
|
upper_text_frequency: 2
|
|
772
837
|
},
|
|
773
838
|
{
|
|
@@ -775,8 +840,8 @@ const y = [
|
|
|
775
840
|
padding: "7d",
|
|
776
841
|
date_format: "YYYY-MM-DD",
|
|
777
842
|
step: "1d",
|
|
778
|
-
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ?
|
|
779
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
843
|
+
lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D", e) : "",
|
|
844
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
|
|
780
845
|
thick_line: (r) => r.getDay() === 1
|
|
781
846
|
},
|
|
782
847
|
{
|
|
@@ -785,8 +850,8 @@ const y = [
|
|
|
785
850
|
step: "7d",
|
|
786
851
|
date_format: "YYYY-MM-DD",
|
|
787
852
|
column_width: 140,
|
|
788
|
-
lower_text:
|
|
789
|
-
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ?
|
|
853
|
+
lower_text: O,
|
|
854
|
+
upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
|
|
790
855
|
thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
|
|
791
856
|
upper_text_frequency: 4
|
|
792
857
|
},
|
|
@@ -797,7 +862,7 @@ const y = [
|
|
|
797
862
|
column_width: 120,
|
|
798
863
|
date_format: "YYYY-MM",
|
|
799
864
|
lower_text: "MMMM",
|
|
800
|
-
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ?
|
|
865
|
+
upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? c.format(r, "YYYY", e) : "",
|
|
801
866
|
thick_line: (r) => r.getMonth() % 3 === 0,
|
|
802
867
|
snap_at: "7d"
|
|
803
868
|
},
|
|
@@ -811,7 +876,7 @@ const y = [
|
|
|
811
876
|
lower_text: "YYYY",
|
|
812
877
|
snap_at: "30d"
|
|
813
878
|
}
|
|
814
|
-
],
|
|
879
|
+
], I = {
|
|
815
880
|
arrow_curve: 5,
|
|
816
881
|
auto_move_label: !1,
|
|
817
882
|
bar_corner_radius: 3,
|
|
@@ -833,12 +898,12 @@ const y = [
|
|
|
833
898
|
padding: 18,
|
|
834
899
|
popup: (r) => {
|
|
835
900
|
r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
|
|
836
|
-
const t =
|
|
901
|
+
const t = c.format(
|
|
837
902
|
r.task._start,
|
|
838
903
|
"MMM D",
|
|
839
904
|
r.chart.options.language
|
|
840
|
-
), e =
|
|
841
|
-
|
|
905
|
+
), e = c.format(
|
|
906
|
+
c.add(r.task._end, -1, "second"),
|
|
842
907
|
"MMM D",
|
|
843
908
|
r.chart.options.language
|
|
844
909
|
);
|
|
@@ -852,6 +917,7 @@ const y = [
|
|
|
852
917
|
readonly: !1,
|
|
853
918
|
scroll_to: "today",
|
|
854
919
|
show_expected_progress: !1,
|
|
920
|
+
task_add_icon_position: null,
|
|
855
921
|
today_button: !0,
|
|
856
922
|
view_mode: "Day",
|
|
857
923
|
view_mode_select: !1,
|
|
@@ -902,7 +968,7 @@ class j {
|
|
|
902
968
|
), s;
|
|
903
969
|
}
|
|
904
970
|
return i;
|
|
905
|
-
}), t.view_mode = t.view_modes[0]), this.options = { ...
|
|
971
|
+
}), t.view_mode = t.view_modes[0]), this.options = { ...I, ...t };
|
|
906
972
|
const e = {
|
|
907
973
|
"grid-height": "container_height",
|
|
908
974
|
"bar-height": "bar_height",
|
|
@@ -941,22 +1007,22 @@ class j {
|
|
|
941
1007
|
return console.error(
|
|
942
1008
|
`task "${e.id}" doesn't have a start date`
|
|
943
1009
|
), !1;
|
|
944
|
-
if (e._start =
|
|
945
|
-
let { duration: h, scale: d } =
|
|
946
|
-
e.end =
|
|
1010
|
+
if (e._start = c.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
|
|
1011
|
+
let { duration: h, scale: d } = c.parse_duration(a);
|
|
1012
|
+
e.end = c.add(e.end, h, d);
|
|
947
1013
|
})), !e.end)
|
|
948
1014
|
return console.error(`task "${e.id}" doesn't have an end date`), !1;
|
|
949
|
-
if (e._end =
|
|
1015
|
+
if (e._end = c.parse(e.end), c.diff(e._end, e._start, "year") < 0)
|
|
950
1016
|
return console.error(
|
|
951
1017
|
`start of task can't be after end of task: in task "${e.id}"`
|
|
952
1018
|
), !1;
|
|
953
|
-
if (
|
|
1019
|
+
if (c.diff(e._end, e._start, "year") > 10)
|
|
954
1020
|
return console.error(
|
|
955
1021
|
`the duration of task "${e.id}" is too long (above ten years)`
|
|
956
1022
|
), !1;
|
|
957
|
-
if (e._index = i,
|
|
958
|
-
let
|
|
959
|
-
e.dependencies && (
|
|
1023
|
+
if (e._index = i, c.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = c.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
|
|
1024
|
+
let o = [];
|
|
1025
|
+
e.dependencies && (o = e.dependencies.split(",").map((a) => a.trim().replaceAll(" ", "_")).filter((a) => a)), e.dependencies = o;
|
|
960
1026
|
}
|
|
961
1027
|
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = B(e), e;
|
|
962
1028
|
}).filter((e) => e), this.setup_dependencies();
|
|
@@ -980,7 +1046,7 @@ class j {
|
|
|
980
1046
|
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]);
|
|
981
1047
|
}
|
|
982
1048
|
update_view_scale(t) {
|
|
983
|
-
let { duration: e, scale: i } =
|
|
1049
|
+
let { duration: e, scale: i } = c.parse_duration(t.step);
|
|
984
1050
|
this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
|
|
985
1051
|
"--gv-column-width",
|
|
986
1052
|
this.config.column_width + "px"
|
|
@@ -994,13 +1060,13 @@ class j {
|
|
|
994
1060
|
this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
|
|
995
1061
|
for (let s of this.tasks)
|
|
996
1062
|
(!e || s._start < e) && (e = s._start), (!i || s._end > i) && (i = s._end);
|
|
997
|
-
if (e =
|
|
1063
|
+
if (e = c.start_of(e, this.config.unit), i = c.start_of(i, this.config.unit), !t)
|
|
998
1064
|
if (this.options.infinite_padding)
|
|
999
|
-
this.gantt_start =
|
|
1065
|
+
this.gantt_start = c.add(
|
|
1000
1066
|
e,
|
|
1001
1067
|
-this.config.extend_by_units * 3,
|
|
1002
1068
|
this.config.unit
|
|
1003
|
-
), this.gantt_end =
|
|
1069
|
+
), this.gantt_end = c.add(
|
|
1004
1070
|
i,
|
|
1005
1071
|
this.config.extend_by_units * 3,
|
|
1006
1072
|
this.config.unit
|
|
@@ -1011,13 +1077,13 @@ class j {
|
|
|
1011
1077
|
this.config.view_mode.padding
|
|
1012
1078
|
]);
|
|
1013
1079
|
let [s, n] = this.config.view_mode.padding.map(
|
|
1014
|
-
|
|
1080
|
+
c.parse_duration
|
|
1015
1081
|
);
|
|
1016
|
-
this.gantt_start =
|
|
1082
|
+
this.gantt_start = c.add(
|
|
1017
1083
|
e,
|
|
1018
1084
|
-s.duration,
|
|
1019
1085
|
s.scale
|
|
1020
|
-
), this.gantt_end =
|
|
1086
|
+
), this.gantt_end = c.add(
|
|
1021
1087
|
i,
|
|
1022
1088
|
n.duration,
|
|
1023
1089
|
n.scale
|
|
@@ -1028,7 +1094,7 @@ class j {
|
|
|
1028
1094
|
setup_date_values() {
|
|
1029
1095
|
let t = this.gantt_start;
|
|
1030
1096
|
for (this.dates = [t]; t < this.gantt_end; )
|
|
1031
|
-
t =
|
|
1097
|
+
t = c.add(
|
|
1032
1098
|
t,
|
|
1033
1099
|
this.config.step,
|
|
1034
1100
|
this.config.unit
|
|
@@ -1075,7 +1141,7 @@ class j {
|
|
|
1075
1141
|
height: e,
|
|
1076
1142
|
class: "grid-background",
|
|
1077
1143
|
append_to: this.$svg
|
|
1078
|
-
}),
|
|
1144
|
+
}), u.attr(this.$svg, {
|
|
1079
1145
|
height: e,
|
|
1080
1146
|
width: "100%"
|
|
1081
1147
|
}), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
|
|
@@ -1134,17 +1200,17 @@ class j {
|
|
|
1134
1200
|
class: "lines_layer",
|
|
1135
1201
|
append_to: this.layers.grid
|
|
1136
1202
|
}), n = this.config.header_height;
|
|
1137
|
-
const
|
|
1203
|
+
const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
|
|
1138
1204
|
if (this.options.lines !== "vertical")
|
|
1139
|
-
for (let h = this.config.header_height; h < this.grid_height; h +=
|
|
1205
|
+
for (let h = this.config.header_height; h < this.grid_height; h += a)
|
|
1140
1206
|
f("line", {
|
|
1141
1207
|
x1: 0,
|
|
1142
|
-
y1: n +
|
|
1143
|
-
x2:
|
|
1144
|
-
y2: n +
|
|
1208
|
+
y1: n + a,
|
|
1209
|
+
x2: o,
|
|
1210
|
+
y2: n + a,
|
|
1145
1211
|
class: "row-line",
|
|
1146
1212
|
append_to: s
|
|
1147
|
-
}), n +=
|
|
1213
|
+
}), n += a;
|
|
1148
1214
|
if (this.options.lines !== "horizontal")
|
|
1149
1215
|
for (let h of this.dates) {
|
|
1150
1216
|
let d = "tick";
|
|
@@ -1152,7 +1218,7 @@ class j {
|
|
|
1152
1218
|
d: `M ${t} ${e} v ${i}`,
|
|
1153
1219
|
class: d,
|
|
1154
1220
|
append_to: this.layers.grid
|
|
1155
|
-
}), this.view_is("month") ? t +=
|
|
1221
|
+
}), this.view_is("month") ? t += c.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += c.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
|
|
1156
1222
|
}
|
|
1157
1223
|
}
|
|
1158
1224
|
highlight_holidays() {
|
|
@@ -1163,28 +1229,28 @@ class j {
|
|
|
1163
1229
|
i === "weekend" && (i = this.options.is_weekend);
|
|
1164
1230
|
let s;
|
|
1165
1231
|
if (typeof i == "object") {
|
|
1166
|
-
let n = i.find((
|
|
1232
|
+
let n = i.find((o) => typeof o == "function");
|
|
1167
1233
|
if (n && (s = n), this.options.holidays.name) {
|
|
1168
|
-
let
|
|
1169
|
-
i = (
|
|
1234
|
+
let o = /* @__PURE__ */ new Date(i.date + " ");
|
|
1235
|
+
i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
|
|
1170
1236
|
} else
|
|
1171
|
-
i = (
|
|
1172
|
-
if (
|
|
1173
|
-
let h = /* @__PURE__ */ new Date(
|
|
1174
|
-
return t[h] =
|
|
1237
|
+
i = (o) => this.options.holidays[e].filter((a) => typeof a != "function").map((a) => {
|
|
1238
|
+
if (a.name) {
|
|
1239
|
+
let h = /* @__PURE__ */ new Date(a.date + " ");
|
|
1240
|
+
return t[h] = a.name, h.getTime();
|
|
1175
1241
|
}
|
|
1176
|
-
return (/* @__PURE__ */ new Date(
|
|
1177
|
-
}).includes(
|
|
1242
|
+
return (/* @__PURE__ */ new Date(a + " ")).getTime();
|
|
1243
|
+
}).includes(o.getTime());
|
|
1178
1244
|
}
|
|
1179
1245
|
for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
|
|
1180
1246
|
if (!(this.config.ignored_dates.find(
|
|
1181
|
-
(
|
|
1247
|
+
(o) => o.getTime() == n.getTime()
|
|
1182
1248
|
) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
|
|
1183
|
-
const
|
|
1249
|
+
const o = c.diff(
|
|
1184
1250
|
n,
|
|
1185
1251
|
this.gantt_start,
|
|
1186
1252
|
this.config.unit
|
|
1187
|
-
) / this.config.step * this.config.column_width,
|
|
1253
|
+
) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = c.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
|
|
1188
1254
|
if (t[n]) {
|
|
1189
1255
|
let d = this.create_el({
|
|
1190
1256
|
classes: "holiday-label label_" + h,
|
|
@@ -1193,13 +1259,13 @@ class j {
|
|
|
1193
1259
|
d.textContent = t[n];
|
|
1194
1260
|
}
|
|
1195
1261
|
f("rect", {
|
|
1196
|
-
x: Math.round(
|
|
1262
|
+
x: Math.round(o),
|
|
1197
1263
|
y: this.config.header_height,
|
|
1198
|
-
width: this.config.column_width /
|
|
1264
|
+
width: this.config.column_width / c.convert_scales(
|
|
1199
1265
|
this.config.view_mode.step,
|
|
1200
1266
|
"day"
|
|
1201
1267
|
),
|
|
1202
|
-
height:
|
|
1268
|
+
height: a,
|
|
1203
1269
|
class: "holiday-highlight " + h,
|
|
1204
1270
|
style: `fill: ${e};`,
|
|
1205
1271
|
append_to: this.layers.grid
|
|
@@ -1217,7 +1283,7 @@ class j {
|
|
|
1217
1283
|
if (!t) return;
|
|
1218
1284
|
const [e, i] = t;
|
|
1219
1285
|
i.classList.add("current-date-highlight");
|
|
1220
|
-
const n =
|
|
1286
|
+
const n = c.diff(
|
|
1221
1287
|
/* @__PURE__ */ new Date(),
|
|
1222
1288
|
this.gantt_start,
|
|
1223
1289
|
this.config.unit
|
|
@@ -1251,8 +1317,8 @@ class j {
|
|
|
1251
1317
|
(n) => n.getTime() == i.getTime()
|
|
1252
1318
|
) && (!this.config.ignored_function || !this.config.ignored_function(i)))
|
|
1253
1319
|
continue;
|
|
1254
|
-
let s =
|
|
1255
|
-
|
|
1320
|
+
let s = c.convert_scales(
|
|
1321
|
+
c.diff(i, this.gantt_start) + "d",
|
|
1256
1322
|
this.config.unit
|
|
1257
1323
|
) / this.config.step;
|
|
1258
1324
|
this.config.ignored_positions.push(s * this.config.column_width), f("rect", {
|
|
@@ -1269,10 +1335,10 @@ class j {
|
|
|
1269
1335
|
this.config.view_mode
|
|
1270
1336
|
);
|
|
1271
1337
|
}
|
|
1272
|
-
create_el({ left: t, top: e, width: i, height: s, id: n, classes:
|
|
1338
|
+
create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
|
|
1273
1339
|
let d = document.createElement(h || "div");
|
|
1274
|
-
for (let _ of
|
|
1275
|
-
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"),
|
|
1340
|
+
for (let _ of o.split(" ")) d.classList.add(_);
|
|
1341
|
+
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;
|
|
1276
1342
|
}
|
|
1277
1343
|
make_dates() {
|
|
1278
1344
|
this.get_dates_to_draw().forEach((t, e) => {
|
|
@@ -1309,11 +1375,11 @@ class j {
|
|
|
1309
1375
|
let i = e ? e.date : null;
|
|
1310
1376
|
this.config.column_width;
|
|
1311
1377
|
const s = e ? e.x + e.column_width : 0;
|
|
1312
|
-
let n = this.config.view_mode.upper_text,
|
|
1313
|
-
return n ? typeof n == "string" && (this.config.view_mode.upper_text = (
|
|
1378
|
+
let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
|
|
1379
|
+
return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => c.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => c.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
|
|
1314
1380
|
date: t,
|
|
1315
1381
|
formatted_date: k(
|
|
1316
|
-
|
|
1382
|
+
c.format(
|
|
1317
1383
|
t,
|
|
1318
1384
|
this.config.date_format,
|
|
1319
1385
|
this.options.language
|
|
@@ -1337,7 +1403,7 @@ class j {
|
|
|
1337
1403
|
}
|
|
1338
1404
|
make_bars() {
|
|
1339
1405
|
this.bars = this.tasks.map((t) => {
|
|
1340
|
-
const e = new
|
|
1406
|
+
const e = new q(this, t);
|
|
1341
1407
|
return this.layers.bar.appendChild(e.group), e;
|
|
1342
1408
|
});
|
|
1343
1409
|
}
|
|
@@ -1348,7 +1414,7 @@ class j {
|
|
|
1348
1414
|
e = t.dependencies.map((i) => {
|
|
1349
1415
|
const s = this.get_task(i);
|
|
1350
1416
|
if (!s) return;
|
|
1351
|
-
const n = new
|
|
1417
|
+
const n = new C(
|
|
1352
1418
|
this,
|
|
1353
1419
|
this.bars[s._index],
|
|
1354
1420
|
// from_task
|
|
@@ -1367,35 +1433,35 @@ class j {
|
|
|
1367
1433
|
});
|
|
1368
1434
|
const e = (n) => {
|
|
1369
1435
|
if (t[n.id].ef > 0) return t[n.id];
|
|
1370
|
-
let
|
|
1436
|
+
let o = 0;
|
|
1371
1437
|
n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
|
|
1372
1438
|
const d = this.get_task(h);
|
|
1373
1439
|
if (d) {
|
|
1374
1440
|
const _ = e(d);
|
|
1375
|
-
|
|
1441
|
+
o = Math.max(o, _.ef);
|
|
1376
1442
|
}
|
|
1377
|
-
}), t[n.id].es =
|
|
1378
|
-
const
|
|
1379
|
-
return t[n.id].ef =
|
|
1443
|
+
}), t[n.id].es = o;
|
|
1444
|
+
const a = c.diff(n._end, n._start, "hour") / 24;
|
|
1445
|
+
return t[n.id].ef = o + a, t[n.id];
|
|
1380
1446
|
};
|
|
1381
1447
|
this.tasks.forEach((n) => e(n));
|
|
1382
1448
|
const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
|
|
1383
1449
|
if (t[n.id].ls > 0 || t[n.id].lf > 0)
|
|
1384
1450
|
return t[n.id];
|
|
1385
|
-
const
|
|
1451
|
+
const o = this.tasks.filter(
|
|
1386
1452
|
(d) => d.dependencies && d.dependencies.includes(n.id)
|
|
1387
1453
|
);
|
|
1388
|
-
let
|
|
1389
|
-
|
|
1454
|
+
let a = i;
|
|
1455
|
+
o.length > 0 && o.forEach((d) => {
|
|
1390
1456
|
const _ = s(d);
|
|
1391
|
-
|
|
1457
|
+
a = Math.min(a, _.ls);
|
|
1392
1458
|
});
|
|
1393
|
-
const h =
|
|
1394
|
-
return t[n.id].lf =
|
|
1459
|
+
const h = c.diff(n._end, n._start, "hour") / 24;
|
|
1460
|
+
return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
|
|
1395
1461
|
};
|
|
1396
1462
|
this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
|
|
1397
|
-
const
|
|
1398
|
-
n._is_critical = Math.abs(
|
|
1463
|
+
const o = t[n.id], a = o.ls - o.es;
|
|
1464
|
+
n._is_critical = Math.abs(a) < 0.01;
|
|
1399
1465
|
});
|
|
1400
1466
|
}
|
|
1401
1467
|
update_arrow_critical_path() {
|
|
@@ -1413,8 +1479,8 @@ class j {
|
|
|
1413
1479
|
}
|
|
1414
1480
|
set_scroll_position(t) {
|
|
1415
1481
|
if (this.options.infinite_padding && (!t || t === "start")) {
|
|
1416
|
-
let [
|
|
1417
|
-
this.$container.scrollLeft =
|
|
1482
|
+
let [o, ...a] = this.get_start_end_positions();
|
|
1483
|
+
this.$container.scrollLeft = o;
|
|
1418
1484
|
return;
|
|
1419
1485
|
}
|
|
1420
1486
|
if (!t || t === "start")
|
|
@@ -1424,9 +1490,9 @@ class j {
|
|
|
1424
1490
|
else {
|
|
1425
1491
|
if (t === "today")
|
|
1426
1492
|
return this.scroll_current();
|
|
1427
|
-
typeof t == "string" && (t =
|
|
1493
|
+
typeof t == "string" && (t = c.parse(t));
|
|
1428
1494
|
}
|
|
1429
|
-
const i =
|
|
1495
|
+
const i = c.diff(
|
|
1430
1496
|
t,
|
|
1431
1497
|
this.gantt_start,
|
|
1432
1498
|
this.config.unit
|
|
@@ -1434,7 +1500,7 @@ class j {
|
|
|
1434
1500
|
this.$container.scrollTo({
|
|
1435
1501
|
left: i - this.config.column_width / 6,
|
|
1436
1502
|
behavior: "smooth"
|
|
1437
|
-
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date =
|
|
1503
|
+
}), this.$current && this.$current.classList.remove("current-upper"), this.current_date = c.add(
|
|
1438
1504
|
this.gantt_start,
|
|
1439
1505
|
this.$container.scrollLeft / this.config.column_width,
|
|
1440
1506
|
this.config.unit
|
|
@@ -1444,9 +1510,9 @@ class j {
|
|
|
1444
1510
|
null,
|
|
1445
1511
|
this.options.language
|
|
1446
1512
|
), n = this.upperTexts.find(
|
|
1447
|
-
(
|
|
1513
|
+
(o) => o.textContent === s
|
|
1448
1514
|
);
|
|
1449
|
-
this.current_date =
|
|
1515
|
+
this.current_date = c.add(
|
|
1450
1516
|
this.gantt_start,
|
|
1451
1517
|
(this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
|
|
1452
1518
|
this.config.unit
|
|
@@ -1454,7 +1520,7 @@ class j {
|
|
|
1454
1520
|
this.current_date,
|
|
1455
1521
|
null,
|
|
1456
1522
|
this.options.language
|
|
1457
|
-
), n = this.upperTexts.find((
|
|
1523
|
+
), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
|
|
1458
1524
|
}
|
|
1459
1525
|
scroll_current() {
|
|
1460
1526
|
let t = this.get_closest_date();
|
|
@@ -1465,7 +1531,7 @@ class j {
|
|
|
1465
1531
|
if (t < this.gantt_start || t > this.gantt_end) return null;
|
|
1466
1532
|
let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
|
|
1467
1533
|
".date_" + k(
|
|
1468
|
-
|
|
1534
|
+
c.format(
|
|
1469
1535
|
e,
|
|
1470
1536
|
this.config.date_format,
|
|
1471
1537
|
this.options.language
|
|
@@ -1473,9 +1539,9 @@ class j {
|
|
|
1473
1539
|
)
|
|
1474
1540
|
), s = 0;
|
|
1475
1541
|
for (; !i && s < this.config.step; )
|
|
1476
|
-
e =
|
|
1542
|
+
e = c.add(e, -1, this.config.unit), i = this.$container.querySelector(
|
|
1477
1543
|
".date_" + k(
|
|
1478
|
-
|
|
1544
|
+
c.format(
|
|
1479
1545
|
e,
|
|
1480
1546
|
this.config.date_format,
|
|
1481
1547
|
this.options.language
|
|
@@ -1484,7 +1550,7 @@ class j {
|
|
|
1484
1550
|
), s++;
|
|
1485
1551
|
return [
|
|
1486
1552
|
/* @__PURE__ */ new Date(
|
|
1487
|
-
|
|
1553
|
+
c.format(
|
|
1488
1554
|
e,
|
|
1489
1555
|
this.config.date_format,
|
|
1490
1556
|
this.options.language
|
|
@@ -1494,7 +1560,7 @@ class j {
|
|
|
1494
1560
|
];
|
|
1495
1561
|
}
|
|
1496
1562
|
bind_grid_click() {
|
|
1497
|
-
|
|
1563
|
+
u.on(
|
|
1498
1564
|
this.$container,
|
|
1499
1565
|
"click",
|
|
1500
1566
|
".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
|
|
@@ -1523,62 +1589,62 @@ class j {
|
|
|
1523
1589
|
get_start_end_positions() {
|
|
1524
1590
|
if (!this.bars.length) return [0, 0, 0];
|
|
1525
1591
|
let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
|
|
1526
|
-
return Array.prototype.forEach.call(this.bars, function({ group:
|
|
1527
|
-
let { x: h, width: d } =
|
|
1592
|
+
return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
|
|
1593
|
+
let { x: h, width: d } = o.getBBox();
|
|
1528
1594
|
h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
|
|
1529
1595
|
}), [i, s, n];
|
|
1530
1596
|
}
|
|
1531
1597
|
bind_bar_events() {
|
|
1532
|
-
let t = !1, e = 0, i = 0, s = !1, n = !1,
|
|
1598
|
+
let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
|
|
1533
1599
|
this.bar_being_dragged = null;
|
|
1534
1600
|
const h = () => t || s || n;
|
|
1535
1601
|
this.$svg.onclick = (_) => {
|
|
1536
1602
|
_.target.classList.contains("grid-row") && this.unselect_all();
|
|
1537
1603
|
};
|
|
1538
1604
|
let d = 0;
|
|
1539
|
-
if (
|
|
1605
|
+
if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
|
|
1540
1606
|
this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
|
|
1541
|
-
}),
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
const $ = this.get_bar(
|
|
1607
|
+
}), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, l) => {
|
|
1608
|
+
const p = u.closest(".bar-wrapper", l);
|
|
1609
|
+
l.classList.contains("left") ? (s = !0, l.classList.add("visible")) : l.classList.contains("right") ? (n = !0, l.classList.add("visible")) : l.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = p.getAttribute("data-id");
|
|
1610
|
+
const $ = this.get_bar(o).task.dependencies_type || this.options.dependencies_type;
|
|
1545
1611
|
let m;
|
|
1546
1612
|
this.options.move_dependencies && $ === "fixed" ? m = [
|
|
1547
|
-
|
|
1548
|
-
...this.get_all_dependent_tasks(
|
|
1549
|
-
] : m = [
|
|
1613
|
+
o,
|
|
1614
|
+
...this.get_all_dependent_tasks(o)
|
|
1615
|
+
] : m = [o], a = m.map((x) => this.get_bar(x)), this.bar_being_dragged = !1, d = e, a.forEach((x) => {
|
|
1550
1616
|
const w = x.$bar;
|
|
1551
1617
|
w.ox = w.getX(), w.oy = w.getY(), w.owidth = w.getWidth(), w.finaldx = 0;
|
|
1552
1618
|
});
|
|
1553
1619
|
}), this.options.infinite_padding) {
|
|
1554
1620
|
let _ = !1;
|
|
1555
|
-
|
|
1556
|
-
let
|
|
1557
|
-
if (!_ &&
|
|
1558
|
-
let
|
|
1559
|
-
_ = !0, this.gantt_start =
|
|
1621
|
+
u.on(this.$container, "mousewheel", (l) => {
|
|
1622
|
+
let p = this.$container.scrollWidth / 2;
|
|
1623
|
+
if (!_ && l.currentTarget.scrollLeft <= p) {
|
|
1624
|
+
let g = l.currentTarget.scrollLeft;
|
|
1625
|
+
_ = !0, this.gantt_start = c.add(
|
|
1560
1626
|
this.gantt_start,
|
|
1561
1627
|
-this.config.extend_by_units,
|
|
1562
1628
|
this.config.unit
|
|
1563
|
-
), this.setup_date_values(), this.render(),
|
|
1629
|
+
), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
|
|
1564
1630
|
}
|
|
1565
|
-
if (!_ &&
|
|
1566
|
-
let
|
|
1567
|
-
_ = !0, this.gantt_end =
|
|
1631
|
+
if (!_ && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= p) {
|
|
1632
|
+
let g = l.currentTarget.scrollLeft;
|
|
1633
|
+
_ = !0, this.gantt_end = c.add(
|
|
1568
1634
|
this.gantt_end,
|
|
1569
1635
|
this.config.extend_by_units,
|
|
1570
1636
|
this.config.unit
|
|
1571
|
-
), this.setup_date_values(), this.render(),
|
|
1637
|
+
), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g, setTimeout(() => _ = !1, 300);
|
|
1572
1638
|
}
|
|
1573
1639
|
});
|
|
1574
1640
|
}
|
|
1575
|
-
|
|
1576
|
-
let
|
|
1577
|
-
const
|
|
1641
|
+
u.on(this.$container, "scroll", (_) => {
|
|
1642
|
+
let l = [];
|
|
1643
|
+
const p = this.bars.map(
|
|
1578
1644
|
({ group: b }) => b.getAttribute("data-id")
|
|
1579
1645
|
);
|
|
1580
|
-
let
|
|
1581
|
-
i && (
|
|
1646
|
+
let g;
|
|
1647
|
+
i && (g = _.currentTarget.scrollLeft - i), this.current_date = c.add(
|
|
1582
1648
|
this.gantt_start,
|
|
1583
1649
|
_.currentTarget.scrollLeft / this.config.column_width * this.config.step,
|
|
1584
1650
|
this.config.unit
|
|
@@ -1590,7 +1656,7 @@ class j {
|
|
|
1590
1656
|
), m = this.upperTexts.find(
|
|
1591
1657
|
(b) => b.textContent === $
|
|
1592
1658
|
);
|
|
1593
|
-
this.current_date =
|
|
1659
|
+
this.current_date = c.add(
|
|
1594
1660
|
this.gantt_start,
|
|
1595
1661
|
(_.currentTarget.scrollLeft + m.clientWidth) / this.config.column_width * this.config.step,
|
|
1596
1662
|
this.config.unit
|
|
@@ -1612,131 +1678,150 @@ class j {
|
|
|
1612
1678
|
left: x,
|
|
1613
1679
|
behavior: "smooth"
|
|
1614
1680
|
});
|
|
1615
|
-
}) : this.$adjust.classList.add("hide"),
|
|
1681
|
+
}) : this.$adjust.classList.add("hide"), g && (l = p.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
|
|
1616
1682
|
b.update_label_position_on_horizontal_scroll({
|
|
1617
|
-
x:
|
|
1683
|
+
x: g,
|
|
1618
1684
|
sx: _.currentTarget.scrollLeft
|
|
1619
1685
|
});
|
|
1620
1686
|
}));
|
|
1621
|
-
}),
|
|
1687
|
+
}), u.on(this.$svg, "mousemove", (_) => {
|
|
1622
1688
|
if (!h()) return;
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
x:
|
|
1628
|
-
width:
|
|
1629
|
-
}) :
|
|
1630
|
-
x:
|
|
1631
|
-
}) : n ?
|
|
1632
|
-
width:
|
|
1633
|
-
}) : t && !this.options.readonly && !this.options.readonly_dates &&
|
|
1689
|
+
const l = (_.offsetX || _.layerX) - e;
|
|
1690
|
+
a.forEach((p) => {
|
|
1691
|
+
const g = p.$bar;
|
|
1692
|
+
g.finaldx = this.get_snap_position(l, g.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
|
|
1693
|
+
x: g.ox + g.finaldx,
|
|
1694
|
+
width: g.owidth - g.finaldx
|
|
1695
|
+
}) : p.update_bar_position({
|
|
1696
|
+
x: g.ox + g.finaldx
|
|
1697
|
+
}) : n ? o === p.task.id && p.update_bar_position({
|
|
1698
|
+
width: g.owidth + g.finaldx
|
|
1699
|
+
}) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: g.ox + g.finaldx });
|
|
1634
1700
|
});
|
|
1635
1701
|
}), document.addEventListener("mouseup", () => {
|
|
1636
|
-
var _,
|
|
1637
|
-
t = !1, s = !1, n = !1, (
|
|
1638
|
-
}),
|
|
1639
|
-
this.bar_being_dragged = null
|
|
1640
|
-
|
|
1702
|
+
var _, l, p;
|
|
1703
|
+
t = !1, s = !1, n = !1, (p = (l = (_ = this.$container.querySelector(".visible")) == null ? void 0 : _.classList) == null ? void 0 : l.remove) == null || p.call(l, "visible");
|
|
1704
|
+
}), u.on(this.$svg, "mouseup", (_) => {
|
|
1705
|
+
this.bar_being_dragged = null;
|
|
1706
|
+
const l = [];
|
|
1707
|
+
a.forEach((g) => {
|
|
1708
|
+
g.$bar.finaldx && (g.date_changed(), g.compute_progress(), g.set_action_completed(), l.push({
|
|
1709
|
+
task: g.task,
|
|
1710
|
+
start: g.task._start,
|
|
1711
|
+
end: c.add(g.task._end, -1, "second")
|
|
1712
|
+
}));
|
|
1713
|
+
});
|
|
1714
|
+
const p = this.get_bar(o);
|
|
1715
|
+
if (p && p.$bar.finaldx) {
|
|
1716
|
+
const g = this.update_dependent_tasks_by_type(p);
|
|
1717
|
+
l.push(...g);
|
|
1718
|
+
}
|
|
1719
|
+
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 }) => {
|
|
1720
|
+
this.trigger_event("after_date_change", [g, $, m]);
|
|
1641
1721
|
});
|
|
1642
|
-
const c = this.get_bar(a);
|
|
1643
|
-
c && c.$bar.finaldx && this.update_dependent_tasks_by_type(c), this.options.critical_path && o.some((g) => g.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path());
|
|
1644
1722
|
}), this.bind_bar_progress();
|
|
1645
1723
|
}
|
|
1646
1724
|
bind_bar_progress() {
|
|
1647
1725
|
let t = 0, e = null, i = null, s = null, n = null;
|
|
1648
|
-
|
|
1649
|
-
e = !0, t =
|
|
1650
|
-
const _ =
|
|
1726
|
+
u.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
|
|
1727
|
+
e = !0, t = a.offsetX || a.layerX;
|
|
1728
|
+
const _ = u.closest(".bar-wrapper", h).getAttribute("data-id");
|
|
1651
1729
|
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();
|
|
1652
1730
|
});
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1731
|
+
const o = this.config.ignored_positions.map((a) => [
|
|
1732
|
+
a,
|
|
1733
|
+
a + this.config.column_width
|
|
1656
1734
|
]);
|
|
1657
|
-
|
|
1735
|
+
u.on(this.$svg, "mousemove", (a) => {
|
|
1658
1736
|
if (!e) return;
|
|
1659
|
-
let h =
|
|
1737
|
+
let h = a.offsetX || a.layerX;
|
|
1660
1738
|
if (h > t) {
|
|
1661
|
-
let
|
|
1662
|
-
([
|
|
1739
|
+
let l = o.find(
|
|
1740
|
+
([p, g]) => h >= p && h < g
|
|
1663
1741
|
);
|
|
1664
|
-
for (;
|
|
1665
|
-
h =
|
|
1666
|
-
([
|
|
1742
|
+
for (; l; )
|
|
1743
|
+
h = l[1], l = o.find(
|
|
1744
|
+
([p, g]) => h >= p && h < g
|
|
1667
1745
|
);
|
|
1668
1746
|
} else {
|
|
1669
|
-
let
|
|
1670
|
-
([
|
|
1747
|
+
let l = o.find(
|
|
1748
|
+
([p, g]) => h > p && h <= g
|
|
1671
1749
|
);
|
|
1672
|
-
for (;
|
|
1673
|
-
h =
|
|
1674
|
-
([
|
|
1750
|
+
for (; l; )
|
|
1751
|
+
h = l[0], l = o.find(
|
|
1752
|
+
([p, g]) => h > p && h <= g
|
|
1675
1753
|
);
|
|
1676
1754
|
}
|
|
1677
1755
|
let _ = h - t;
|
|
1678
|
-
console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _),
|
|
1679
|
-
}),
|
|
1756
|
+
console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), u.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
|
|
1757
|
+
}), u.on(this.$svg, "mouseup", () => {
|
|
1680
1758
|
e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
|
|
1681
1759
|
});
|
|
1682
1760
|
}
|
|
1683
1761
|
get_all_dependent_tasks(t) {
|
|
1684
1762
|
let e = [], i = [t];
|
|
1685
1763
|
for (; i.length; ) {
|
|
1686
|
-
const s = i.reduce((n,
|
|
1764
|
+
const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
|
|
1687
1765
|
e = e.concat(s), i = s.filter((n) => !i.includes(n));
|
|
1688
1766
|
}
|
|
1689
1767
|
return e.filter(Boolean);
|
|
1690
1768
|
}
|
|
1691
1769
|
update_dependent_tasks_by_type(t) {
|
|
1692
|
-
|
|
1693
|
-
(this.dependency_map[t.task.id] || []).forEach((
|
|
1694
|
-
const
|
|
1695
|
-
if (!
|
|
1696
|
-
const a =
|
|
1697
|
-
let
|
|
1698
|
-
const
|
|
1699
|
-
let
|
|
1700
|
-
switch (
|
|
1770
|
+
const e = t.task.dependencies_type || this.options.dependencies_type, i = [];
|
|
1771
|
+
return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((n) => {
|
|
1772
|
+
const o = this.get_bar(n);
|
|
1773
|
+
if (!o) return;
|
|
1774
|
+
const a = o.task, h = a.dependencies_type || this.options.dependencies_type;
|
|
1775
|
+
let d, _;
|
|
1776
|
+
const l = c.diff(a._end, a._start, "hour");
|
|
1777
|
+
let p = !1;
|
|
1778
|
+
switch (h) {
|
|
1701
1779
|
case "finish-to-start":
|
|
1702
|
-
t.task._end > a._start && (
|
|
1780
|
+
t.task._end > a._start && (d = new Date(t.task._end), _ = c.add(d, l, "hour"), p = !0);
|
|
1703
1781
|
break;
|
|
1704
1782
|
case "start-to-start":
|
|
1705
|
-
t.task._start > a._start && (
|
|
1783
|
+
t.task._start > a._start && (d = new Date(t.task._start), _ = c.add(d, l, "hour"), p = !0);
|
|
1706
1784
|
break;
|
|
1707
1785
|
case "finish-to-finish":
|
|
1708
|
-
t.task._end > a._end && (
|
|
1786
|
+
t.task._end > a._end && (_ = new Date(t.task._end), d = c.add(_, -l, "hour"), p = !0);
|
|
1709
1787
|
break;
|
|
1710
1788
|
case "start-to-finish":
|
|
1711
|
-
t.task._start > a._end && (
|
|
1789
|
+
t.task._start > a._end && (_ = new Date(t.task._start), d = c.add(_, -l, "hour"), p = !0);
|
|
1712
1790
|
break;
|
|
1713
1791
|
default:
|
|
1714
1792
|
return;
|
|
1715
1793
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1794
|
+
if (!p) return;
|
|
1795
|
+
a._start = d, a._end = _, o.compute_x(), o.compute_duration(), o.update_bar_position({
|
|
1796
|
+
x: o.x,
|
|
1797
|
+
width: o.width
|
|
1719
1798
|
}), this.trigger_event("date_change", [
|
|
1720
1799
|
a,
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
]),
|
|
1724
|
-
|
|
1800
|
+
d,
|
|
1801
|
+
c.add(_, -1, "second")
|
|
1802
|
+
]), i.push({
|
|
1803
|
+
task: a,
|
|
1804
|
+
start: d,
|
|
1805
|
+
end: c.add(_, -1, "second")
|
|
1806
|
+
});
|
|
1807
|
+
const g = this.update_dependent_tasks_by_type(o);
|
|
1808
|
+
i.push(...g);
|
|
1809
|
+
}), i;
|
|
1725
1810
|
}
|
|
1726
1811
|
get_snap_position(t, e) {
|
|
1727
1812
|
let i = 1;
|
|
1728
1813
|
const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
|
|
1729
1814
|
if (s !== "unit") {
|
|
1730
|
-
const { duration: _, scale:
|
|
1731
|
-
i =
|
|
1815
|
+
const { duration: _, scale: l } = c.parse_duration(s);
|
|
1816
|
+
i = c.convert_scales(this.config.view_mode.step, l) / _;
|
|
1732
1817
|
}
|
|
1733
1818
|
const n = t % (this.config.column_width / i);
|
|
1734
|
-
let
|
|
1735
|
-
const h =
|
|
1736
|
-
let d = this.get_ignored_region(
|
|
1819
|
+
let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
|
|
1820
|
+
const h = o > 0 ? 1 : -1;
|
|
1821
|
+
let d = this.get_ignored_region(a, h);
|
|
1737
1822
|
for (; d.length; )
|
|
1738
|
-
|
|
1739
|
-
return
|
|
1823
|
+
a += this.config.column_width * h, d = this.get_ignored_region(a, h), d.length || (a -= this.config.column_width * h);
|
|
1824
|
+
return a - e;
|
|
1740
1825
|
}
|
|
1741
1826
|
get_ignored_region(t, e = 1) {
|
|
1742
1827
|
return e === 1 ? this.config.ignored_positions.filter((i) => t > i && t <= i + this.config.column_width) : this.config.ignored_positions.filter(
|
|
@@ -1756,7 +1841,7 @@ class j {
|
|
|
1756
1841
|
return this.bars.find((e) => e.task.id === t);
|
|
1757
1842
|
}
|
|
1758
1843
|
show_popup(t) {
|
|
1759
|
-
this.options.popup !== !1 && (this.popup || (this.popup = new
|
|
1844
|
+
this.options.popup !== !1 && (this.popup || (this.popup = new F(
|
|
1760
1845
|
this.$popup_wrapper,
|
|
1761
1846
|
this.options.popup,
|
|
1762
1847
|
this
|
|
@@ -1785,8 +1870,8 @@ class j {
|
|
|
1785
1870
|
* @memberof Gantt
|
|
1786
1871
|
*/
|
|
1787
1872
|
clear() {
|
|
1788
|
-
var t, e, i, s, n,
|
|
1789
|
-
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), (
|
|
1873
|
+
var t, e, i, s, n, o, a, h, d, _;
|
|
1874
|
+
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.$current_highlight) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$extras) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.popup) == null ? void 0 : d.hide) == null || _.call(d);
|
|
1790
1875
|
}
|
|
1791
1876
|
}
|
|
1792
1877
|
j.VIEW_MODE = {
|