fix: bug with current marking

This commit is contained in:
Safwan Samsudeen 2024-12-17 15:33:44 +05:30
parent fcd04922bd
commit 097d69ce90
2 changed files with 13 additions and 9 deletions

View File

@ -50,7 +50,7 @@ const DEFAULT_VIEW_MODES = [
},
{
name: 'Day',
padding: '1m',
padding: '14d',
format_string: 'YYYY-MM-DD',
step: '1d',
lower_text: (d, ld, lang) =>
@ -158,7 +158,9 @@ const DEFAULT_OPTIONS = {
);
});
ctx.add_action('-', (task, chart) => {
task.progress -= (1 / task.actual_duration) * 100;
task.progress -=
Math.floor((1 / task.actual_duration) * 10000) / 100;
console.log(task.progress);
chart.refresh(
chart.tasks.map((t) => (t.id !== task.id ? t : task)),
);

View File

@ -642,8 +642,10 @@ export default class Gantt {
* @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.
*/
highlightNow() {
const [_, el] = this.get_closest_date();
const res = this.get_closest_date();
if (!res) return;
const [_, el] = res;
el.classList.add('current-date-highlight');
const diff_in_units = date_utils.diff(
@ -751,6 +753,9 @@ export default class Gantt {
$upper_text.innerText = date.upper_text;
}
});
this.upperTexts = Array.from(
this.$container.querySelectorAll('.upper-text'),
);
}
get_dates_to_draw() {
@ -889,9 +894,6 @@ export default class Gantt {
this.$current.classList.remove('current-upper');
}
this.upperTexts = Array.from(
this.$container.querySelectorAll('.upper-text'),
);
this.current_date = date_utils.add(
this.gantt_start,
this.$container.scrollLeft / this.config.column_width,
@ -904,7 +906,7 @@ export default class Gantt {
);
// Recalculate
this.current_date = this.current_date = date_utils.add(
this.current_date = date_utils.add(
this.gantt_start,
(this.$container.scrollLeft + $el.clientWidth) /
this.config.column_width,
@ -917,8 +919,8 @@ export default class Gantt {
}
scroll_today() {
let [today, _] = this.get_closest_date();
this.set_scroll_position(today);
let res = this.get_closest_date();
if (res) this.set_scroll_position(res[0]);
}
get_closest_date() {