Fix javascript issues, 'directions' in sortable-header, sorted attrs
This commit is contained in:
parent
f99c8b3b86
commit
08607a5e7c
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
^{cellContents}
|
||||
$maybe flag <- sortableKey
|
||||
<br>
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-asc")}>asc
|
||||
/
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-desc")}>desc
|
||||
$case directions
|
||||
$of [SortAsc]
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-desc")}>desc
|
||||
$of [SortDesc]
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-asc")}>asc
|
||||
$of []
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-desc")}>desc
|
||||
/
|
||||
<a href=#{tblLink $ setParam (wIdent "sorting") (Just $ flag <> "-asc")}>asc
|
||||
$of _
|
||||
$nothing
|
||||
|
||||
Loading…
Reference in New Issue
Block a user