Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/app/api/models/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export class Task extends Entity {

private _unit: Unit;

public maxForSlider: number = 50; //max for date slider component for each task

constructor(data?: Project | Unit) {
super();
if (data instanceof Project) {
Expand Down Expand Up @@ -298,6 +300,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);
Expand All @@ -317,7 +322,26 @@ export class Task extends Entity {

return Math.ceil(diffInDays / 7);
}
/*
Get percentage for task completion
*/
public get maxForDataSlider() {
return this.maxForSlider;
}
public get taskPeriodProgress() {
const today = new Date();

//use Math.abs to avoid sign
if (today <= this.startDate) return 0;
if (today >= this.checklocalDueDate) return this.maxForSlider;

const startToNow = Math.abs(today.valueOf() - this.startDate.valueOf());
const totalDuration = Math.abs(this.taskTotalDuration);
return Math.round((startToNow / totalDuration) * this.maxForSlider);
}
public get taskTotalDuration(): number {
return this.checklocalDueDate.valueOf() - this.startDate.valueOf();
}
/**
* Set the task to be due in a specific week.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class TaskDateSliderComponent implements OnChanges {
private confirmationModalService: ConfirmationModalService,
) {}

public get max(): number {
return this.task.unit.totalWeeks + Math.ceil(this.task.project.specConDays / 7);
public get max() {
return this.task.maxForDataSlider;
}

ngOnChanges(changes: SimpleChanges): void {
Expand All @@ -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;
}
Expand Down
Loading