Identify paginated table with html-id

This commit is contained in:
Gregor Kleen 2018-03-16 13:30:58 +01:00
parent 907958baf4
commit ba918129c9

View File

@ -13,6 +13,7 @@ import Import
import qualified Database.Esqueleto as E
import qualified Database.Esqueleto.Internal.Sql as E (SqlSelect)
import Text.Blaze (Attribute)
import qualified Text.Blaze.Html5.Attributes as Html5
import Control.Monad.RWS hiding ((<>), Foldable(..), mapM_)
@ -88,6 +89,9 @@ dbTable PSValidator{..} DBTable{ dbtIdent = (toPathPiece -> dbtIdent), .. } = do
wIdent n
| not $ null dbtIdent = dbtIdent <> "-" <> n
| otherwise = n
dbtAttrs'
| not $ null dbtIdent = Html5.id (fromString $ unpack dbtIdent) <> dbtAttrs
| otherwise = dbtAttrs
psResult <- runInputGetResult $ PaginationSettings
<$> ireq sortingField (wIdent "sorting")
@ -115,7 +119,7 @@ dbTable PSValidator{..} DBTable{ dbtIdent = (toPathPiece -> dbtIdent), .. } = do
rows <- runDB $ E.select sqlQuery'
bool return (sendResponse <=< tblLayout) psShortcircuit $ do
encodeCellTable dbtAttrs dbtColonnade rows
encodeCellTable dbtAttrs' dbtColonnade rows
where
tblLayout :: Widget -> Handler Html
tblLayout = widgetToPageContent >=> (\tbl -> withUrlRenderer $(hamletFile "templates/table-layout.hamlet"))