fix: wire up MongoDB table column sort buttons
The DataGrid emits @sort events when column headers are clicked, but MongoDocBrowser was not listening to them. Added an onSort handler that converts the column/direction into MongoDB sort JSON format.
This commit is contained in:
1 parent
f88367a872
commit
6ec8115984
1 file changed
+11
@@ -178,6 +178,16 @@ function applyFilter() {
|
||||
load();
|
||||
}
|
||||
|
||||
function onSort(column: string, _columnIndex: number, direction: "asc" | "desc" | null) {
|
||||
if (direction) {
|
||||
sortInput.value = JSON.stringify({ [column]: direction === "asc" ? 1 : -1 });
|
||||
} else {
|
||||
sortInput.value = "";
|
||||
}
|
||||
page.value = 0;
|
||||
load();
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): JsonRecord {
|
||||
if (value && typeof value === "object" && !Array.isArray(value)) {
|
||||
return value as JsonRecord;
|
||||
@@ -491,6 +501,7 @@ onMounted(load);
|
||||
context="results"
|
||||
editable
|
||||
:custom-save="gridSave"
|
||||
@sort="onSort"
|
||||
@reload="load"
|
||||
>
|
||||
<template #search-bar>
|
||||
|
||||
Reference in new issue
Block a user