Compare commits

...

2 Commits

Author SHA1 Message Date
e32c2391a0 Sort lines based on the text and not the checkboxes
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-11 22:33:04 +02:00
bbbf82ff93 Fix bug for ordering checkboxes 2021-08-11 22:32:45 +02:00

View File

@ -56,12 +56,16 @@ function sort(id, property, direction) {
let children = this.getChildren(id)
if (property === 'todo') {
children = _.orderBy(children, item => {
let res = item.text.match(/^#\[\[(TODO|DONE)/)
const res = item.text.match(/^#\[\[(TODO|DONE)/)
if (!res) return "C";
if (res[1] === 'TODO') return direction === 'asc' ? "A" : "B";
if (res[1] === 'DONE') return direction === 'asc' ? "B" : "A";
if (res[1] === 'TODO') return "A";
if (res[1] === 'DONE') return "B";
return "D";
}, direction)
} else if (property === 'text') {
children = _.orderBy(children, item => {
return item.text.replace(/^#\[\[(TODO|DONE)]]\s*/, '')
}, direction)
} else {
children = _.orderBy(children, property, direction)
}