Skip to content

Commit

Permalink
teams: smoother tasks deadlines (fixes #5377) (#7842)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
Gavinp14 and dogi authored Dec 27, 2024
1 parent a8297ef commit f0368b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.16.22",
"version": "0.16.23",
"myplanet": {
"latest": "v0.21.55",
"min": "v0.20.55"
Expand Down
3 changes: 2 additions & 1 deletion src/app/tasks/tasks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<button mat-list-item *ngFor="let task of filteredTasks; trackBy: trackById" (click)="openTaskDetail(task)" [disabled]="!editable">
<mat-checkbox [checked]="task.completed" [disabled]="!editable" (change)="toggleTaskComplete(task)" (click)="$event.stopPropagation()"></mat-checkbox>
<p matLine>{{task.title}}</p>
<p matLine><ng-container i18n>Deadline:</ng-container> {{task.deadline | date}} {{task.deadline | date: 'shortTime'}}</p>
<p matLine [ngClass]="{'deadline-soon': isTaskDueSoon(task),
'deadline-passed': isTaskOverdue(task)}"><ng-container i18n>Deadline:</ng-container> {{task.deadline | date}} {{task.deadline | date: 'shortTime'}}</p>
<p matLine *ngIf="task.completed"><ng-container i18n>Completed:</ng-container> {{task.completedTime | date}} {{task.completedTime | date: 'shortTime'}}</p>
<img (click)="openMemberDialog(task.assignee); $event.stopPropagation()" matTooltip="{{task.assignee | assigneeName}}" *ngIf="task.assignee" matListAvatar [src]="
task.assignee.attachmentDoc ?
Expand Down
20 changes: 20 additions & 0 deletions src/app/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ export class TasksComponent implements OnInit {
});
}

isTaskDueSoon(task): boolean {
if (!task || task.completed || !task.deadline) return false;

const now = new Date();
const deadline = new Date(task.deadline);
const twentyFourHoursFromNow = new Date(now.getTime() + 24 * 60 * 60 * 1000);

const isWithinNextDay = deadline <= twentyFourHoursFromNow && deadline > now;

return isWithinNextDay;
}

isTaskOverdue(task): boolean {
if (task.completed || !task.deadline) return false;

const now = new Date();
const deadline = new Date(task.deadline);
return deadline < now;
}

openAddDialog(additionalFields, task: any = {}, onSuccess = (res) => {}) {
const { fields, formGroup } = this.tasksService.addDialogForm(task);
this.dialogsFormService.openDialogsForm(task.title ? $localize`Edit Task` : $localize`Add Task`, fields, formGroup, {
Expand Down
8 changes: 8 additions & 0 deletions src/app/tasks/tasks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ planet-tasks {
}
}

.deadline-soon{
color: #F6BE00
}

.deadline-passed{
color: red
}

mat-button-toggle-group {
font-size: 14px;

Expand Down

0 comments on commit f0368b8

Please sign in to comment.