aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component/Table.hs
diff options
context:
space:
mode:
authorJoris2019-10-22 22:26:38 +0200
committerJoris2019-10-22 22:26:38 +0200
commit613ffccac4b3ab25c6d4c631fab757da0b35acf6 (patch)
tree13e448af89f4079bb62d7ce8b5a44b6a64515129 /client/src/Component/Table.hs
parent80f09e8b3a5c856e60922a73c9161a8c5392e4d4 (diff)
downloadbudget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.tar.gz
budget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.tar.bz2
budget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.zip
Harmonize view component code style
Diffstat (limited to 'client/src/Component/Table.hs')
-rw-r--r--client/src/Component/Table.hs45
1 files changed, 22 insertions, 23 deletions
diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs
index b431c14..bf76566 100644
--- a/client/src/Component/Table.hs
+++ b/client/src/Component/Table.hs
@@ -1,29 +1,28 @@
module Component.Table
- ( table
- , TableIn(..)
- , TableOut(..)
+ ( view
+ , In(..)
+ , Out(..)
) where
import Data.Text (Text)
import Reflex.Dom (Dynamic, Event, MonadWidget)
import qualified Reflex.Dom as R
-import Component.Pages (PagesIn (..), PagesOut (..))
import qualified Component.Pages as Pages
-data TableIn h r t = TableIn
- { _tableIn_headerLabel :: h -> Text
- , _tableIn_rows :: Dynamic t [r]
- , _tableIn_cell :: h -> r -> Text
- , _tableIn_perPage :: Int
- , _tableIn_resetPage :: Event t ()
+data In h r t = In
+ { _in_headerLabel :: h -> Text
+ , _in_rows :: Dynamic t [r]
+ , _in_cell :: h -> r -> Text
+ , _in_perPage :: Int
+ , _in_resetPage :: Event t ()
}
-data TableOut = TableOut
+data Out = Out
{}
-table :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => TableIn h r t -> m (TableOut)
-table tableIn =
+view :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => In h r t -> m (Out)
+view input =
R.divClass "table" $ do
rec
R.divClass "lines" $ do
@@ -31,29 +30,29 @@ table tableIn =
R.divClass "header" $
flip mapM_ [minBound..] $ \header ->
R.divClass "cell" . R.text $
- _tableIn_headerLabel tableIn header
+ _in_headerLabel input header
let rows = getRange
- (_tableIn_perPage tableIn)
- <$> (_pagesOut_currentPage pages)
- <*> (_tableIn_rows tableIn)
+ (_in_perPage input)
+ <$> (Pages._out_currentPage pages)
+ <*> (_in_rows input)
R.simpleList rows $ \r ->
R.divClass "row" $
flip mapM_ [minBound..] $ \h ->
R.divClass "cell name" $
R.dynText $
- R.ffor r (_tableIn_cell tableIn h)
+ R.ffor r (_in_cell input h)
- pages <- Pages.widget $ PagesIn
- { _pagesIn_total = length <$> (_tableIn_rows tableIn)
- , _pagesIn_perPage = _tableIn_perPage tableIn
- , _pagesIn_reset = _tableIn_resetPage tableIn
+ pages <- Pages.view $ Pages.In
+ { Pages._in_total = length <$> (_in_rows input)
+ , Pages._in_perPage = _in_perPage input
+ , Pages._in_reset = _in_resetPage input
}
return ()
- return $ TableOut
+ return $ Out
{}
getRange :: forall a. Int -> Int -> [a] -> [a]