mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: removed software-side sorting logic, fixes #904
This commit is contained in:
@@ -284,7 +284,7 @@ const settingsStore = useSettingsStore();
|
|||||||
const consoleStore = useConsoleStore();
|
const consoleStore = useConsoleStore();
|
||||||
const { getWorkspace } = useWorkspacesStore();
|
const { getWorkspace } = useWorkspacesStore();
|
||||||
|
|
||||||
const { dataTabLimit: pageSize, defaultCopyType } = storeToRefs(settingsStore);
|
const { /* dataTabLimit: pageSize, */ defaultCopyType } = storeToRefs(settingsStore);
|
||||||
|
|
||||||
const { consoleHeight } = storeToRefs(consoleStore);
|
const { consoleHeight } = storeToRefs(consoleStore);
|
||||||
|
|
||||||
@@ -357,36 +357,36 @@ const isSortable = computed(() => {
|
|||||||
return fields.value.every(field => field.name);
|
return fields.value.every(field => field.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
const isHardSort = computed(() => {
|
// const isHardSort = computed(() => {
|
||||||
return props.mode === 'table' && localResults.value.length === pageSize.value;
|
// return props.mode === 'table' && localResults.value.length === pageSize.value;
|
||||||
});
|
// });
|
||||||
|
|
||||||
const sortedResults = computed(() => {
|
const sortedResults = computed(() => {
|
||||||
if (currentSort.value[resultsetIndex.value] && !isHardSort.value) {
|
// if (currentSort.value[resultsetIndex.value] && !isHardSort.value) {
|
||||||
const sortObj = currentSort.value[resultsetIndex.value];
|
// const sortObj = currentSort.value[resultsetIndex.value];
|
||||||
|
|
||||||
return [...localResults.value].sort((a: any, b: any) => {
|
// return [...localResults.value].sort((a: any, b: any) => {
|
||||||
const modifier = sortObj.dir === 'desc' ? -1 : 1;
|
// const modifier = sortObj.dir === 'desc' ? -1 : 1;
|
||||||
let valA = a[sortObj.field];
|
// let valA = a[sortObj.field];
|
||||||
let valB = b[sortObj.field];
|
// let valB = b[sortObj.field];
|
||||||
|
|
||||||
// Handle null values
|
// // Handle null values
|
||||||
if (valA === null && valB !== null) return sortObj.dir === 'asc' ? -1 : 1;
|
// if (valA === null && valB !== null) return sortObj.dir === 'asc' ? -1 : 1;
|
||||||
if (valA !== null && valB === null) return sortObj.dir === 'asc' ? 1 : -1;
|
// if (valA !== null && valB === null) return sortObj.dir === 'asc' ? 1 : -1;
|
||||||
if (valA === null && valB === null) return 0;
|
// if (valA === null && valB === null) return 0;
|
||||||
|
|
||||||
valA = typeof valA === 'string' ? valA.toLowerCase() : valA;
|
// valA = typeof valA === 'string' ? valA.toLowerCase() : valA;
|
||||||
valB = typeof valB === 'string' ? valB.toLowerCase() : valB;
|
// valB = typeof valB === 'string' ? valB.toLowerCase() : valB;
|
||||||
|
|
||||||
if (typeof valA !== 'number' && !isNaN(valA)) valA = String(Number(valA));
|
// if (typeof valA !== 'number' && !isNaN(valA)) valA = String(Number(valA));
|
||||||
if (typeof valB !== 'number' && !isNaN(valB)) valB = String(Number(valB));
|
// if (typeof valB !== 'number' && !isNaN(valB)) valB = String(Number(valB));
|
||||||
|
|
||||||
if (valA < valB) return -1 * modifier;
|
// if (valA < valB) return -1 * modifier;
|
||||||
if (valA > valB) return 1 * modifier;
|
// if (valA > valB) return 1 * modifier;
|
||||||
return 0;
|
// return 0;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
return localResults.value;
|
return localResults.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -827,12 +827,12 @@ const sort = (field: TableField) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHardSort.value) {
|
// if (isHardSort.value) {
|
||||||
emit('hard-sort', {
|
emit('hard-sort', {
|
||||||
field: currentSort.value[resultsetIndex.value].field,
|
field: currentSort.value[resultsetIndex.value].field,
|
||||||
dir: currentSort.value[resultsetIndex.value].dir
|
dir: currentSort.value[resultsetIndex.value].dir
|
||||||
});
|
});
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetSort = () => {
|
const resetSort = () => {
|
||||||
|
Reference in New Issue
Block a user