module IHP.Pagination.Types where

import IHP.Prelude

data Pagination = 
    Pagination
    {
        Pagination -> Int
pageSize :: Int     -- the number of items per page
    ,   Pagination -> Int
totalItems :: Int   -- the total number of items in the result
    ,   Pagination -> Int
currentPage :: Int  -- the currently-selected page
    ,   Pagination -> Int
window :: Int       -- The size of the window
    }
    deriving(Int -> Pagination -> ShowS
[Pagination] -> ShowS
Pagination -> String
(Int -> Pagination -> ShowS)
-> (Pagination -> String)
-> ([Pagination] -> ShowS)
-> Show Pagination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Pagination -> ShowS
showsPrec :: Int -> Pagination -> ShowS
$cshow :: Pagination -> String
show :: Pagination -> String
$cshowList :: [Pagination] -> ShowS
showList :: [Pagination] -> ShowS
Show)

-- | Options for customizing a pagination, to be used with 'paginateOptions'.
data Options = 
    Options 
        {
            Options -> Int
maxItems :: Int -- ^ The maximum items per page. Default 50.
        ,   Options -> Int
windowSize :: Int -- ^ The size of the window in the page selector. Default 5.
        }

instance SetField "maxItems" Options Int where
    setField :: Int -> Options -> Options
setField Int
value Options
options =
        Options
options { $sel:maxItems:Options :: Int
maxItems = Int
value }
instance SetField "windowSize" Options Int where
    setField :: Int -> Options -> Options
setField Int
value Options
options =
        Options
options { $sel:windowSize:Options :: Int
windowSize = Int
value }

data PageDotDot =
      Page Int
    | DotDot Int