From f1f1cd9a36dff1faa4cb4848f850be27445ae009 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 14 Dec 2018 21:52:42 +0100 Subject: [PATCH] Fix controls not responding after pagesize change --- src/Handler/Utils/Table/Pagination.hs | 15 +++++++-------- templates/table/layout.hamlet | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Handler/Utils/Table/Pagination.hs b/src/Handler/Utils/Table/Pagination.hs index 7836b9e88..eb5e60353 100644 --- a/src/Handler/Utils/Table/Pagination.hs +++ b/src/Handler/Utils/Table/Pagination.hs @@ -517,7 +517,7 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db , fieldEnctype = UrlEncoded } - piPrevious <- lift . runInputMaybe $ ireq (jsonField True) (wIdent "pagination") + piPrevious <- lift . runInputPostMaybe $ ireq (jsonField True) (wIdent "pagination") let piPreviousRes = maybe FormMissing FormSuccess piPrevious previousKeys <- throwExceptT . runMaybeT $ encodedSecretBoxOpen =<< MaybeT (lift . lookupPostParam $ wIdent "previous") @@ -601,6 +601,7 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db , foldr (.) id . map (\k -> setParams (wIdent $ toPathPiece k) . fromMaybe [] . join $ traverse (Map.lookup k) piFilter) $ Map.keys dbtFilter , setParam (wIdent "pagesize") $ fmap toPathPiece piLimit , setParam (wIdent "page") $ fmap toPathPiece piPage + , setParam (wIdent "pagination") Nothing ] if @@ -615,13 +616,11 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db | (E.Value n, _, _):_ <- rows' = n | otherwise = 0 - filterAction = tblLink - $ setParam (wIdent "page") Nothing - . Map.foldrWithKey (\k _ f -> setParam (wIdent $ toPathPiece k) Nothing . f) id dbtFilter - - pagesizeAction = tblLink - $ setParam (wIdent "page") Nothing + rawAction = tblLink + $ setParam (wIdent "sorting") Nothing . setParam (wIdent "pagesize") Nothing + . setParam (wIdent "page") Nothing + . setParam (wIdent "pagination") Nothing table' :: WriterT x m Widget table' = do @@ -656,7 +655,7 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db return $(widgetFile "table/layout") - bool (dbHandler (Proxy @m) (Proxy @x) $ (\table -> $(widgetFile "table/layout-wrapper")) . dbsLayoutFilter filterWdgt filterEnc filterAction) (sendResponse <=< tblLayout . dbsLayoutFilter filterWdgt filterEnc filterAction <=< dbWidget (Proxy @m) (Proxy @x)) psShortcircuit <=< runDBTable dbtable paginationInput currentKeys . fmap swap $ runWriterT table' + bool (dbHandler (Proxy @m) (Proxy @x) $ (\table -> $(widgetFile "table/layout-wrapper")) . dbsLayoutFilter filterWdgt filterEnc rawAction) (sendResponse <=< tblLayout . dbsLayoutFilter filterWdgt filterEnc rawAction <=< dbWidget (Proxy @m) (Proxy @x)) psShortcircuit <=< runDBTable dbtable paginationInput currentKeys . fmap swap $ runWriterT table' where tblLayout :: forall m'. (MonadHandler m', HandlerSite m' ~ UniWorX) => Widget -> m' Html tblLayout tbl' = do diff --git a/templates/table/layout.hamlet b/templates/table/layout.hamlet index 06f9e51aa..2d662b885 100644 --- a/templates/table/layout.hamlet +++ b/templates/table/layout.hamlet @@ -6,7 +6,7 @@ $else ^{table} $if pageCount > 1
-
+ ^{pagesizeWdgt}
    $forall p <- pageNumbers