chore: format

This commit is contained in:
Safwan Samsudeen 2024-11-28 14:33:17 +05:30
parent bc791491b1
commit de53f780b7
3 changed files with 15 additions and 10 deletions

View File

@ -504,10 +504,14 @@ export default class Bar {
and then add the days in the month, making sure the number does not exceed 29 and then add the days in the month, making sure the number does not exceed 29
so it is within the column */ so it is within the column */
if (this.gantt.view_is('Month')) { if (this.gantt.view_is('Month')) {
const diffDaysBasedOn30DayMonths = date_utils.diff(task_start, gantt_start, 'month') * 30; const diffDaysBasedOn30DayMonths =
const dayInMonth = Math.min(29, date_utils.format(task_start, "DD")); date_utils.diff(task_start, gantt_start, 'month') * 30;
const dayInMonth = Math.min(
29,
date_utils.format(task_start, 'DD'),
);
const diff = diffDaysBasedOn30DayMonths + dayInMonth; const diff = diffDaysBasedOn30DayMonths + dayInMonth;
x = (diff * column_width) / 30; x = (diff * column_width) / 30;
} }
this.x = x; this.x = x;

View File

@ -136,7 +136,7 @@ export default {
diff(date_a, date_b, scale = DAY) { diff(date_a, date_b, scale = DAY) {
let milliseconds, seconds, hours, minutes, days, months, years; let milliseconds, seconds, hours, minutes, days, months, years;
milliseconds = date_a - date_b; milliseconds = date_a - date_b;
seconds = milliseconds / 1000; seconds = milliseconds / 1000;
minutes = seconds / 60; minutes = seconds / 60;
@ -145,17 +145,17 @@ export default {
// Calculate months across years // Calculate months across years
const yearDiff = date_a.getFullYear() - date_b.getFullYear(); const yearDiff = date_a.getFullYear() - date_b.getFullYear();
const monthDiff = date_a.getMonth() - date_b.getMonth(); const monthDiff = date_a.getMonth() - date_b.getMonth();
/* If monthDiff is negative, date_b is in an earlier month than /* If monthDiff is negative, date_b is in an earlier month than
date_a and thus subtracted from the year difference in months */ date_a and thus subtracted from the year difference in months */
months = yearDiff * 12 + monthDiff; months = yearDiff * 12 + monthDiff;
/* If date_a's (e.g. march 1st) day of the month is smaller than date_b (e.g. february 28th), /* If date_a's (e.g. march 1st) day of the month is smaller than date_b (e.g. february 28th),
adjust the month difference */ adjust the month difference */
if (date_a.getDate() < date_b.getDate()) { if (date_a.getDate() < date_b.getDate()) {
months--; months--;
} }
// Calculate years based on actual months // Calculate years based on actual months
years = months / 12; years = months / 12;

View File

@ -680,7 +680,7 @@ export default class Gantt {
} }
} }
return { x } return { x };
} }
make_grid_highlights() { make_grid_highlights() {
@ -697,7 +697,8 @@ export default class Gantt {
const { x: left, date } = this.computeGridHighlightDimensions( const { x: left, date } = this.computeGridHighlightDimensions(
this.options.view_mode, this.options.view_mode,
); );
if (!date || !this.dates.find((d) => d.getTime() == date.getTime())) return; if (!date || !this.dates.find((d) => d.getTime() == date.getTime()))
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) *
@ -1297,7 +1298,7 @@ export default class Gantt {
trigger_event(event, args) { trigger_event(event, args) {
if (this.options['on_' + event]) { if (this.options['on_' + event]) {
this.options['on_' + event].apply(this, args) this.options['on_' + event].apply(this, args);
} }
} }