defaultPagesize
This commit is contained in:
parent
7a4f1cb76e
commit
8f33d1590c
@ -13,6 +13,7 @@ module Handler.Utils.Table.Pagination
|
||||
, PagesizeLimit(..)
|
||||
, PaginationSettings(..), PaginationInput(..), piIsUnset
|
||||
, PSValidator(..)
|
||||
, defaultPagesize
|
||||
, defaultFilter, defaultSorting
|
||||
, restrictFilter, restrictSorting
|
||||
, ToSortable(..), Sortable(..)
|
||||
@ -314,6 +315,13 @@ defaultSorting psSorting (runPSValidator -> f) = PSValidator $ \dbTable' -> inje
|
||||
Just _ -> id
|
||||
Nothing -> set (_2._psSorting) psSorting
|
||||
|
||||
defaultPagesize :: PagesizeLimit -> PSValidator m x -> PSValidator m x
|
||||
defaultPagesize psLimit (runPSValidator -> f) = PSValidator $ \dbTable' -> injectDefault <*> f dbTable'
|
||||
where
|
||||
injectDefault x = case x >>= piLimit of
|
||||
Just _ -> id
|
||||
Nothing -> set (_2._psLimit) psLimit
|
||||
|
||||
restrictFilter :: (FilterKey -> [Text] -> Bool) -> PSValidator m x -> PSValidator m x
|
||||
restrictFilter restrict (runPSValidator -> f) = PSValidator $ \dbTable' ps -> over _2 restrict' $ f dbTable' ps
|
||||
where
|
||||
|
||||
Loading…
Reference in New Issue
Block a user