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