diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5402a84b..45b4a5a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Avoided (infinite) display of "The list is loading. Just a moment please." for queries that should show "The result list is empty.", in cases where the user does not have the right to read the involved source(s) (#209).
+- Result list sorting works again and the behavior is improved - see the issue for details (#216).
## [1.7.0] - 2025-04-09
diff --git a/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx b/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
index a660d038..3528a2b3 100644
--- a/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
+++ b/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
@@ -49,6 +49,7 @@ function QueryResultList(props) {
}
empty={false}
diff --git a/main/src/components/ListResultTable/QueryResultList/TableHeader/TableHeader.jsx b/main/src/components/ListResultTable/QueryResultList/TableHeader/TableHeader.jsx
index ad2ba020..6d164025 100644
--- a/main/src/components/ListResultTable/QueryResultList/TableHeader/TableHeader.jsx
+++ b/main/src/components/ListResultTable/QueryResultList/TableHeader/TableHeader.jsx
@@ -1,4 +1,4 @@
-import { Link, TableCell, TableHead, TableRow } from "@mui/material";
+import { Link, TableCell, TableHead, TableRow, Tooltip } from "@mui/material";
import React from "react";
import { useListContext } from "react-admin";
import "./TableHeader.css";
@@ -24,8 +24,8 @@ function TableHeader({ children }) {
* @param {string} target - the source of the column that was clicked
*/
function handleHeaderClick(target) {
- const newSort = { field: target, order: "DESC" };
- if (sort) {
+ const newSort = { field: target, order: "ASC" };
+ if (sort && sort.field == target) {
if (sort.order === "ASC") {
newSort.order = "DESC";
} else {
@@ -37,7 +37,8 @@ function TableHeader({ children }) {
const query = configManager.getQueryWorkingCopyById(resource);
const variableOntology = query.variableOntology;
-
+ const sortingAllowed = query.queryText.startsWith("# Custom sorting is allowed.");
+
return (
@@ -45,15 +46,19 @@ function TableHeader({ children }) {
<>
*": { verticalAlign: "middle" } }}
+ sx={{ height: "100%", "font-weight": "bold", "& > *": { verticalAlign: "middle" } }}
>
- handleHeaderClick(child.props.source)}
>
{child.props.label}
-
+ :
+
+ {child.props.label}
+
+ }
{!!variableOntology && variableOntology[child.props.source] && (
{
+ it("Should respond to sorting", () => {
+ cy.visit("/");
+ cy.contains("Example queries").click();
+ cy.contains("A query about musicians").click();
+ cy.contains("Finished in:");
+ cy.get(':nth-child(1) > .column-name > span').contains("Antonio Caldara").should("not.exist");
+ cy.contains("name").click();
+ cy.get(':nth-child(1) > .column-name > span').contains("Antonio Caldara");
+ cy.contains("name").click();
+ cy.get(':nth-child(1) > .column-name > span').contains("Wolfgang Amadeus Mozart");
+ });
+
+ it("Should show that sorting is disabled on queries with an ORDER clause", () => {
+ cy.visit("/");
+ cy.contains("Project related examples").click();
+ cy.contains("Components").click();
+ cy.contains("Finished in:");
+ cy.contains(/^component$/).click();
+ cy.contains("Custom sorting is disabled for queries containing an ORDER clause.").should('exist');
+ });
+});