From 0074a092a59a91406c4be60295d554a8c8a27d19 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Wed, 11 Sep 2024 20:34:28 +0530 Subject: [PATCH 1/4] fix: bump node version --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 53814288..ce102aeb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: - node-version: 14 + node-version: 16 - run: yarn install - run: yarn prettier-check - run: yarn test From f8d77b2a7316fa7fe03ef5e2eb6e7fb8af268847 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Wed, 11 Sep 2024 20:40:08 +0530 Subject: [PATCH 2/4] fix: today highlight bug --- src/date_utils.js | 1 - src/index.js | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/date_utils.js b/src/date_utils.js index 716d2ae3..4d2e4f0a 100644 --- a/src/date_utils.js +++ b/src/date_utils.js @@ -25,7 +25,6 @@ export default { parse_duration(duration) { const regex = /([0-9]+)(y|m|d|h|min|s|ms)/gm; const matches = regex.exec(duration); - console.log(matches); if (matches !== null) { if (matches[2] === 'y') { return { duration: parseInt(matches[1]), scale: `year` }; diff --git a/src/index.js b/src/index.js index f8ff9f01..a94e8cc4 100644 --- a/src/index.js +++ b/src/index.js @@ -516,7 +516,6 @@ export default class Gantt { const { left, y } = this.$header.getBoundingClientRect(); // Check if the button is scrolled out of the container vertically - console.log('heyy'); if ( buttonRect.top < containerRect.top || buttonRect.bottom > containerRect.bottom @@ -640,12 +639,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) { + const todayDate = new Date(); + if (todayDate < this.gantt_start || todayDate > this.gantt_end) return null; + let x = this.options.column_width / 2; if (this.view_is(VIEW_MODE.DAY)) { - let today = date_utils.today(); return { x: x + @@ -689,9 +694,9 @@ export default class Gantt { this.view_is(VIEW_MODE.YEAR) ) { // Used as we must find the _end_ of session if view is not Day - const { x: left, date } = this.computeGridHighlightDimensions( - this.options.view_mode, - ); + const highlightDimensions = this.computeGridHighlightDimensions(this.options.view_mode); + if (!highlightDimensions) return; + const { x: left, date } = highlightDimensions; if (!this.dates.find((d) => d.getTime() == date.getTime())) return; const top = this.options.header_height + this.options.padding / 2; const height = From faf41b7220d28f828ef6ae7de3187a345679845e Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Wed, 11 Sep 2024 20:49:06 +0530 Subject: [PATCH 3/4] fix: use css ids that don't start with number --- src/bar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bar.js b/src/bar.js index afa469b6..dbbf023f 100644 --- a/src/bar.js +++ b/src/bar.js @@ -154,7 +154,7 @@ export default class Bar { this.gantt.options.column_width; 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.style.height = this.height * 0.8 + 'px'; $date_highlight.style.width = this.width + 'px'; @@ -290,7 +290,7 @@ export default class Bar { (timeout = setTimeout(() => { this.show_popup(e.offsetX || e.layerX); document.getElementById( - `${task_id}-highlight`, + `highlight-${task_id}`, ).style.display = 'block'; }, 200)), ); @@ -298,7 +298,7 @@ export default class Bar { $.on(this.group, 'mouseleave', () => { clearTimeout(timeout); this.gantt.popup?.hide?.(); - document.getElementById(`${task_id}-highlight`).style.display = + document.getElementById(`highlight-${task_id}`).style.display = 'none'; }); From af206ebbd7dae8bb59741b3ced7ac125a8fd91ff Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Wed, 11 Sep 2024 20:51:53 +0530 Subject: [PATCH 4/4] fix: changes from #397 --- src/date_utils.js | 19 ++++--------------- src/index.js | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/date_utils.js b/src/date_utils.js index 4d2e4f0a..4698088e 100644 --- a/src/date_utils.js +++ b/src/date_utils.js @@ -6,20 +6,6 @@ const MINUTE = 'minute'; const SECOND = 'second'; 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 { parse_duration(duration) { @@ -97,6 +83,9 @@ export default { const dateTimeFormat = new Intl.DateTimeFormat(lang, { month: 'long', }); + const dateTimeFormatShort = new Intl.DateTimeFormat(lang, { + month: "short", + }); const month_name = dateTimeFormat.format(date); const month_name_capitalized = month_name.charAt(0).toUpperCase() + month_name.slice(1); @@ -112,7 +101,7 @@ export default { SSS: values[6], D: values[2], MMMM: month_name_capitalized, - MMM: SHORTENED[month_name_capitalized], + MMM: dateTimeFormatShort.format(date), }; let str = format_string; diff --git a/src/index.js b/src/index.js index a94e8cc4..94973fcd 100644 --- a/src/index.js +++ b/src/index.js @@ -867,7 +867,7 @@ export default class Gantt { formatted_date: date_utils.format(date).replaceAll(' ', '_'), column_width, base_pos_x: base_pos.x, - upper_text: this.options.lower_text + upper_text: this.options.upper_text ? this.options.upper_text( date, this.options.view_mode,