fix(table view): do not sort table column fields when the field in question is hidden

Resolves https://kolaente.dev/vikunja/vikunja/issues/2272
This commit is contained in:
kolaente 2024-04-21 23:48:40 +02:00
parent 84197dd9c1
commit d86fdcb756
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 17 additions and 2 deletions

View File

@ -267,7 +267,7 @@
</template>
<script setup lang="ts">
import {computed, type Ref} from 'vue'
import {computed, type Ref, watch} from 'vue'
import {useStorage} from '@vueuse/core'
@ -337,6 +337,12 @@ Object.assign(params.value, {
filter: '',
})
watch(
() => activeColumns.value,
() => setActiveColumnsSortParam(),
{deep: true},
)
// FIXME: by doing this we can have multiple sort orders
function sort(property: keyof SortBy) {
const order = sortBy.value[property]
@ -347,7 +353,16 @@ function sort(property: keyof SortBy) {
} else {
delete sortBy.value[property]
}
sortByParam.value = sortBy.value
setActiveColumnsSortParam()
}
function setActiveColumnsSortParam() {
sortByParam.value = Object.keys(sortBy.value)
.filter(prop => activeColumns.value[prop])
.reduce((obj, key) => {
obj[key] = sortBy.value[key]
return obj
}, {})
}
// TODO: re-enable opening task detail in modal