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