diff --git a/client/src/components/Grid/GridList.vue b/client/src/components/Grid/GridList.vue
index f6ffa8b6881d..d2348e90457a 100644
--- a/client/src/components/Grid/GridList.vue
+++ b/client/src/components/Grid/GridList.vue
@@ -46,6 +46,9 @@ const totalRows = ref(0);
// loading indicator
const loading = ref(true);
+// search term
+const searchTerm = ref("");
+
// current grid configuration
const gridConfig = computed(() => {
return registry[props.id];
@@ -54,13 +57,27 @@ const gridConfig = computed(() => {
// check if loading has completed and data rows are available
const isAvailable = computed(() => !loading.value && totalRows.value > 0);
+// sort references
+const sortBy = ref(gridConfig.value ? gridConfig.value.sortBy : "");
+const sortDesc = ref(gridConfig.value ? gridConfig.value.sortDesc : false);
+
/**
* Request grid data
*/
async function getGridData() {
if (gridConfig.value) {
try {
- const response = await axios.get(withPrefix(gridConfig.value.getUrl(currentPage.value, props.perPage, "")));
+ const response = await axios.get(
+ withPrefix(
+ gridConfig.value.getUrl(
+ currentPage.value,
+ props.perPage,
+ sortBy.value,
+ sortDesc.value,
+ searchTerm.value
+ )
+ )
+ );
if (response.headers.total_matches) {
totalRows.value = parseInt(response.headers.total_matches);
}
@@ -77,7 +94,7 @@ async function getGridData() {
/**
* Execute grid operation and display message if available
*/
-async function executeOperation(operation: Operation, rowData: RowData) {
+async function onOperation(operation: Operation, rowData: RowData) {
const response = await operation.handler(rowData, router);
if (response) {
await getGridData();
@@ -86,6 +103,14 @@ async function executeOperation(operation: Operation, rowData: RowData) {
}
}
+function onSort(sortKey: string) {
+ if (sortBy.value !== sortKey) {
+ sortBy.value = sortKey;
+ } else {
+ sortDesc.value = !sortDesc.value;
+ }
+}
+
/**
* Process tag inputs
*/
@@ -106,7 +131,7 @@ onMounted(() => {
/**
* Load current page
*/
-watch(currentPage, () => getGridData());
+watch([currentPage, sortDesc, sortBy], () => getGridData());
/**
* Operation message timeout handler
@@ -131,8 +156,17 @@ watch(operationMessage, () => {
- {{ fieldEntry.title || fieldEntry.key }} + |
+
+ |
---|