diff --git a/src/Handler/Utils/Table/Pagination.hs b/src/Handler/Utils/Table/Pagination.hs
index ef3ab45ec..776fd3498 100644
--- a/src/Handler/Utils/Table/Pagination.hs
+++ b/src/Handler/Utils/Table/Pagination.hs
@@ -153,10 +153,16 @@ dbTable PSValidator{..} DBTable{ dbtIdent = (toPathPiece -> dbtIdent), .. } = do
let table = $(widgetFile "table/colonnade")
pageCount = max 1 . ceiling $ rowCount % psLimit
tblLink f = decodeUtf8 . Builder.toLazyByteString . renderQueryText True $ f getParams
+
withSortLinks Sortable{ sortableContent = Cell{..}, .. } = Cell
{ cellContents = $(widgetFile "table/sortable-header")
- , ..
+ , cellAttrs = maybe mempty (const sortableAttr) sortableKey <> cellAttrs
}
+ where
+ directions = [dir | (k, dir) <- psSorting, Just k == sortableKey ]
+ sortableAttr = foldMap toAttr directions
+ toAttr SortAsc = Html5.class_ "sorted-asc"
+ toAttr SortDesc = Html5.class_ "sorted-desc"
$(widgetFile "table/layout")
where
tblLayout :: Widget -> Handler Html
diff --git a/templates/table/colonnade.julius b/templates/table/colonnade.julius
index fcea7dea9..212ecf4ff 100644
--- a/templates/table/colonnade.julius
+++ b/templates/table/colonnade.julius
@@ -23,8 +23,7 @@
event.preventDefault();
var url = new URL(window.location.origin + window.location.pathname + this.getAttribute('href'));
var order = this.parentNode.dataset.order || ASC;
- // TODO: make use of dbtIdent instead of -terms-
- url.searchParams.set('terms-table-only', 'true');
+ url.searchParams.set(#{String $ wIdent "table-only"}, 'yes');
updateTableFrom(url);
markSorted(this.parentNode, order);
}
diff --git a/templates/table/sortable-header.hamlet b/templates/table/sortable-header.hamlet
index 1054b1ce0..b5e006b6a 100644
--- a/templates/table/sortable-header.hamlet
+++ b/templates/table/sortable-header.hamlet
@@ -1,7 +1,14 @@
^{cellContents}
$maybe flag <- sortableKey
- "-asc")}>asc
- /
- "-desc")}>desc
+ $case directions
+ $of [SortAsc]
+ "-desc")}>desc
+ $of [SortDesc]
+ "-asc")}>asc
+ $of []
+ "-desc")}>desc
+ /
+ "-asc")}>asc
+ $of _
$nothing