1
0
Fork 0

Sort by label

This commit is contained in:
lzieniew 2023-08-06 17:33:22 +00:00
parent 7e1cfebf6a
commit be9dbf9c46
1 changed files with 19 additions and 9 deletions

View File

@ -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