fix: couple ignoring bugs

This commit is contained in:
safwansamsudeen 2024-12-05 12:39:45 +05:30
parent 9caf2322b9
commit 6c8cc993c4
3 changed files with 25 additions and 11 deletions

View File

@ -587,9 +587,9 @@ export default class Bar {
if (
!this.gantt.config.ignored_dates.find(
(k) => k.getTime() === d.getTime(),
) &&
this.gantt.config.ignored_function &&
!this.gantt.config.ignored_function(d)
) ||
(this.gantt.config.ignored_function &&
!this.gantt.config.ignored_function(d))
) {
actual_duration_in_days++;
}

View File

@ -118,8 +118,17 @@ const DEFAULT_OPTIONS = {
today_button: true,
view_mode_select: false,
default_snap: '1d',
holiday_highlight: { green: 'weekend' },
ignore: ['weekend'],
holiday_highlight: {
green: [
'2024-03-01',
'2024-03-02',
'2024-03-03',
'2024-03-04',
'2024-03-05',
'2024-03-06',
],
},
ignore: [],
};
export { DEFAULT_OPTIONS, DEFAULT_VIEW_MODES };

View File

@ -559,7 +559,6 @@ export default class Gantt {
let check_highlight = this.options.holiday_highlight[color];
if (check_highlight === 'weekend')
check_highlight = (d) => d.getDay() === 0 || d.getDay() === 6;
let extra_func;
if (typeof check_highlight === 'object') {
@ -600,13 +599,17 @@ export default class Gantt {
const height =
(this.options.bar_height + this.options.padding) *
this.tasks.length;
createSVG('rect', {
x,
x: Math.round(x),
y:
this.options.header_height +
this.options.padding / 2,
width: this.config.column_width,
width:
this.config.column_width /
date_utils.convert_scales(
this.config.view_mode.step,
'day',
),
height,
style: `fill: ${color};`,
append_to: this.layers.grid,
@ -664,6 +667,7 @@ export default class Gantt {
M3,5 l2,-2"
style="stroke:black; stroke-width:0.5" />
</pattern>`;
for (
let d = new Date(this.gantt_start);
d <= this.gantt_end;
@ -673,10 +677,11 @@ export default class Gantt {
!this.config.ignored_dates.find(
(k) => k.getDate() == d.getDate(),
) &&
this.config.ignored_function &&
!this.config.ignored_function(d)
(!this.config.ignored_function ||
!this.config.ignored_function(d))
)
continue;
console.log(this.config.ignored_function);
let diff =
date_utils.convert_scales(
date_utils.diff(d, this.gantt_start) + 'd',