commit
8f03ba0572
@ -154,7 +154,7 @@ export default class Bar {
|
|||||||
this.gantt.options.column_width;
|
this.gantt.options.column_width;
|
||||||
|
|
||||||
let $date_highlight = document.createElement('div');
|
let $date_highlight = document.createElement('div');
|
||||||
$date_highlight.id = `${this.task.id}-highlight`;
|
$date_highlight.id = `highlight-${this.task.id}`;
|
||||||
$date_highlight.classList.add('date-highlight');
|
$date_highlight.classList.add('date-highlight');
|
||||||
$date_highlight.style.height = this.height * 0.8 + 'px';
|
$date_highlight.style.height = this.height * 0.8 + 'px';
|
||||||
$date_highlight.style.width = this.width + 'px';
|
$date_highlight.style.width = this.width + 'px';
|
||||||
@ -289,7 +289,7 @@ export default class Bar {
|
|||||||
if (!opened) {
|
if (!opened) {
|
||||||
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';
|
||||||
} else {
|
} else {
|
||||||
this.gantt.hide_popup();
|
this.gantt.hide_popup();
|
||||||
|
|||||||
@ -6,20 +6,6 @@ const MINUTE = 'minute';
|
|||||||
const SECOND = 'second';
|
const SECOND = 'second';
|
||||||
const MILLISECOND = 'millisecond';
|
const MILLISECOND = 'millisecond';
|
||||||
|
|
||||||
const SHORTENED = {
|
|
||||||
January: 'Jan',
|
|
||||||
February: 'Feb',
|
|
||||||
March: 'Mar',
|
|
||||||
April: 'Apr',
|
|
||||||
May: 'May',
|
|
||||||
June: 'Jun',
|
|
||||||
July: 'Jul',
|
|
||||||
August: 'Aug',
|
|
||||||
September: 'Sep',
|
|
||||||
October: 'Oct',
|
|
||||||
November: 'Nov',
|
|
||||||
December: 'Dec',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
parse_duration(duration) {
|
parse_duration(duration) {
|
||||||
@ -97,6 +83,9 @@ export default {
|
|||||||
const dateTimeFormat = new Intl.DateTimeFormat(lang, {
|
const dateTimeFormat = new Intl.DateTimeFormat(lang, {
|
||||||
month: 'long',
|
month: 'long',
|
||||||
});
|
});
|
||||||
|
const dateTimeFormatShort = new Intl.DateTimeFormat(lang, {
|
||||||
|
month: "short",
|
||||||
|
});
|
||||||
const month_name = dateTimeFormat.format(date);
|
const month_name = dateTimeFormat.format(date);
|
||||||
const month_name_capitalized =
|
const month_name_capitalized =
|
||||||
month_name.charAt(0).toUpperCase() + month_name.slice(1);
|
month_name.charAt(0).toUpperCase() + month_name.slice(1);
|
||||||
@ -112,7 +101,7 @@ export default {
|
|||||||
SSS: values[6],
|
SSS: values[6],
|
||||||
D: values[2],
|
D: values[2],
|
||||||
MMMM: month_name_capitalized,
|
MMMM: month_name_capitalized,
|
||||||
MMM: SHORTENED[month_name_capitalized],
|
MMM: dateTimeFormatShort.format(date),
|
||||||
};
|
};
|
||||||
|
|
||||||
let str = format_string;
|
let str = format_string;
|
||||||
|
|||||||
21
src/index.js
21
src/index.js
@ -688,12 +688,18 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//compute the horizontal x distance
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
computeGridHighlightDimensions(view_mode) {
|
computeGridHighlightDimensions(view_mode) {
|
||||||
|
const todayDate = new Date();
|
||||||
|
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;
|
||||||
|
|
||||||
if (this.view_is(VIEW_MODE.DAY)) {
|
if (this.view_is(VIEW_MODE.DAY)) {
|
||||||
let today = date_utils.today();
|
|
||||||
return {
|
return {
|
||||||
x:
|
x:
|
||||||
x +
|
x +
|
||||||
@ -740,11 +746,10 @@ 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 { x: left, date } = this.computeGridHighlightDimensions(
|
const highlightDimensions = this.computeGridHighlightDimensions(this.options.view_mode);
|
||||||
this.options.view_mode,
|
if (!highlightDimensions) return;
|
||||||
);
|
const { x: left, date } = highlightDimensions;
|
||||||
if (!date || !this.dates.find((d) => d.getTime() == date.getTime()))
|
if (!this.dates.find((d) => d.getTime() == date.getTime())) return;
|
||||||
return;
|
|
||||||
const top = this.options.header_height + this.options.padding / 2;
|
const top = this.options.header_height + this.options.padding / 2;
|
||||||
const height =
|
const height =
|
||||||
(this.options.bar_height + this.options.padding) *
|
(this.options.bar_height + this.options.padding) *
|
||||||
@ -1006,7 +1011,7 @@ export default class Gantt {
|
|||||||
formatted_date: date_utils.format(date).replaceAll(' ', '_'),
|
formatted_date: date_utils.format(date).replaceAll(' ', '_'),
|
||||||
column_width,
|
column_width,
|
||||||
base_pos_x: base_pos.x,
|
base_pos_x: base_pos.x,
|
||||||
upper_text: this.options.lower_text
|
upper_text: this.options.upper_text
|
||||||
? this.options.upper_text(
|
? this.options.upper_text(
|
||||||
date,
|
date,
|
||||||
this.options.view_mode,
|
this.options.view_mode,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user