From 170442cff0c476d8e81df9a770c87801b0fce017 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 16 Mar 2018 14:22:33 +0100 Subject: [PATCH] Fix page indicator --- src/Handler/Utils/Table/Pagination.hs | 3 +++ templates/table-layout.hamlet | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Handler/Utils/Table/Pagination.hs b/src/Handler/Utils/Table/Pagination.hs index 76a988ddb..f00426e45 100644 --- a/src/Handler/Utils/Table/Pagination.hs +++ b/src/Handler/Utils/Table/Pagination.hs @@ -25,6 +25,8 @@ import Yesod.Colonnade import Text.Hamlet (hamletFile) +import Data.Ratio ((%)) + data SortColumn = forall a. PersistField a => SortColumn { getSortColumn :: E.SqlExpr (E.Value a) } data SortDirection = SortAsc | SortDesc @@ -121,6 +123,7 @@ dbTable PSValidator{..} DBTable{ dbtIdent = (toPathPiece -> dbtIdent), .. } = do bool return (sendResponse <=< tblLayout) psShortcircuit $ do let table = encodeCellTable dbtAttrs' dbtColonnade rows + pageCount = max 1 . ceiling $ rowCount % psLimit $(widgetFile "table-layout") where tblLayout :: Widget -> Handler Html diff --git a/templates/table-layout.hamlet b/templates/table-layout.hamlet index 323be24bb..d268dad12 100644 --- a/templates/table-layout.hamlet +++ b/templates/table-layout.hamlet @@ -1,4 +1,4 @@
^{table}

- _{MsgPage (succ psPage) (succ $ div rowCount psLimit)} + _{MsgPage (succ psPage) pageCount}