forked from vikunja/frontend
Sort by label
This commit is contained in:
parent
7e1cfebf6a
commit
be9dbf9c46
@ -85,6 +85,7 @@
|
||||
</th>
|
||||
<th v-if="activeColumns.labels">
|
||||
{{ $t('task.attributes.labels') }}
|
||||
<Sort :order="sortBy.labels" @click="sort('labels')"/>
|
||||
</th>
|
||||
<th v-if="activeColumns.assignees">
|
||||
{{ $t('task.attributes.assignees') }}
|
||||
@ -250,15 +251,24 @@ Object.assign(params.value, {
|
||||
|
||||
// FIXME: by doing this we can have multiple sort orders
|
||||
function sort(property: keyof SortBy) {
|
||||
const order = sortBy.value[property]
|
||||
if (typeof order === 'undefined' || order === 'none') {
|
||||
sortBy.value[property] = 'desc'
|
||||
} else if (order === 'desc') {
|
||||
sortBy.value[property] = 'asc'
|
||||
} else {
|
||||
delete sortBy.value[property]
|
||||
}
|
||||
sortByParam.value = sortBy.value
|
||||
if (property === 'labels') {
|
||||
tasks.value.sort((a, b) => {
|
||||
// Assuming labels is an array and we're sorting by the first label
|
||||
if (a.labels[0] < b.labels[0]) return -1;
|
||||
if (a.labels[0] > b.labels[0]) return 1;
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
const order = sortBy.value[property]
|
||||
if (typeof order === 'undefined' || order === 'none') {
|
||||
sortBy.value[property] = 'desc'
|
||||
} else if (order === 'desc') {
|
||||
sortBy.value[property] = 'asc'
|
||||
} else {
|
||||
delete sortBy.value[property]
|
||||
}
|
||||
sortByParam.value = sortBy.value
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: re-enable opening task detail in modal
|
||||
|
Loading…
x
Reference in New Issue
Block a user