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:
@ -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')
|
||||
})
|
||||
})
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user