mirror of
https://github.com/byteverse/colonnade.git
synced 2026-03-26 02:07:08 +01:00
correct rounding bug in pagination
This commit is contained in:
parent
6300c03a5f
commit
900f6a2e18
@ -582,6 +582,7 @@ expandable tableAttrs tdExpandedAttrs as encoding@(E.Colonnade v) = do
|
|||||||
|
|
||||||
data Visible a = Visible !Bool a
|
data Visible a = Visible !Bool a
|
||||||
|
|
||||||
|
-- TODO: figure out a way to get rid of the awful default value hack
|
||||||
paginated :: forall t b h m a c.
|
paginated :: forall t b h m a c.
|
||||||
(Sizable t b h, Cellular t m c, Headedness b, MonadFix m, Functor h)
|
(Sizable t b h, Cellular t m c, Headedness b, MonadFix m, Functor h)
|
||||||
=> Bureau t b a -- ^ table class settings
|
=> Bureau t b a -- ^ table class settings
|
||||||
@ -599,7 +600,7 @@ paginated (Bureau tableAttrs theadAttrs bodyAttrs trAttrs) (Pagination pageSize
|
|||||||
v <- vecD
|
v <- vecD
|
||||||
return (maybe (Visible False aDef) (Visible True) (v V.!? (p * pageSize + ix)))
|
return (maybe (Visible False aDef) (Visible True) (v V.!? (p * pageSize + ix)))
|
||||||
totalPages :: Dynamic t Int
|
totalPages :: Dynamic t Int
|
||||||
totalPages = fmap ((`div` pageSize) . V.length) vecD
|
totalPages = fmap ((`divRoundUp` pageSize) . V.length) vecD
|
||||||
hideWhenUnipage :: Dynamic t (Map Text Text) -> Dynamic t (Map Text Text)
|
hideWhenUnipage :: Dynamic t (Map Text Text) -> Dynamic t (Map Text Text)
|
||||||
hideWhenUnipage = zipDynWith
|
hideWhenUnipage = zipDynWith
|
||||||
( \ct attrs -> if ct > 1 then attrs else M.insert "style" "display:none;" attrs
|
( \ct attrs -> if ct > 1 then attrs else M.insert "style" "display:none;" attrs
|
||||||
@ -624,6 +625,9 @@ paginated (Bureau tableAttrs theadAttrs bodyAttrs trAttrs) (Pagination pageSize
|
|||||||
return ()
|
return ()
|
||||||
_ -> error "Reflex.Dom.Colonnade: paginated: write this code"
|
_ -> error "Reflex.Dom.Colonnade: paginated: write this code"
|
||||||
|
|
||||||
|
divRoundUp :: Int -> Int -> Int
|
||||||
|
divRoundUp a b = case divMod a b of
|
||||||
|
(x,y) -> if y == 0 then x else x + 1
|
||||||
|
|
||||||
tableHeader :: forall t b h c a m.
|
tableHeader :: forall t b h c a m.
|
||||||
(Reflex t, Sizable t b h, Cellular t m c, Headedness b)
|
(Reflex t, Sizable t b h, Cellular t m c, Headedness b)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user