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