Fix sort order for table view

This commit is contained in:
kolaente 2021-09-08 18:13:02 +02:00
parent 6f89863c81
commit 9cee720ac9
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -286,10 +286,26 @@ export default {
}, },
methods: { methods: {
initTasks(page, search = '') { initTasks(page, search = '') {
// This makes sure an id sort order is always sorted last.
// When tasks would be sorted first by id and then by whatever else was specified, the id sort takes
// precedence over everything else, making any other sort columns pretty useless.
const sortKeys = Object.keys(this.sortBy)
let hasIdFilter = false
for (const s of sortKeys) {
if (s === 'id') {
sortKeys.splice(s, 1)
hasIdFilter = true
break
}
}
if (hasIdFilter) {
sortKeys.push('id')
}
const params = this.params const params = this.params
params.sort_by = [] params.sort_by = []
params.order_by = [] params.order_by = []
Object.keys(this.sortBy).map(s => { sortKeys.map(s => {
params.sort_by.push(s) params.sort_by.push(s)
params.order_by.push(this.sortBy[s]) params.order_by.push(this.sortBy[s])
}) })