fix: rename list to project for parsing subtasks via indention
This commit is contained in:
parent
03cef1f831
commit
fc8711d6d8
@ -113,8 +113,8 @@ task two`)
|
|||||||
sub task 2`)
|
sub task 2`)
|
||||||
|
|
||||||
expect(tasks).to.have.length(3)
|
expect(tasks).to.have.length(3)
|
||||||
expect(tasks[0].list).to.eq('list')
|
expect(tasks[0].project).to.eq('list')
|
||||||
expect(tasks[1].list).to.eq('list')
|
expect(tasks[1].project).to.eq('list')
|
||||||
expect(tasks[2].list).to.eq('list')
|
expect(tasks[2].project).to.eq('list')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,7 @@ import {getProjectFromPrefix} from '@/modules/parseTaskText'
|
|||||||
export interface TaskWithParent {
|
export interface TaskWithParent {
|
||||||
title: string,
|
title: string,
|
||||||
parent: string | null,
|
parent: string | null,
|
||||||
list: string | null,
|
project: string | null,
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupTitle(title: string) {
|
function cleanupTitle(title: string) {
|
||||||
@ -23,10 +23,10 @@ export function parseSubtasksViaIndention(taskTitles: string): TaskWithParent[]
|
|||||||
const task: TaskWithParent = {
|
const task: TaskWithParent = {
|
||||||
title: cleanupTitle(title),
|
title: cleanupTitle(title),
|
||||||
parent: null,
|
parent: null,
|
||||||
list: null,
|
project: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
task.list = getProjectFromPrefix(task.title)
|
task.project = getProjectFromPrefix(task.title)
|
||||||
|
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return task
|
return task
|
||||||
@ -47,9 +47,9 @@ export function parseSubtasksViaIndention(taskTitles: string): TaskWithParent[]
|
|||||||
} while (parentSpaces >= matchedSpaces)
|
} while (parentSpaces >= matchedSpaces)
|
||||||
task.title = cleanupTitle(title.replace(spaceRegex, ''))
|
task.title = cleanupTitle(title.replace(spaceRegex, ''))
|
||||||
task.parent = task.parent.replace(spaceRegex, '')
|
task.parent = task.parent.replace(spaceRegex, '')
|
||||||
if (task.list === null) {
|
if (task.project === null) {
|
||||||
// This allows to specify a list once for the parent task and inherit it to all subtasks
|
// This allows to specify a list once for the parent task and inherit it to all subtasks
|
||||||
task.list = getProjectFromPrefix(task.parent)
|
task.project = getProjectFromPrefix(task.parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user