feat: automatically create subtask relations based on indention #2443

Merged
konrad merged 6 commits from feature/subtask-via-indention into main 2022-09-30 11:47:22 +00:00
1 changed files with 8 additions and 4 deletions
Showing only changes of commit 5f5ed410df - Show all commits

View File

@ -181,15 +181,19 @@ async function addTask() {
try {
newTaskTitle.value = ''
await Promise.all(newTasks)
const taskRelationService = new TaskRelationService()
const relations = tasksToCreate.map(async t => {
const createdTask = createdTasks.find(ct => ct.title === t.title)
if (typeof createdTask === 'undefined') {
konrad marked this conversation as resolved Outdated

In line 194 we return if typeof createdTask === 'undefined'.
This implies that createdTask could be undefined here aswell. Is that intended?

In line 194 we return if `typeof createdTask === 'undefined'`. This implies that createdTask could be undefined here aswell. Is that intended?

mhh I didn't think this through. It should never be null.

I've adjusted this so that there's a check before emitting it.

mhh I didn't think this through. It should never be null. I've adjusted this so that there's a check before emitting it.
return
}
if (t.parent === null) {
emit('taskAdded', createdTask)
return
}
const createdParentTask = createdTasks.find(ct => ct.title === t.parent)
if (typeof createdTask === 'undefined' || typeof createdParentTask === 'undefined') {
return
@ -200,11 +204,11 @@ async function addTask() {
otherTaskId: createdParentTask.id,
relationKind: RELATION_KIND.PARENTTASK,
}))
createdTask.relatedTasks[RELATION_KIND.PARENTTASK] = [createdParentTask]
// we're only emitting here so that the relation shows up in the task list
emit('taskAdded', createdTask)
return rel
})
await Promise.all(relations)