From 3fa8f2ba82aeb549aa80744ce4df07fe30ecb4c5 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sat, 3 May 2025 13:48:22 +0200 Subject: [PATCH] feat(dueDate): make drag and drop work --- .../tasks/task-list/task-list.component.ts | 28 +++++++++++++++++-- src/app/features/tasks/task.model.ts | 7 ++++- .../work-view/work-view.component.html | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/app/features/tasks/task-list/task-list.component.ts b/src/app/features/tasks/task-list/task-list.component.ts index 4842393aa8..cdac09b42b 100644 --- a/src/app/features/tasks/task-list/task-list.component.ts +++ b/src/app/features/tasks/task-list/task-list.component.ts @@ -24,7 +24,7 @@ import { moveProjectTaskToBacklogList, moveProjectTaskToRegularList, } from '../../project/store/project.actions'; -import { moveSubTask } from '../store/task.actions'; +import { moveSubTask, updateTask } from '../store/task.actions'; import { WorkContextService } from '../../work-context/work-context.service'; import { Store } from '@ngrx/store'; import { moveItemBeforeItem } from '../../../util/move-item-before-item'; @@ -35,10 +35,11 @@ import { MatButton } from '@angular/material/button'; import { MatIcon } from '@angular/material/icon'; import { TaskComponent } from '../task/task.component'; import { AsyncPipe } from '@angular/common'; +import { planTaskForToday } from '../../tag/store/tag.actions'; export type TaskListId = 'PARENT' | 'SUB'; export type ListModelId = DropListModelSource | string; -const PARENT_ALLOWED_LISTS = ['DONE', 'UNDONE', 'BACKLOG', 'ADD_TASK_PANEL']; +const PARENT_ALLOWED_LISTS = ['DONE', 'UNDONE', 'OVERDUE', 'BACKLOG', 'ADD_TASK_PANEL']; export interface DropModelDataForList { listModelId: ListModelId; @@ -241,6 +242,29 @@ export class TaskListComponent implements OnDestroy, AfterViewInit { workContextType, }), ); + } else if (target === 'OVERDUE') { + return; + } else if (src === 'OVERDUE' && (target === 'UNDONE' || target === 'DONE')) { + const workContextType = this._workContextService + .activeWorkContextType as WorkContextType; + this._store.dispatch(planTaskForToday({ taskId })); + this._store.dispatch( + moveTaskInTodayList({ + taskId, + newOrderedIds, + src, + target, + workContextId, + workContextType, + }), + ); + if (target === 'DONE') { + this._store.dispatch( + updateTask({ + task: { id: taskId, changes: { isDone: true } }, + }), + ); + } } else if (src === 'BACKLOG' && target === 'BACKLOG') { // move inside backlog this._store.dispatch( diff --git a/src/app/features/tasks/task.model.ts b/src/app/features/tasks/task.model.ts index 580be3aabe..0d40ac05ea 100644 --- a/src/app/features/tasks/task.model.ts +++ b/src/app/features/tasks/task.model.ts @@ -16,7 +16,12 @@ export enum TaskDetailTargetPanel { DONT_OPEN_PANEL = 'DONT_OPEN_PANEL', } -export type DropListModelSource = 'UNDONE' | 'DONE' | 'BACKLOG' | 'ADD_TASK_PANEL'; +export type DropListModelSource = + | 'UNDONE' + | 'DONE' + | 'BACKLOG' + | 'ADD_TASK_PANEL' + | 'OVERDUE'; // NOTE: do not change these, as they are used inside task repeat model directly // (new can be added though) diff --git a/src/app/features/work-view/work-view.component.html b/src/app/features/work-view/work-view.component.html index c226dd7954..3e8fb6bdc1 100644 --- a/src/app/features/work-view/work-view.component.html +++ b/src/app/features/work-view/work-view.component.html @@ -31,7 +31,7 @@ class="tour-undoneList" [tasks]="overdueTasks()" listId="PARENT" - listModelId="UNDONE" + listModelId="OVERDUE" >