diff --git a/src/app/features/tasks/task.service.ts b/src/app/features/tasks/task.service.ts index 37b979c4f9..151aa3c706 100644 --- a/src/app/features/tasks/task.service.ts +++ b/src/app/features/tasks/task.service.ts @@ -289,6 +289,13 @@ export class TaskService { ); } + addTodayTag(t: Task) { + if (t.parentId) { + throw new Error('Sub task cannot be added a today tag'); + } + this.updateTags(t, [TODAY_TAG.id, ...t.tagIds], t.tagIds); + } + updateTags(task: Task, newTagIds: string[], oldTagIds: string[]) { if (task.parentId) { throw new Error('Editing sub task tags should not be possible.'); diff --git a/src/app/features/tasks/task/task.component.ts b/src/app/features/tasks/task/task.component.ts index 612eed8eb5..26fe6e81fb 100644 --- a/src/app/features/tasks/task/task.component.ts +++ b/src/app/features/tasks/task/task.component.ts @@ -400,7 +400,7 @@ export class TaskComponent implements OnInit, OnDestroy, AfterViewInit { } addToMyDay() { - this.onTagsUpdated([TODAY_TAG.id, ...this.task.tagIds]); + this._taskService.addTodayTag(this.task); } removeFromMyDay() { diff --git a/src/app/features/work-view/work-view.component.ts b/src/app/features/work-view/work-view.component.ts index 1ad010c9de..88232969a3 100644 --- a/src/app/features/work-view/work-view.component.ts +++ b/src/app/features/work-view/work-view.component.ts @@ -31,7 +31,6 @@ import { T } from '../../t.const'; import { ImprovementService } from '../metric/improvement/improvement.service'; import { workViewProjectChangeAnimation } from '../../ui/animations/work-view-project-change.ani'; import { WorkContextService } from '../work-context/work-context.service'; -import { TODAY_TAG } from '../tag/tag.const'; const SUB = 'SUB'; const PARENT = 'PARENT'; @@ -163,8 +162,17 @@ export class WorkViewComponent implements OnInit, OnDestroy, AfterContentInit { addAllPlannedToToday(plannedTasks: TaskPlanned[]) { plannedTasks.forEach((t) => { - this.taskService.moveToProjectTodayList(t.id); - this.taskService.updateTags(t, [...t.tagIds, TODAY_TAG.id], t.tagIds); + if (t.parentId) { + this.taskService.moveToProjectTodayList(t.parentId); + this._subs.add( + this.taskService.getByIdOnce$(t.parentId).subscribe((parentTask) => { + this.taskService.addTodayTag(parentTask); + }), + ); + } else { + this.taskService.moveToProjectTodayList(t.id); + this.taskService.addTodayTag(t); + } }); }