mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-26 09:23:50 +00:00
fix: crash when sub task is added via "planned-for-tomorrow" button
This commit is contained in:
parent
2dce5b04cf
commit
bbb41c2ee1
3 changed files with 19 additions and 4 deletions
|
|
@ -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.');
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue