From 04c59f08f100ba6a0658d1f2b357f7d8b1e14218 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 13 Oct 2019 22:38:35 +0200 Subject: Show income table --- client/src/Component/Table.hs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 client/src/Component/Table.hs (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs new file mode 100644 index 0000000..a77a18d --- /dev/null +++ b/client/src/Component/Table.hs @@ -0,0 +1,38 @@ +module Component.Table + ( table + , TableIn(..) + , TableOut(..) + ) where + +import Data.Text (Text) +import Reflex.Dom (Dynamic, MonadWidget) +import qualified Reflex.Dom as R + +data TableIn h r t = TableIn + { _tableIn_headerLabel :: h -> Text + , _tableIn_rows :: Dynamic t [r] + , _tableIn_cell :: h -> r -> Text + } + +data TableOut = TableOut + {} + +table :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => TableIn h r t -> m (TableOut) +table tableIn = do + R.divClass "table" $ do + + R.divClass "lines" $ do + R.divClass "header" $ do + flip mapM_ [minBound..] $ \header -> + R.divClass "cell" . R.text $ + _tableIn_headerLabel tableIn header + + R.simpleList (_tableIn_rows tableIn) $ \r -> + R.divClass "row" $ + flip mapM_ [minBound..] $ \h -> + R.divClass "cell name" $ + R.dynText $ + R.ffor r (_tableIn_cell tableIn h) + + return $ TableOut + {} -- cgit v1.2.3 From 0b40b6b5583b5c437f83e61bf8913f2b4c447b24 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 19 Oct 2019 09:36:03 +0200 Subject: Include pages into table component --- client/src/Component/Table.hs | 53 +++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index a77a18d..b431c14 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -4,35 +4,58 @@ module Component.Table , TableOut(..) ) where -import Data.Text (Text) -import Reflex.Dom (Dynamic, MonadWidget) -import qualified Reflex.Dom as R +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 TableOut = TableOut {} table :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => TableIn h r t -> m (TableOut) -table tableIn = do +table tableIn = R.divClass "table" $ do + rec + R.divClass "lines" $ do + + R.divClass "header" $ + flip mapM_ [minBound..] $ \header -> + R.divClass "cell" . R.text $ + _tableIn_headerLabel tableIn header + + let rows = getRange + (_tableIn_perPage tableIn) + <$> (_pagesOut_currentPage pages) + <*> (_tableIn_rows tableIn) - R.divClass "lines" $ do - R.divClass "header" $ do - flip mapM_ [minBound..] $ \header -> - R.divClass "cell" . R.text $ - _tableIn_headerLabel tableIn header + 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.simpleList (_tableIn_rows tableIn) $ \r -> - R.divClass "row" $ - flip mapM_ [minBound..] $ \h -> - R.divClass "cell name" $ - R.dynText $ - R.ffor r (_tableIn_cell tableIn h) + pages <- Pages.widget $ PagesIn + { _pagesIn_total = length <$> (_tableIn_rows tableIn) + , _pagesIn_perPage = _tableIn_perPage tableIn + , _pagesIn_reset = _tableIn_resetPage tableIn + } + + return () return $ TableOut {} + +getRange :: forall a. Int -> Int -> [a] -> [a] +getRange perPage currentPage = + take perPage . drop ((currentPage - 1) * perPage) -- cgit v1.2.3 From 613ffccac4b3ab25c6d4c631fab757da0b35acf6 Mon Sep 17 00:00:00 2001 From: Joris Date: Tue, 22 Oct 2019 22:26:38 +0200 Subject: Harmonize view component code style --- client/src/Component/Table.hs | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'client/src/Component/Table.hs') 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] -- cgit v1.2.3 From 61ff1443c42def5a09f624e3df2e2520e97610d0 Mon Sep 17 00:00:00 2001 From: Joris Date: Tue, 22 Oct 2019 23:25:05 +0200 Subject: Clone incomes --- client/src/Component/Table.hs | 54 ++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index bf76566..5819f45 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -4,56 +4,82 @@ module Component.Table , Out(..) ) where -import Data.Text (Text) -import Reflex.Dom (Dynamic, Event, MonadWidget) -import qualified Reflex.Dom as R +import Data.Text (Text) +import Reflex.Dom (Dynamic, Event, MonadWidget) +import qualified Reflex.Dom as R -import qualified Component.Pages as Pages +import qualified Component.Button as Button +import qualified Component.Modal as Modal +import qualified Component.Pages as Pages +import qualified Util.Reflex as ReflexUtil +import qualified View.Icon as Icon -data In h r t = In +data In m t h r a = In { _in_headerLabel :: h -> Text , _in_rows :: Dynamic t [r] , _in_cell :: h -> r -> Text , _in_perPage :: Int , _in_resetPage :: Event t () + , _in_cloneModal :: Dynamic t r -> Modal.Content t m a } -data Out = Out - {} +data Out t a = Out + { _out_add :: Event t a + } -view :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => In h r t -> m (Out) +view :: forall t m h r a. (MonadWidget t m, Bounded h, Enum h) => In m t h r a -> m (Out t a) view input = R.divClass "table" $ do rec - R.divClass "lines" $ do + result <- R.divClass "lines" $ do - R.divClass "header" $ + R.divClass "header" $ do flip mapM_ [minBound..] $ \header -> R.divClass "cell" . R.text $ _in_headerLabel input header + R.divClass "cell" $ R.blank + let rows = getRange (_in_perPage input) <$> (Pages._out_currentPage pages) <*> (_in_rows input) R.simpleList rows $ \r -> - R.divClass "row" $ + R.divClass "row" $ do flip mapM_ [minBound..] $ \h -> - R.divClass "cell name" $ + R.divClass "cell" $ R.dynText $ R.ffor r (_in_cell input h) + clone <- + R.divClass "cell button" $ + Button._out_clic <$> (Button.view $ + Button.defaultIn Icon.clone) + + cloned <- + Modal.view $ Modal.In + { Modal._in_show = clone + , Modal._in_content = _in_cloneModal input r + } + + return cloned + 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 $ + -- ( R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result + -- , R.switch . R.current . fmap (R.leftmost . map (\(_, b, _) -> b)) $ result + -- , R.switch . R.current . fmap (R.leftmost . map (\(_, _, c) -> c)) $ result + -- ) return $ Out - {} + { _out_add = R.switch . R.current . fmap R.leftmost $ result + } getRange :: forall a. Int -> Int -> [a] -> [a] getRange perPage currentPage = -- cgit v1.2.3 From f968c8ce63e1aec119b1e6f414cf27e2c0294bcb Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 23 Oct 2019 21:09:54 +0200 Subject: Delete income --- client/src/Component/Table.hs | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index 5819f45..b3c70a0 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -20,11 +20,14 @@ data In m t h r a = In , _in_cell :: h -> r -> Text , _in_perPage :: Int , _in_resetPage :: Event t () - , _in_cloneModal :: Dynamic t r -> Modal.Content t m a + , _in_cloneModal :: r -> Modal.Content t m a + , _in_deleteModal :: r -> Modal.Content t m a + , _in_isOwner :: r -> Bool } data Out t a = Out - { _out_add :: Event t a + { _out_add :: Event t a + , _out_delete :: Event t a } view :: forall t m h r a. (MonadWidget t m, Bounded h, Enum h) => In m t h r a -> m (Out t a) @@ -39,6 +42,7 @@ view input = _in_headerLabel input header R.divClass "cell" $ R.blank + R.divClass "cell" $ R.blank let rows = getRange (_in_perPage input) @@ -60,25 +64,41 @@ view input = cloned <- Modal.view $ Modal.In { Modal._in_show = clone - , Modal._in_content = _in_cloneModal input r + , Modal._in_content = \curtainClick -> + (R.dyn . R.ffor r $ \r2 -> _in_cloneModal input r2 curtainClick) + >>= ReflexUtil.flattenTuple + } + + let isOwner = R.ffor r (_in_isOwner input) + + delete <- + R.divClass "cell button" $ + ReflexUtil.divVisibleIf isOwner $ + Button._out_clic <$> (Button.view $ + Button.defaultIn Icon.delete) + + deleted <- + Modal.view $ Modal.In + { Modal._in_show = delete + , Modal._in_content = \curtainClick -> + (R.dyn . R.ffor r $ \r2 -> _in_deleteModal input r2 curtainClick) + >>= ReflexUtil.flattenTuple } - return cloned + return (cloned, deleted) pages <- Pages.view $ Pages.In - { Pages._in_total = length <$> (_in_rows input) + { Pages._in_total = length <$> _in_rows input , Pages._in_perPage = _in_perPage input , Pages._in_reset = _in_resetPage input } - -- return $ - -- ( R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result - -- , R.switch . R.current . fmap (R.leftmost . map (\(_, b, _) -> b)) $ result - -- , R.switch . R.current . fmap (R.leftmost . map (\(_, _, c) -> c)) $ result - -- ) + let add = R.switch . R.current . fmap (R.leftmost . map fst) $ result + delete = R.switch . R.current . fmap (R.leftmost . map snd) $ result return $ Out - { _out_add = R.switch . R.current . fmap R.leftmost $ result + { _out_add = add + , _out_delete = delete } getRange :: forall a. Int -> Int -> [a] -> [a] -- cgit v1.2.3 From e4b32ce15f8c92f3b477d3f3d4d301ba08f9b5e3 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 23 Oct 2019 22:35:27 +0200 Subject: Edit an income --- client/src/Component/Table.hs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index b3c70a0..a02eaa7 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -21,12 +21,14 @@ data In m t h r a = In , _in_perPage :: Int , _in_resetPage :: Event t () , _in_cloneModal :: r -> Modal.Content t m a + , _in_editModal :: r -> Modal.Content t m a , _in_deleteModal :: r -> Modal.Content t m a , _in_isOwner :: r -> Bool } data Out t a = Out { _out_add :: Event t a + , _out_edit :: Event t a , _out_delete :: Event t a } @@ -43,6 +45,7 @@ view input = R.divClass "cell" $ R.blank R.divClass "cell" $ R.blank + R.divClass "cell" $ R.blank let rows = getRange (_in_perPage input) @@ -71,6 +74,20 @@ view input = let isOwner = R.ffor r (_in_isOwner input) + edit <- + R.divClass "cell button" $ + ReflexUtil.divVisibleIf isOwner $ + Button._out_clic <$> (Button.view $ + Button.defaultIn Icon.edit) + + edited <- + Modal.view $ Modal.In + { Modal._in_show = edit + , Modal._in_content = \curtainClick -> + (R.dyn . R.ffor r $ \r2 -> _in_editModal input r2 curtainClick) + >>= ReflexUtil.flattenTuple + } + delete <- R.divClass "cell button" $ ReflexUtil.divVisibleIf isOwner $ @@ -85,7 +102,7 @@ view input = >>= ReflexUtil.flattenTuple } - return (cloned, deleted) + return (cloned, edited, deleted) pages <- Pages.view $ Pages.In { Pages._in_total = length <$> _in_rows input @@ -93,11 +110,13 @@ view input = , Pages._in_reset = _in_resetPage input } - let add = R.switch . R.current . fmap (R.leftmost . map fst) $ result - delete = R.switch . R.current . fmap (R.leftmost . map snd) $ result + let add = R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result + edit = R.switch . R.current . fmap (R.leftmost . map (\(_, a, _) -> a)) $ result + delete = R.switch . R.current . fmap (R.leftmost . map (\(_, _, a) -> a)) $ result return $ Out { _out_add = add + , _out_edit = edit , _out_delete = delete } -- cgit v1.2.3 From b97ad942495352c3fc1e0c820cfba82a9693ac7a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Oct 2019 20:26:29 +0100 Subject: WIP Set up server side paging for incomes --- client/src/Component/Table.hs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index a02eaa7..7103abd 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -10,7 +10,6 @@ import qualified Reflex.Dom as R import qualified Component.Button as Button import qualified Component.Modal as Modal -import qualified Component.Pages as Pages import qualified Util.Reflex as ReflexUtil import qualified View.Icon as Icon @@ -18,8 +17,6 @@ data In m t h r a = In { _in_headerLabel :: h -> Text , _in_rows :: Dynamic t [r] , _in_cell :: h -> r -> Text - , _in_perPage :: Int - , _in_resetPage :: Event t () , _in_cloneModal :: r -> Modal.Content t m a , _in_editModal :: r -> Modal.Content t m a , _in_deleteModal :: r -> Modal.Content t m a @@ -47,12 +44,7 @@ view input = R.divClass "cell" $ R.blank R.divClass "cell" $ R.blank - let rows = getRange - (_in_perPage input) - <$> (Pages._out_currentPage pages) - <*> (_in_rows input) - - R.simpleList rows $ \r -> + R.simpleList (_in_rows input) $ \r -> R.divClass "row" $ do flip mapM_ [minBound..] $ \h -> R.divClass "cell" $ @@ -104,12 +96,6 @@ view input = return (cloned, edited, deleted) - pages <- Pages.view $ Pages.In - { Pages._in_total = length <$> _in_rows input - , Pages._in_perPage = _in_perPage input - , Pages._in_reset = _in_resetPage input - } - let add = R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result edit = R.switch . R.current . fmap (R.leftmost . map (\(_, a, _) -> a)) $ result delete = R.switch . R.current . fmap (R.leftmost . map (\(_, _, a) -> a)) $ result @@ -119,7 +105,3 @@ view input = , _out_edit = edit , _out_delete = delete } - -getRange :: forall a. Int -> Int -> [a] -> [a] -getRange perPage currentPage = - take perPage . drop ((currentPage - 1) * perPage) -- cgit v1.2.3 From 227dcd4435b775d7dbc5ae5d3d81b589897253cc Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 2 Nov 2019 20:52:27 +0100 Subject: Implement incomes server side paging --- client/src/Component/Table.hs | 62 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index 7103abd..3b9ec24 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -4,8 +4,9 @@ module Component.Table , Out(..) ) where +import qualified Data.Map as M import Data.Text (Text) -import Reflex.Dom (Dynamic, Event, MonadWidget) +import Reflex.Dom (Event, MonadWidget) import qualified Reflex.Dom as R import qualified Component.Button as Button @@ -15,7 +16,7 @@ import qualified View.Icon as Icon data In m t h r a = In { _in_headerLabel :: h -> Text - , _in_rows :: Dynamic t [r] + , _in_rows :: [r] , _in_cell :: h -> r -> Text , _in_cloneModal :: r -> Modal.Content t m a , _in_editModal :: r -> Modal.Content t m a @@ -44,61 +45,60 @@ view input = R.divClass "cell" $ R.blank R.divClass "cell" $ R.blank - R.simpleList (_in_rows input) $ \r -> + flip mapM (_in_rows input) $ \row -> R.divClass "row" $ do - flip mapM_ [minBound..] $ \h -> + flip mapM_ [minBound..] $ \header -> R.divClass "cell" $ - R.dynText $ - R.ffor r (_in_cell input h) + R.text $ + _in_cell input header row - clone <- + cloneButton <- R.divClass "cell button" $ Button._out_clic <$> (Button.view $ Button.defaultIn Icon.clone) - cloned <- + clone <- Modal.view $ Modal.In - { Modal._in_show = clone - , Modal._in_content = \curtainClick -> - (R.dyn . R.ffor r $ \r2 -> _in_cloneModal input r2 curtainClick) - >>= ReflexUtil.flattenTuple + { Modal._in_show = cloneButton + , Modal._in_content = _in_cloneModal input row } - let isOwner = R.ffor r (_in_isOwner input) + let isOwner = _in_isOwner input row - edit <- + let visibleIf cond = + R.elAttr + "div" + (if cond then M.empty else M.singleton "style" "display:none") + + editButton <- R.divClass "cell button" $ - ReflexUtil.divVisibleIf isOwner $ + visibleIf isOwner $ Button._out_clic <$> (Button.view $ Button.defaultIn Icon.edit) - edited <- + edit <- Modal.view $ Modal.In - { Modal._in_show = edit - , Modal._in_content = \curtainClick -> - (R.dyn . R.ffor r $ \r2 -> _in_editModal input r2 curtainClick) - >>= ReflexUtil.flattenTuple + { Modal._in_show = editButton + , Modal._in_content = _in_editModal input row } - delete <- + deleteButton <- R.divClass "cell button" $ - ReflexUtil.divVisibleIf isOwner $ + visibleIf isOwner $ Button._out_clic <$> (Button.view $ Button.defaultIn Icon.delete) - deleted <- + delete <- Modal.view $ Modal.In - { Modal._in_show = delete - , Modal._in_content = \curtainClick -> - (R.dyn . R.ffor r $ \r2 -> _in_deleteModal input r2 curtainClick) - >>= ReflexUtil.flattenTuple + { Modal._in_show = deleteButton + , Modal._in_content = _in_deleteModal input row } - return (cloned, edited, deleted) + return (clone, edit, delete) - let add = R.switch . R.current . fmap (R.leftmost . map (\(a, _, _) -> a)) $ result - edit = R.switch . R.current . fmap (R.leftmost . map (\(_, a, _) -> a)) $ result - delete = R.switch . R.current . fmap (R.leftmost . map (\(_, _, a) -> a)) $ result + let add = R.leftmost . map (\(a, _, _) -> a) $ result + edit = R.leftmost . map (\(_, a, _) -> a) $ result + delete = R.leftmost . map (\(_, _, a) -> a) $ result return $ Out { _out_add = add -- cgit v1.2.3 From f4f24158a46d8c0975f1b8813bbdbbeebad8c108 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 6 Nov 2019 19:44:15 +0100 Subject: Show the payment table with server side paging --- client/src/Component/Table.hs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index 3b9ec24..2869c2d 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -4,7 +4,7 @@ module Component.Table , Out(..) ) where -import qualified Data.Map as M +import qualified Data.Map as M import Data.Text (Text) import Reflex.Dom (Event, MonadWidget) import qualified Reflex.Dom as R @@ -14,23 +14,23 @@ import qualified Component.Modal as Modal import qualified Util.Reflex as ReflexUtil import qualified View.Icon as Icon -data In m t h r a = In +data In m t h r a b c = In { _in_headerLabel :: h -> Text , _in_rows :: [r] - , _in_cell :: h -> r -> Text + , _in_cell :: h -> r -> m () , _in_cloneModal :: r -> Modal.Content t m a - , _in_editModal :: r -> Modal.Content t m a - , _in_deleteModal :: r -> Modal.Content t m a + , _in_editModal :: r -> Modal.Content t m b + , _in_deleteModal :: r -> Modal.Content t m c , _in_isOwner :: r -> Bool } -data Out t a = Out +data Out t a b c = Out { _out_add :: Event t a - , _out_edit :: Event t a - , _out_delete :: Event t a + , _out_edit :: Event t b + , _out_delete :: Event t c } -view :: forall t m h r a. (MonadWidget t m, Bounded h, Enum h) => In m t h r a -> m (Out t a) +view :: forall t m h r a b c. (MonadWidget t m, Bounded h, Enum h) => In m t h r a b c-> m (Out t a b c) view input = R.divClass "table" $ do rec @@ -49,8 +49,7 @@ view input = R.divClass "row" $ do flip mapM_ [minBound..] $ \header -> R.divClass "cell" $ - R.text $ - _in_cell input header row + _in_cell input header row cloneButton <- R.divClass "cell button" $ -- cgit v1.2.3 From 316bda10c6bec8b5ccc9e23f1f677c076205f046 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 8 Dec 2019 11:39:37 +0100 Subject: Add category page --- client/src/Component/Table.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index 2869c2d..f82cfa6 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -14,23 +14,23 @@ import qualified Component.Modal as Modal import qualified Util.Reflex as ReflexUtil import qualified View.Icon as Icon -data In m t h r a b c = In +data In m t h r = In { _in_headerLabel :: h -> Text , _in_rows :: [r] , _in_cell :: h -> r -> m () - , _in_cloneModal :: r -> Modal.Content t m a - , _in_editModal :: r -> Modal.Content t m b - , _in_deleteModal :: r -> Modal.Content t m c + , _in_cloneModal :: r -> Modal.Content t m + , _in_editModal :: r -> Modal.Content t m + , _in_deleteModal :: r -> Modal.Content t m , _in_isOwner :: r -> Bool } -data Out t a b c = Out - { _out_add :: Event t a - , _out_edit :: Event t b - , _out_delete :: Event t c +data Out t = Out + { _out_add :: Event t () + , _out_edit :: Event t () + , _out_delete :: Event t () } -view :: forall t m h r a b c. (MonadWidget t m, Bounded h, Enum h) => In m t h r a b c-> m (Out t a b c) +view :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => In m t h r -> m (Out t) view input = R.divClass "table" $ do rec -- cgit v1.2.3 From da2a0c13aa89705c65fdb9df2f496fb4eea29654 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 4 Jan 2020 19:22:45 +0100 Subject: Allow to remove only unused categories --- client/src/Component/Table.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'client/src/Component/Table.hs') diff --git a/client/src/Component/Table.hs b/client/src/Component/Table.hs index f82cfa6..1482f91 100644 --- a/client/src/Component/Table.hs +++ b/client/src/Component/Table.hs @@ -21,7 +21,8 @@ data In m t h r = In , _in_cloneModal :: r -> Modal.Content t m , _in_editModal :: r -> Modal.Content t m , _in_deleteModal :: r -> Modal.Content t m - , _in_isOwner :: r -> Bool + , _in_canEdit :: r -> Bool + , _in_canDelete :: r -> Bool } data Out t = Out @@ -62,8 +63,6 @@ view input = , Modal._in_content = _in_cloneModal input row } - let isOwner = _in_isOwner input row - let visibleIf cond = R.elAttr "div" @@ -71,7 +70,7 @@ view input = editButton <- R.divClass "cell button" $ - visibleIf isOwner $ + visibleIf (_in_canEdit input row) $ Button._out_clic <$> (Button.view $ Button.defaultIn Icon.edit) @@ -83,7 +82,7 @@ view input = deleteButton <- R.divClass "cell button" $ - visibleIf isOwner $ + visibleIf (_in_canDelete input row) $ Button._out_clic <$> (Button.view $ Button.defaultIn Icon.delete) -- cgit v1.2.3