1
0

fix(task): pass a list specified via quick add magic down to all subtasks created via indention

Resolves https://kolaente.dev/vikunja/frontend/issues/2771
This commit is contained in:
kolaente
2022-12-02 18:39:52 +01:00
parent 83fb8c3ded
commit b2da4fd126
5 changed files with 44 additions and 4 deletions

View File

@ -106,4 +106,15 @@ task two`)
expect(tasks).to.have.length(1)
expect(tasks[0].parent).toBeNull()
})
it('Should add the list of the parent task as list for all sub tasks', () => {
const tasks = parseSubtasksViaIndention(
`parent task +list
sub task 1
sub task 2`)
expect(tasks).to.have.length(3)
expect(tasks[0].list).to.eq('list')
expect(tasks[1].list).to.eq('list')
expect(tasks[2].list).to.eq('list')
})
})

View File

@ -1,6 +1,9 @@
import {getListFromPrefix} from '@/modules/parseTaskText'
export interface TaskWithParent {
title: string,
parent: string | null,
list: string | null,
}
function cleanupTitle(title: string) {
@ -20,8 +23,11 @@ export function parseSubtasksViaIndention(taskTitles: string): TaskWithParent[]
const task: TaskWithParent = {
title: cleanupTitle(title),
parent: null,
list: null,
}
task.list = getListFromPrefix(task.title)
if (index === 0) {
return task
}
@ -41,6 +47,10 @@ export function parseSubtasksViaIndention(taskTitles: string): TaskWithParent[]
} while (parentSpaces >= matchedSpaces)
task.title = cleanupTitle(title.replace(spaceRegex, ''))
task.parent = task.parent.replace(spaceRegex, '')
if (task.list === null) {
// This allows to specify a list once for the parent task and inherit it to all subtasks
task.list = getListFromPrefix(task.parent)
}
}
return task