From 2df2e68435db7b9b35c4b4347a1b07096ee068da Mon Sep 17 00:00:00 2001 From: owens-hub-git Date: Fri, 24 Apr 2026 21:41:49 +1000 Subject: [PATCH] fix: this is a fix to the slider component in the ontrack task dashboard --- src/app/api/models/task.ts | 16 ++++++++++++++++ .../task-date-slider.component.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/app/api/models/task.ts b/src/app/api/models/task.ts index 2d7d995792..d8a5d9b19d 100644 --- a/src/app/api/models/task.ts +++ b/src/app/api/models/task.ts @@ -236,6 +236,9 @@ export class Task extends Entity { return this.definition.localDueDate(); } + public get checklocalDueDate(): Date { + return this.localDueDate(); + } public localDueDateString(): string { const locale: string = AppInjector.get(LOCALE_ID); @@ -255,7 +258,20 @@ export class Task extends Entity { return Math.ceil(diffInDays / 7); } + public get taskPeriodProgress() { + const today = new Date(); + + //use Math.abs to avoid sign + if (today <= this.startDate) return 0; + if (today >= this.checklocalDueDate) return 50; + const startToNow = Math.abs(today.valueOf() - this.startDate.valueOf()); + const totalDuration = Math.abs(this.taskTotalDuration); + return Math.round((startToNow / totalDuration) * 50); + } + public get taskTotalDuration(): number { + return this.checklocalDueDate.valueOf() - this.startDate.valueOf(); + } /** * Set the task to be due in a specific week. * diff --git a/src/app/common/modals/date-change-modal/task-date-slider.component.ts b/src/app/common/modals/date-change-modal/task-date-slider.component.ts index 4da6b3a2f8..90f281ec32 100644 --- a/src/app/common/modals/date-change-modal/task-date-slider.component.ts +++ b/src/app/common/modals/date-change-modal/task-date-slider.component.ts @@ -32,7 +32,7 @@ export class TaskDateSliderComponent implements OnChanges { ) {} public get max(): number { - return this.task.unit.totalWeeks + Math.ceil(this.task.project.specConDays / 7); + return 50; } ngOnChanges(changes: SimpleChanges): void { @@ -41,7 +41,7 @@ export class TaskDateSliderComponent implements OnChanges { this.cancelEdit(); } - this.value = this.task.dueWeek; + this.value = this.task.taskPeriodProgress; this._originalDueDate = this.task.dueDate; this._originalExtension = this.task.extensions; }