Merge pull request #475 from MercurialUroboros/fix/highlight-issues
fix: issues with highlight system and todayDate.
This commit is contained in:
commit
79b0e0d2ab
@ -305,7 +305,7 @@ export default class Bar {
|
|||||||
(timeout = setTimeout(() => {
|
(timeout = setTimeout(() => {
|
||||||
this.show_popup(e.offsetX || e.layerX);
|
this.show_popup(e.offsetX || e.layerX);
|
||||||
document.getElementById(
|
document.getElementById(
|
||||||
`${task_id}-highlight`,
|
`highlight-${task_id}`,
|
||||||
).style.display = 'block';
|
).style.display = 'block';
|
||||||
}, 200)),
|
}, 200)),
|
||||||
);
|
);
|
||||||
@ -313,7 +313,7 @@ export default class Bar {
|
|||||||
$.on(this.group, 'mouseleave', () => {
|
$.on(this.group, 'mouseleave', () => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
this.gantt.popup?.hide?.();
|
this.gantt.popup?.hide?.();
|
||||||
document.getElementById(`${task_id}-highlight`).style.display =
|
document.getElementById(`highlight-${task_id}`).style.display =
|
||||||
'none';
|
'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ const MINUTE = 'minute';
|
|||||||
const SECOND = 'second';
|
const SECOND = 'second';
|
||||||
const MILLISECOND = 'millisecond';
|
const MILLISECOND = 'millisecond';
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@ -84,7 +83,7 @@ export default {
|
|||||||
month: 'long',
|
month: 'long',
|
||||||
});
|
});
|
||||||
const dateTimeFormatShort = new Intl.DateTimeFormat(lang, {
|
const dateTimeFormatShort = new Intl.DateTimeFormat(lang, {
|
||||||
month: "short",
|
month: 'short',
|
||||||
});
|
});
|
||||||
const month_name = dateTimeFormat.format(date);
|
const month_name = dateTimeFormat.format(date);
|
||||||
const month_name_capitalized =
|
const month_name_capitalized =
|
||||||
|
|||||||
20
src/index.js
20
src/index.js
@ -689,13 +689,14 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the horizontal x-axis distance and associated date for the current date and view.
|
* Compute the horizontal x-axis distance and associated date for the current date and view.
|
||||||
*
|
*
|
||||||
* @returns Object containing the x-axis distance and date of the current date, or null if the current date is out of the gantt range.
|
* @returns Object containing the x-axis distance and date of the current date, or null if the current date is out of the gantt range.
|
||||||
*/
|
*/
|
||||||
computeGridHighlightDimensions(view_mode) {
|
computeGridHighlightDimensions(view_mode) {
|
||||||
const todayDate = new Date();
|
const todayDate = new Date();
|
||||||
if (todayDate < this.gantt_start || todayDate > this.gantt_end) return null;
|
if (todayDate < this.gantt_start || todayDate > this.gantt_end)
|
||||||
|
return null;
|
||||||
|
|
||||||
let x = this.options.column_width / 2;
|
let x = this.options.column_width / 2;
|
||||||
|
|
||||||
@ -703,10 +704,10 @@ export default class Gantt {
|
|||||||
return {
|
return {
|
||||||
x:
|
x:
|
||||||
x +
|
x +
|
||||||
(date_utils.diff(today, this.gantt_start, 'hour') /
|
(date_utils.diff(todayDate, this.gantt_start, 'hour') /
|
||||||
this.options.step) *
|
this.options.step) *
|
||||||
this.options.column_width,
|
this.options.column_width,
|
||||||
date: today,
|
date: todayDate,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,7 +747,9 @@ export default class Gantt {
|
|||||||
this.view_is(VIEW_MODE.YEAR)
|
this.view_is(VIEW_MODE.YEAR)
|
||||||
) {
|
) {
|
||||||
// Used as we must find the _end_ of session if view is not Day
|
// Used as we must find the _end_ of session if view is not Day
|
||||||
const highlightDimensions = this.computeGridHighlightDimensions(this.options.view_mode);
|
const highlightDimensions = this.computeGridHighlightDimensions(
|
||||||
|
this.options.view_mode,
|
||||||
|
);
|
||||||
if (!highlightDimensions) return;
|
if (!highlightDimensions) return;
|
||||||
const { x: left, date } = highlightDimensions;
|
const { x: left, date } = highlightDimensions;
|
||||||
if (!this.dates.find((d) => d.getTime() == date.getTime())) return;
|
if (!this.dates.find((d) => d.getTime() == date.getTime())) return;
|
||||||
@ -1147,7 +1150,6 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bar_wrapper.classList.add('active');
|
bar_wrapper.classList.add('active');
|
||||||
if (this.popup) this.popup.parent.classList.add('hidden');
|
|
||||||
|
|
||||||
if (this.popup) this.popup.parent.classList.add('hidden');
|
if (this.popup) this.popup.parent.classList.add('hidden');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user