fix: more bugs
This commit is contained in:
parent
30a8d5a78b
commit
e648769ec5
118
dist/frappe-gantt.js
vendored
118
dist/frappe-gantt.js
vendored
@ -13,8 +13,8 @@ const M = "year", D = "month", v = "day", E = "hour", Y = "minute", A = "second"
|
|||||||
December: "Dec"
|
December: "Dec"
|
||||||
}, h = {
|
}, h = {
|
||||||
parse_duration(n) {
|
parse_duration(n) {
|
||||||
const e = /([0-9])+(y|m|d|h|min|s|ms)/gm.exec(n);
|
const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(n);
|
||||||
if (e !== null) {
|
if (console.log(e), e !== null) {
|
||||||
if (e[2] === "y")
|
if (e[2] === "y")
|
||||||
return { duration: parseInt(e[1]), scale: "year" };
|
return { duration: parseInt(e[1]), scale: "year" };
|
||||||
if (e[2] === "m")
|
if (e[2] === "m")
|
||||||
@ -63,25 +63,25 @@ const M = "year", D = "month", v = "day", E = "hour", Y = "minute", A = "second"
|
|||||||
MMMM: r,
|
MMMM: r,
|
||||||
MMM: T[r]
|
MMM: T[r]
|
||||||
};
|
};
|
||||||
let p = t;
|
let d = t;
|
||||||
const d = [];
|
const p = [];
|
||||||
return Object.keys(a).sort((g, u) => u.length - g.length).forEach((g) => {
|
return Object.keys(a).sort((g, u) => u.length - g.length).forEach((g) => {
|
||||||
p.includes(g) && (p = p.replaceAll(g, `$${d.length}`), d.push(a[g]));
|
d.includes(g) && (d = d.replaceAll(g, `$${p.length}`), p.push(a[g]));
|
||||||
}), d.forEach((g, u) => {
|
}), p.forEach((g, u) => {
|
||||||
p = p.replaceAll(`$${u}`, g);
|
d = d.replaceAll(`$${u}`, g);
|
||||||
}), p;
|
}), d;
|
||||||
},
|
},
|
||||||
diff(n, t, e = v) {
|
diff(n, t, e = v) {
|
||||||
let s, i, r, o, a, p, d;
|
let s, i, r, o, a, d, p;
|
||||||
return s = n - t, i = s / 1e3, o = i / 60, r = o / 60, a = r / 24, p = a / 30, d = p / 12, e.endsWith("s") || (e += "s"), Math.floor(
|
return s = n - t, i = s / 1e3, o = i / 60, r = o / 60, a = r / 24, d = a / 30, p = d / 12, e.endsWith("s") || (e += "s"), Math.floor(
|
||||||
{
|
{
|
||||||
milliseconds: s,
|
milliseconds: s,
|
||||||
seconds: i,
|
seconds: i,
|
||||||
minutes: o,
|
minutes: o,
|
||||||
hours: r,
|
hours: r,
|
||||||
days: a,
|
days: a,
|
||||||
months: p,
|
months: d,
|
||||||
years: d
|
years: p
|
||||||
}[e]
|
}[e]
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -456,8 +456,8 @@ class O {
|
|||||||
}
|
}
|
||||||
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
|
||||||
const s = document.querySelector(".gantt-container"), i = this.group.querySelector(".bar-label"), r = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
|
const s = document.querySelector(".gantt-container"), i = this.group.querySelector(".bar-label"), r = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
|
||||||
let a = this.$bar.getX() + this.$bar.getWidth(), p = i.getX() + t, d = r && r.getX() + t || 0, g = r && r.getBBox().width + 7 || 7, u = p + i.getBBox().width + 7, f = e + s.clientWidth / 2;
|
let a = this.$bar.getX() + this.$bar.getWidth(), d = i.getX() + t, p = r && r.getX() + t || 0, g = r && r.getBBox().width + 7 || 7, u = d + i.getBBox().width + 7, f = e + s.clientWidth / 2;
|
||||||
i.classList.contains("big") || (u < a && t > 0 && u < f || p - g > this.$bar.getX() && t < 0 && u > f) && (i.setAttribute("x", p), r && (r.setAttribute("x", d), o.setAttribute("x", d)));
|
i.classList.contains("big") || (u < a && t > 0 && u < f || d - g > this.$bar.getX() && t < 0 && u > f) && (i.setAttribute("x", d), r && (r.setAttribute("x", p), o.setAttribute("x", p)));
|
||||||
}
|
}
|
||||||
date_changed() {
|
date_changed() {
|
||||||
let t = !1;
|
let t = !1;
|
||||||
@ -533,8 +533,8 @@ class O {
|
|||||||
update_label_position() {
|
update_label_position() {
|
||||||
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, s = this.group.querySelector(".bar-label"), i = this.group.querySelector(".bar-img");
|
const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, s = this.group.querySelector(".bar-label"), i = this.group.querySelector(".bar-img");
|
||||||
let r = 5, o = this.image_size + 10;
|
let r = 5, o = this.image_size + 10;
|
||||||
const a = s.getBBox().width, p = e.getWidth();
|
const a = s.getBBox().width, d = e.getWidth();
|
||||||
a > p ? (s.classList.add("big"), i ? (i.setAttribute("x", e.getX() + e.getWidth() + r), t.setAttribute(
|
a > d ? (s.classList.add("big"), i ? (i.setAttribute("x", e.getX() + e.getWidth() + r), t.setAttribute(
|
||||||
"x",
|
"x",
|
||||||
e.getX() + e.getWidth() + r
|
e.getX() + e.getWidth() + r
|
||||||
), s.setAttribute(
|
), s.setAttribute(
|
||||||
@ -542,10 +542,10 @@ class O {
|
|||||||
e.getX() + e.getWidth() + o
|
e.getX() + e.getWidth() + o
|
||||||
)) : s.setAttribute("x", e.getX() + e.getWidth() + r)) : (s.classList.remove("big"), i ? (i.setAttribute("x", e.getX() + r), t.setAttribute("x", e.getX() + r), s.setAttribute(
|
)) : s.setAttribute("x", e.getX() + e.getWidth() + r)) : (s.classList.remove("big"), i ? (i.setAttribute("x", e.getX() + r), t.setAttribute("x", e.getX() + r), s.setAttribute(
|
||||||
"x",
|
"x",
|
||||||
e.getX() + p / 2 + o
|
e.getX() + d / 2 + o
|
||||||
)) : s.setAttribute(
|
)) : s.setAttribute(
|
||||||
"x",
|
"x",
|
||||||
e.getX() + p / 2 - a / 2
|
e.getX() + d / 2 - a / 2
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
update_handle_position() {
|
update_handle_position() {
|
||||||
@ -554,7 +554,7 @@ class O {
|
|||||||
const t = this.$bar;
|
const t = this.$bar;
|
||||||
this.handle_group.querySelector(".handle.left").setAttribute("x", t.getX() - 12), this.handle_group.querySelector(".handle.right").setAttribute("x", t.getEndX() + 4);
|
this.handle_group.querySelector(".handle.left").setAttribute("x", t.getX() - 12), this.handle_group.querySelector(".handle.right").setAttribute("x", t.getEndX() + 4);
|
||||||
const e = this.group.querySelector(".handle.progress");
|
const e = this.group.querySelector(".handle.progress");
|
||||||
console.log(e, this.$bar_progress.getEndX()), e && e.setAttribute("cx", this.$bar_progress.getEndX());
|
e && e.setAttribute("cx", this.$bar_progress.getEndX());
|
||||||
}
|
}
|
||||||
update_arrow_position() {
|
update_arrow_position() {
|
||||||
this.arrows = this.arrows || [];
|
this.arrows = this.arrows || [];
|
||||||
@ -571,24 +571,24 @@ class C {
|
|||||||
const e = () => this.to_task.$bar.getX() < t + this.gantt.options.padding && t > this.from_task.$bar.getX() + this.gantt.options.padding;
|
const e = () => this.to_task.$bar.getX() < t + this.gantt.options.padding && t > this.from_task.$bar.getX() + this.gantt.options.padding;
|
||||||
for (; e(); )
|
for (; e(); )
|
||||||
t -= 10;
|
t -= 10;
|
||||||
const s = this.gantt.options.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, i = this.to_task.$bar.getX() - this.gantt.options.padding / 2 - 7, r = this.gantt.options.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, o = this.from_task.task._index > this.to_task.task._index, a = this.gantt.options.arrow_curve, p = o ? 1 : 0, d = o ? -a : a, g = o ? r + this.gantt.options.arrow_curve : r - this.gantt.options.arrow_curve;
|
const s = this.gantt.options.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, i = this.to_task.$bar.getX() - this.gantt.options.padding / 2 - 7, r = this.gantt.options.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, o = this.from_task.task._index > this.to_task.task._index, a = this.gantt.options.arrow_curve, d = o ? 1 : 0, p = o ? -a : a, g = o ? r + this.gantt.options.arrow_curve : r - this.gantt.options.arrow_curve;
|
||||||
if (this.path = `
|
if (this.path = `
|
||||||
M ${t} ${s}
|
M ${t} ${s}
|
||||||
V ${g}
|
V ${g}
|
||||||
a ${a} ${a} 0 0 ${p} ${a} ${d}
|
a ${a} ${a} 0 0 ${d} ${a} ${p}
|
||||||
L ${i} ${r}
|
L ${i} ${r}
|
||||||
m -5 -5
|
m -5 -5
|
||||||
l 5 5
|
l 5 5
|
||||||
l -5 5`, this.to_task.$bar.getX() < this.from_task.$bar.getX() + this.gantt.options.padding) {
|
l -5 5`, this.to_task.$bar.getX() < this.from_task.$bar.getX() + this.gantt.options.padding) {
|
||||||
const u = this.gantt.options.padding / 2 - a, f = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, w = this.to_task.$bar.getX() - this.gantt.options.padding;
|
const u = this.gantt.options.padding / 2 - a, f = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - p, w = this.to_task.$bar.getX() - this.gantt.options.padding;
|
||||||
this.path = `
|
this.path = `
|
||||||
M ${t} ${s}
|
M ${t} ${s}
|
||||||
v ${u}
|
v ${u}
|
||||||
a ${a} ${a} 0 0 1 -${a} ${a}
|
a ${a} ${a} 0 0 1 -${a} ${a}
|
||||||
H ${w}
|
H ${w}
|
||||||
a ${a} ${a} 0 0 ${p} -${a} ${d}
|
a ${a} ${a} 0 0 ${d} -${a} ${p}
|
||||||
V ${f}
|
V ${f}
|
||||||
a ${a} ${a} 0 0 ${p} ${a} ${d}
|
a ${a} ${a} 0 0 ${d} ${a} ${p}
|
||||||
L ${i} ${r}
|
L ${i} ${r}
|
||||||
m -5 -5
|
m -5 -5
|
||||||
l 5 5
|
l 5 5
|
||||||
@ -652,7 +652,6 @@ const l = {
|
|||||||
}, R = {
|
}, R = {
|
||||||
header_height: 65,
|
header_height: 65,
|
||||||
column_width: 30,
|
column_width: 30,
|
||||||
step: 24,
|
|
||||||
view_modes: [...Object.values(l)],
|
view_modes: [...Object.values(l)],
|
||||||
bar_height: 30,
|
bar_height: 30,
|
||||||
bar_corner_radius: 3,
|
bar_corner_radius: 3,
|
||||||
@ -704,8 +703,8 @@ class F {
|
|||||||
setup_tasks(t) {
|
setup_tasks(t) {
|
||||||
this.tasks = t.map((e, s) => {
|
this.tasks = t.map((e, s) => {
|
||||||
if (e._start = h.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
|
if (e._start = h.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
|
||||||
let { duration: p, scale: d } = h.parse_duration(a);
|
let { duration: d, scale: p } = h.parse_duration(a);
|
||||||
e.end = h.add(e.end, p, d);
|
e.end = h.add(e.end, d, p);
|
||||||
})), e._end = h.parse(e.end), h.diff(e._end, e._start, "year") < 0)
|
})), e._end = h.parse(e.end), h.diff(e._end, e._start, "year") < 0)
|
||||||
throw Error(
|
throw Error(
|
||||||
"start of task can't be after end of task: in task #, " + (s + 1)
|
"start of task can't be after end of task: in task #, " + (s + 1)
|
||||||
@ -746,8 +745,8 @@ class F {
|
|||||||
let t, e;
|
let t, e;
|
||||||
this.gantt_start ? t = h.start_of(this.gantt_start, "day") : t = /* @__PURE__ */ new Date(), this.gantt_end ? e = h.start_of(this.gantt_end, "day") : e = /* @__PURE__ */ new Date();
|
this.gantt_start ? t = h.start_of(this.gantt_start, "day") : t = /* @__PURE__ */ new Date(), this.gantt_end ? e = h.start_of(this.gantt_end, "day") : e = /* @__PURE__ */ new Date();
|
||||||
let s;
|
let s;
|
||||||
for (let [a, p] of Object.entries(l))
|
for (let [a, d] of Object.entries(l))
|
||||||
p === this.options.view_mode && (s = a);
|
d === this.options.view_mode && (s = a);
|
||||||
const [i, r] = this.options.view_mode_padding[s].map(h.parse_duration);
|
const [i, r] = this.options.view_mode_padding[s].map(h.parse_duration);
|
||||||
t = h.add(
|
t = h.add(
|
||||||
t,
|
t,
|
||||||
@ -838,8 +837,8 @@ class F {
|
|||||||
const o = document.createElement("option");
|
const o = document.createElement("option");
|
||||||
o.selected = !0, o.disabled = !0, o.textContent = "Mode", r.appendChild(o);
|
o.selected = !0, o.disabled = !0, o.textContent = "Mode", r.appendChild(o);
|
||||||
for (const a in l) {
|
for (const a in l) {
|
||||||
const p = document.createElement("option");
|
const d = document.createElement("option");
|
||||||
p.value = l[a], p.textContent = l[a], r.appendChild(p);
|
d.value = l[a], d.textContent = l[a], r.appendChild(d);
|
||||||
}
|
}
|
||||||
r.addEventListener(
|
r.addEventListener(
|
||||||
"change",
|
"change",
|
||||||
@ -868,7 +867,7 @@ class F {
|
|||||||
}), r = this.options.header_height + this.options.padding / 2;
|
}), r = this.options.header_height + this.options.padding / 2;
|
||||||
const o = this.dates.length * this.options.column_width, a = this.options.bar_height + this.options.padding;
|
const o = this.dates.length * this.options.column_width, a = this.options.bar_height + this.options.padding;
|
||||||
if (this.options.lines !== "vertical")
|
if (this.options.lines !== "vertical")
|
||||||
for (let p of this.tasks)
|
for (let d of this.tasks)
|
||||||
c("line", {
|
c("line", {
|
||||||
x1: 0,
|
x1: 0,
|
||||||
y1: r + a,
|
y1: r + a,
|
||||||
@ -878,13 +877,13 @@ class F {
|
|||||||
append_to: i
|
append_to: i
|
||||||
}), r += a;
|
}), r += a;
|
||||||
if (this.options.lines !== "horizontal")
|
if (this.options.lines !== "horizontal")
|
||||||
for (let p of this.dates) {
|
for (let d of this.dates) {
|
||||||
let d = "tick";
|
let p = "tick";
|
||||||
this.view_is(l.DAY) && p.getDate() === 1 && (d += " thick"), this.view_is(l.WEEK) && p.getDate() >= 1 && p.getDate() < 8 && (d += " thick"), this.view_is(l.MONTH) && p.getMonth() % 3 === 0 && (d += " thick"), c("path", {
|
this.view_is(l.DAY) && d.getDate() === 1 && (p += " thick"), this.view_is(l.WEEK) && d.getDate() >= 1 && d.getDate() < 8 && (p += " thick"), this.view_is(l.MONTH) && d.getMonth() % 3 === 0 && (p += " thick"), c("path", {
|
||||||
d: `M ${t} ${e} v ${s}`,
|
d: `M ${t} ${e} v ${s}`,
|
||||||
class: d,
|
class: p,
|
||||||
append_to: this.layers.grid
|
append_to: this.layers.grid
|
||||||
}), this.view_is(l.MONTH) ? t += h.get_days_in_month(p) * this.options.column_width / 30 : t += this.options.column_width;
|
}), this.view_is(l.MONTH) ? t += h.get_days_in_month(d) * this.options.column_width / 30 : t += this.options.column_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
highlightWeekends() {
|
highlightWeekends() {
|
||||||
@ -946,12 +945,12 @@ class F {
|
|||||||
let r = document.getElementById(
|
let r = document.getElementById(
|
||||||
h.format(e).replaceAll(" ", "_")
|
h.format(e).replaceAll(" ", "_")
|
||||||
);
|
);
|
||||||
r.classList.add("current-date-highlight"), r.style.top = +r.style.top.slice(0, -2) - 4 + "px", r.style.left = +r.style.left.slice(0, -2) - 8 + "px";
|
r && (r.classList.add("current-date-highlight"), r.style.top = +r.style.top.slice(0, -2) - 4 + "px", r.style.left = +r.style.left.slice(0, -2) - 8 + "px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_el({ left: t, top: e, width: s, height: i, id: r, classes: o, append_to: a }) {
|
create_el({ left: t, top: e, width: s, height: i, id: r, classes: o, append_to: a }) {
|
||||||
let p = document.createElement("div");
|
let d = document.createElement("div");
|
||||||
return p.classList.add(o), p.style.top = e + "px", p.style.left = t + "px", r && (p.id = r), s && (p.style.width = i + "px"), i && (p.style.height = i + "px"), a.appendChild(p), p;
|
return d.classList.add(o), d.style.top = e + "px", d.style.left = t + "px", r && (d.id = r), s && (d.style.width = i + "px"), i && (d.style.height = i + "px"), a.appendChild(d), d;
|
||||||
}
|
}
|
||||||
make_dates() {
|
make_dates() {
|
||||||
this.upper_texts_x = {}, this.get_dates_to_draw().forEach((t, e) => {
|
this.upper_texts_x = {}, this.get_dates_to_draw().forEach((t, e) => {
|
||||||
@ -1111,26 +1110,26 @@ class F {
|
|||||||
bind_bar_events() {
|
bind_bar_events() {
|
||||||
let t = !1, e = 0, s = 0, i = !1, r = !1, o = null, a = [];
|
let t = !1, e = 0, s = 0, i = !1, r = !1, o = null, a = [];
|
||||||
this.bar_being_dragged = null;
|
this.bar_being_dragged = null;
|
||||||
function p() {
|
function d() {
|
||||||
return t || i || r;
|
return t || i || r;
|
||||||
}
|
}
|
||||||
this.$svg.onclick = (d) => {
|
this.$svg.onclick = (p) => {
|
||||||
d.target.classList.contains("grid-row") && this.unselect_all();
|
p.target.classList.contains("grid-row") && this.unselect_all();
|
||||||
}, _.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (d, g) => {
|
}, _.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (p, g) => {
|
||||||
const u = _.closest(".bar-wrapper", g);
|
const u = _.closest(".bar-wrapper", g);
|
||||||
a.forEach((w) => w.group.classList.remove("active")), g.classList.contains("left") ? i = !0 : g.classList.contains("right") ? r = !0 : g.classList.contains("bar-wrapper") && (t = !0), u.classList.add("active"), this.popup && this.popup.parent.classList.add("hidden"), e = d.offsetX || d.layerX, d.offsetY || d.layerY, o = u.getAttribute("data-id"), a = [
|
a.forEach((w) => w.group.classList.remove("active")), g.classList.contains("left") ? i = !0 : g.classList.contains("right") ? r = !0 : g.classList.contains("bar-wrapper") && (t = !0), u.classList.add("active"), this.popup && this.popup.parent.classList.add("hidden"), e = p.offsetX || p.layerX, p.offsetY || p.layerY, o = u.getAttribute("data-id"), a = [
|
||||||
o,
|
o,
|
||||||
...this.get_all_dependent_tasks(o)
|
...this.get_all_dependent_tasks(o)
|
||||||
].map((w) => this.get_bar(w)), this.bar_being_dragged = o, a.forEach((w) => {
|
].map((w) => this.get_bar(w)), this.bar_being_dragged = o, a.forEach((w) => {
|
||||||
const b = w.$bar;
|
const b = w.$bar;
|
||||||
b.ox = b.getX(), b.oy = b.getY(), b.owidth = b.getWidth(), b.finaldx = 0;
|
b.ox = b.getX(), b.oy = b.getY(), b.owidth = b.getWidth(), b.finaldx = 0;
|
||||||
});
|
});
|
||||||
}), _.on(this.$container, "scroll", (d) => {
|
}), _.on(this.$container, "scroll", (p) => {
|
||||||
let g = document.querySelectorAll(".bar-wrapper"), u = [];
|
let g = document.querySelectorAll(".bar-wrapper"), u = [];
|
||||||
const f = [];
|
const f = [];
|
||||||
let w;
|
let w;
|
||||||
s && (w = d.currentTarget.scrollLeft - s);
|
s && (w = p.currentTarget.scrollLeft - s);
|
||||||
const b = d.currentTarget.scrollLeft / this.options.column_width * this.options.step / 24;
|
const b = p.currentTarget.scrollLeft / this.options.column_width * this.options.step / 24;
|
||||||
let y = "D MMM";
|
let y = "D MMM";
|
||||||
["Year", "Month"].includes(this.options.view_mode) ? y = "YYYY" : ["Day", "Week"].includes(this.options.view_mode) ? y = "MMMM" : this.view_is("Half Day") ? y = "D" : this.view_is("Hour") && (y = "D MMMM");
|
["Year", "Month"].includes(this.options.view_mode) ? y = "YYYY" : ["Day", "Week"].includes(this.options.view_mode) ? y = "MMMM" : this.view_is("Half Day") ? y = "D" : this.view_is("Hour") && (y = "D MMMM");
|
||||||
let S = h.format(
|
let S = h.format(
|
||||||
@ -1153,14 +1152,13 @@ class F {
|
|||||||
}), w && (u = f.map((m) => this.get_bar(m)), this.options.auto_move_label && u.forEach((m) => {
|
}), w && (u = f.map((m) => this.get_bar(m)), this.options.auto_move_label && u.forEach((m) => {
|
||||||
m.update_label_position_on_horizontal_scroll({
|
m.update_label_position_on_horizontal_scroll({
|
||||||
x: w,
|
x: w,
|
||||||
sx: d.currentTarget.scrollLeft
|
sx: p.currentTarget.scrollLeft
|
||||||
});
|
});
|
||||||
})), s = d.currentTarget.scrollLeft;
|
})), s = p.currentTarget.scrollLeft;
|
||||||
}), _.on(this.$svg, "mousemove", (d) => {
|
}), _.on(this.$svg, "mousemove", (p) => {
|
||||||
if (!p())
|
if (!d())
|
||||||
return;
|
return;
|
||||||
console.log(d);
|
const g = (p.offsetX || p.layerX) - e;
|
||||||
const g = (d.offsetX || d.layerX) - e;
|
|
||||||
a.forEach((u) => {
|
a.forEach((u) => {
|
||||||
const f = u.$bar;
|
const f = u.$bar;
|
||||||
f.finaldx = this.get_snap_position(g), this.hide_popup(), i ? o === u.task.id ? u.update_bar_position({
|
f.finaldx = this.get_snap_position(g), this.hide_popup(), i ? o === u.task.id ? u.update_bar_position({
|
||||||
@ -1172,9 +1170,9 @@ class F {
|
|||||||
width: f.owidth + f.finaldx
|
width: f.owidth + f.finaldx
|
||||||
}) : t && !this.options.readonly && !this.options.dates_readonly && u.update_bar_position({ x: f.ox + f.finaldx });
|
}) : t && !this.options.readonly && !this.options.dates_readonly && u.update_bar_position({ x: f.ox + f.finaldx });
|
||||||
});
|
});
|
||||||
}), document.addEventListener("mouseup", (d) => {
|
}), document.addEventListener("mouseup", (p) => {
|
||||||
t = !1, i = !1, r = !1;
|
t = !1, i = !1, r = !1;
|
||||||
}), _.on(this.$svg, "mouseup", (d) => {
|
}), _.on(this.$svg, "mouseup", (p) => {
|
||||||
this.bar_being_dragged = null, a.forEach((g) => {
|
this.bar_being_dragged = null, a.forEach((g) => {
|
||||||
g.$bar.finaldx && (g.date_changed(), g.set_action_completed());
|
g.$bar.finaldx && (g.date_changed(), g.set_action_completed());
|
||||||
});
|
});
|
||||||
@ -1184,15 +1182,15 @@ class F {
|
|||||||
let t = 0, e = null, s = null, i = null, r = null;
|
let t = 0, e = null, s = null, i = null, r = null;
|
||||||
_.on(this.$svg, "mousedown", ".handle.progress", (o, a) => {
|
_.on(this.$svg, "mousedown", ".handle.progress", (o, a) => {
|
||||||
e = !0, t = o.offsetX || o.layerX, o.offsetY || o.layerY;
|
e = !0, t = o.offsetX || o.layerX, o.offsetY || o.layerY;
|
||||||
const d = _.closest(".bar-wrapper", a).getAttribute("data-id");
|
const p = _.closest(".bar-wrapper", a).getAttribute("data-id");
|
||||||
s = this.get_bar(d), i = s.$bar_progress, r = s.$bar, i.finaldx = 0, i.owidth = i.getWidth(), i.min_dx = -i.getWidth(), i.max_dx = r.getWidth() - i.getWidth();
|
s = this.get_bar(p), i = s.$bar_progress, r = s.$bar, i.finaldx = 0, i.owidth = i.getWidth(), i.min_dx = -i.getWidth(), i.max_dx = r.getWidth() - i.getWidth();
|
||||||
}), _.on(this.$svg, "mousemove", (o) => {
|
}), _.on(this.$svg, "mousemove", (o) => {
|
||||||
if (!e)
|
if (!e)
|
||||||
return;
|
return;
|
||||||
let a = (o.offsetX || o.layerX) - t;
|
let a = (o.offsetX || o.layerX) - t;
|
||||||
a > i.max_dx && (a = i.max_dx), a < i.min_dx && (a = i.min_dx);
|
a > i.max_dx && (a = i.max_dx), a < i.min_dx && (a = i.min_dx);
|
||||||
const p = s.$handle_progress;
|
const d = s.$handle_progress;
|
||||||
_.attr(i, "width", i.owidth + a), _.attr(p, "cx", i.getEndX()), i.finaldx = a;
|
_.attr(i, "width", i.owidth + a), _.attr(d, "cx", i.getEndX()), i.finaldx = a;
|
||||||
}), _.on(this.$svg, "mouseup", () => {
|
}), _.on(this.$svg, "mouseup", () => {
|
||||||
e = !1, i && i.finaldx && (i.finaldx = 0, s.progress_changed(), s.set_action_completed(), s = null, i = null, r = null);
|
e = !1, i && i.finaldx && (i.finaldx = 0, s.progress_changed(), s.set_action_completed(), s = null, i = null, r = null);
|
||||||
});
|
});
|
||||||
|
|||||||
4
dist/frappe-gantt.umd.cjs
vendored
4
dist/frappe-gantt.umd.cjs
vendored
File diff suppressed because one or more lines are too long
@ -634,7 +634,6 @@ export default class Bar {
|
|||||||
.querySelector('.handle.right')
|
.querySelector('.handle.right')
|
||||||
.setAttribute('x', bar.getEndX() + 4);
|
.setAttribute('x', bar.getEndX() + 4);
|
||||||
const handle = this.group.querySelector('.handle.progress');
|
const handle = this.group.querySelector('.handle.progress');
|
||||||
console.log(handle, this.$bar_progress.getEndX())
|
|
||||||
handle &&
|
handle &&
|
||||||
handle.setAttribute('cx', this.$bar_progress.getEndX());
|
handle.setAttribute('cx', this.$bar_progress.getEndX());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,9 @@ const SHORTENED = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
parse_duration(duration) {
|
parse_duration(duration) {
|
||||||
const regex = /([0-9])+(y|m|d|h|min|s|ms)/gm;
|
const regex = /([0-9]+)(y|m|d|h|min|s|ms)/gm;
|
||||||
const matches = regex.exec(duration);
|
const matches = regex.exec(duration);
|
||||||
|
console.log(matches)
|
||||||
if (matches !== null) {
|
if (matches !== null) {
|
||||||
if (matches[2] === 'y') {
|
if (matches[2] === 'y') {
|
||||||
return { duration: parseInt(matches[1]), scale: `year` };
|
return { duration: parseInt(matches[1]), scale: `year` };
|
||||||
|
|||||||
11
src/index.js
11
src/index.js
@ -29,7 +29,6 @@ const VIEW_MODE_PADDING = {
|
|||||||
const DEFAULT_OPTIONS = {
|
const DEFAULT_OPTIONS = {
|
||||||
header_height: 65,
|
header_height: 65,
|
||||||
column_width: 30,
|
column_width: 30,
|
||||||
step: 24,
|
|
||||||
view_modes: [...Object.values(VIEW_MODE)],
|
view_modes: [...Object.values(VIEW_MODE)],
|
||||||
bar_height: 30,
|
bar_height: 30,
|
||||||
bar_corner_radius: 3,
|
bar_corner_radius: 3,
|
||||||
@ -676,10 +675,11 @@ export default class Gantt {
|
|||||||
let $today = document.getElementById(
|
let $today = document.getElementById(
|
||||||
date_utils.format(date).replaceAll(' ', '_'),
|
date_utils.format(date).replaceAll(' ', '_'),
|
||||||
);
|
);
|
||||||
|
if ($today) {
|
||||||
$today.classList.add('current-date-highlight');
|
$today.classList.add('current-date-highlight');
|
||||||
$today.style.top = +$today.style.top.slice(0, -2) - 4 + 'px';
|
$today.style.top = +$today.style.top.slice(0, -2) - 4 + 'px';
|
||||||
$today.style.left = +$today.style.left.slice(0, -2) - 8 + 'px';
|
$today.style.left = +$today.style.left.slice(0, -2) - 8 + 'px';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,7 +1064,6 @@ export default class Gantt {
|
|||||||
|
|
||||||
$.on(this.$svg, 'mousemove', (e) => {
|
$.on(this.$svg, 'mousemove', (e) => {
|
||||||
if (!action_in_progress()) return;
|
if (!action_in_progress()) return;
|
||||||
console.log(e);
|
|
||||||
const dx = (e.offsetX || e.layerX) - x_on_start;
|
const dx = (e.offsetX || e.layerX) - x_on_start;
|
||||||
|
|
||||||
bars.forEach((bar) => {
|
bars.forEach((bar) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user