fix: sorting

This commit is contained in:
2025-03-16 10:56:47 +07:00
parent 21f0c44e41
commit 3f8b548cd0
22 changed files with 1717 additions and 8 deletions

View File

@@ -19,10 +19,11 @@ defineProps<{
<ul class="flex flex-col gap-2 native-border secondary-background p-3 rounded-md">
<li v-for="optionKey in optionsKeys" class="flex items-center justify-between w-full">
<h1>{{ scheme[optionKey].russian }}</h1>
<Select size="small" class="w-24" :options="['ASC', 'DESC']" v-model="options![optionKey]" @value-change="load">
<Select size="small" class="w-24" :options="['NONE', 'ASC', 'DESC']" v-model="options![optionKey]" @value-change="load">
<template #value="{ value }">
<span class="pi pi-sort-amount-up-alt" v-if="value == 'ASC'"></span>
<span class="pi pi-sort-amount-down" v-else></span>
<span class="pi pi-sort-amount-down" v-else-if="value == 'DESC'"></span>
<span v-else>-</span>
</template>
</Select>
</li>

View File

@@ -43,10 +43,14 @@ export default class TaskService implements IService<Task> {
async sort(options: SortOptions<Task>) {
return (await SortedByOrder(
Object.entries(options).map((item) => ({
Name: item[0],
Order: item[1],
})),
Object.entries(options).map((item) => {
if (item[1] !== 'NONE') {
return ({
Name: item[0],
Order: item[1],
})
}
}).filter(item => !!item)
)) as Task[];
}
}

View File

@@ -1 +1 @@
export type Sorting = "DESC" | "ASC"
export type Sorting = "DESC" | "ASC" | "NONE"

View File

@@ -8,7 +8,7 @@ export const getDefaultSortOptions = <T extends IEntity>(scheme: Scheme<T>): Sor
keys.forEach(key => {
if (!scheme[key].hidden && key !== 'entityId' && !scheme[key].many) {
result[key] = 'ASC'
result[key] = 'NONE'
}
})