refactor(firm): dbTable form for firm all with selection box working now
This commit is contained in:
parent
19eea7abe8
commit
dfa03f8ba8
@ -212,10 +212,43 @@ mkFirmAllTable isAdmin uid = do
|
|||||||
)
|
)
|
||||||
dbtRowKey = (E.^. CompanyId)
|
dbtRowKey = (E.^. CompanyId)
|
||||||
dbtProj = dbtProjId
|
dbtProj = dbtProjId
|
||||||
dbtColonnade = -- formColonnade $
|
dbtColonnade = formColonnade $
|
||||||
mconcat
|
mconcat
|
||||||
[ -- if not isAdmin then mempty else -- guardOnM idAdmin $
|
[ -- if not isAdmin then mempty else -- guardOnM idAdmin $
|
||||||
-- hole :: (x -> f x) -> r -> f r
|
{- hole :: (x -> f x) -> r -> f r
|
||||||
|
(FormResult
|
||||||
|
(DBFormResult (Key Company) Bool (DBRow (Entity Company, E.Value Word64, E.Value Word64, E.Value Word64, E.Value Word64, E.Value Word64, E.Value Word64))
|
||||||
|
)
|
||||||
|
-> f (FormResult
|
||||||
|
(DBFormResult
|
||||||
|
(Key Company)
|
||||||
|
Bool
|
||||||
|
(DBRow
|
||||||
|
(Entity Company, E.Value Word64, E.Value Word64, E.Value Word64,
|
||||||
|
E.Value Word64, E.Value Word64, E.Value Word64)))))
|
||||||
|
-> FormResult
|
||||||
|
(First FirmAllActionData,
|
||||||
|
DBFormResult CompanyId Bool FirmAllActionData)
|
||||||
|
-> f (FormResult
|
||||||
|
(First FirmAllActionData,
|
||||||
|
DBFormResult CompanyId Bool FirmAllActionData))
|
||||||
|
|
||||||
|
-------
|
||||||
|
|
||||||
|
( (FormResult (DBFormResult (Key Company) Bool AllCompanyTableData))
|
||||||
|
-> f (FormResult (DBFormResult (Key Company) Bool AllCompanyTableData))
|
||||||
|
)
|
||||||
|
-> (FormResult (First FirmAllActionData, DBFormResult CompanyId Bool FirmAllActionData))
|
||||||
|
-> f (FormResult (First FirmAllActionData, DBFormResult CompanyId Bool FirmAllActionData))
|
||||||
|
|
||||||
|
------
|
||||||
|
Lens' (FormResult (DBFormResult (Key Company) Bool AllCompanyTableData))
|
||||||
|
(FormResult (First FirmAllActionData, DBFormResult CompanyId Bool FirmAllActionData))
|
||||||
|
------
|
||||||
|
Lens' (FormResult (Map (Key Company) (AllCompanyTableData,Bool -> Bool)))
|
||||||
|
(FormResult (First FirmAllActionData, (Map (CompanyId) (FirmAllActionData ,Bool -> Bool))))
|
||||||
|
-- applying bringt uns unter das FormResult
|
||||||
|
-}
|
||||||
dbSelect (applying _2) id (return . view (resultAllCompanyEntity . _entityKey))
|
dbSelect (applying _2) id (return . view (resultAllCompanyEntity . _entityKey))
|
||||||
, sortable (Just "name") (i18nCell MsgTableCompany) $ \(view resultAllCompany -> firm) ->
|
, sortable (Just "name") (i18nCell MsgTableCompany) $ \(view resultAllCompany -> firm) ->
|
||||||
anchorCell (FirmR $ companyShorthand firm) . toWgt $ companyName firm
|
anchorCell (FirmR $ companyShorthand firm) . toWgt $ companyName firm
|
||||||
@ -273,7 +306,7 @@ mkFirmAllTable isAdmin uid = do
|
|||||||
dbtCsvDecode = Nothing
|
dbtCsvDecode = Nothing
|
||||||
dbtExtraReps = []
|
dbtExtraReps = []
|
||||||
|
|
||||||
postprocess :: FormResult (First FirmAllActionData, DBFormResult CompanyId Bool FirmAllActionData)
|
postprocess :: FormResult (First FirmAllActionData, DBFormResult CompanyId Bool AllCompanyTableData)
|
||||||
-> FormResult ( FirmAllActionData, Set CompanyId)
|
-> FormResult ( FirmAllActionData, Set CompanyId)
|
||||||
postprocess inp = do
|
postprocess inp = do
|
||||||
(First (Just act), cmpMap) <- inp
|
(First (Just act), cmpMap) <- inp
|
||||||
|
|||||||
@ -1,10 +1,20 @@
|
|||||||
-- SPDX-FileCopyrightText: 2022 Felix Hamann <felix.hamann@campus.lmu.de>,Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>,Steffen Jost <jost@cip.ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>
|
-- SPDX-FileCopyrightText: 2022-23 Felix Hamann <felix.hamann@campus.lmu.de>,Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>,Steffen Jost <jost@cip.ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>,Steffen Jost <s.jost@fraport.de>
|
||||||
--
|
--
|
||||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
{-# LANGUAGE UndecidableInstances #-}
|
{-# LANGUAGE UndecidableInstances #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
|
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
|
||||||
|
|
||||||
|
|
||||||
|
{- FOP - Frequently occurring problems using dbTable:
|
||||||
|
|
||||||
|
- When changing a dbTable to a form, eg. using `dbSelect` then change the colonnade defnition from `dbColonnade` to `formColonnade`!
|
||||||
|
Both functions are equal to id, but the types are quite different.
|
||||||
|
|
||||||
|
- Don't mix up the row type alias traditionally ending with ...Data and the Action-Result-Type also ending with ...Data
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
module Handler.Utils.Table.Pagination
|
module Handler.Utils.Table.Pagination
|
||||||
( module Handler.Utils.Table.Pagination.Types
|
( module Handler.Utils.Table.Pagination.Types
|
||||||
, dbFilterKey
|
, dbFilterKey
|
||||||
@ -1654,10 +1664,12 @@ widgetColonnade :: Colonnade h r (DBCell (HandlerFor UniWorX) x)
|
|||||||
-> Colonnade h r (DBCell (HandlerFor UniWorX) x)
|
-> Colonnade h r (DBCell (HandlerFor UniWorX) x)
|
||||||
widgetColonnade = id
|
widgetColonnade = id
|
||||||
|
|
||||||
|
-- | force the column list type for tables that cotain forms, especially those constructed with dbSelect, avoids explicit type signatures
|
||||||
formColonnade :: Colonnade h r (DBCell (RWST (Maybe (Env, FileEnv), UniWorX, [Lang]) Enctype Ints (HandlerFor UniWorX)) (FormResult a))
|
formColonnade :: Colonnade h r (DBCell (RWST (Maybe (Env, FileEnv), UniWorX, [Lang]) Enctype Ints (HandlerFor UniWorX)) (FormResult a))
|
||||||
-> Colonnade h r (DBCell (RWST (Maybe (Env, FileEnv), UniWorX, [Lang]) Enctype Ints (HandlerFor UniWorX)) (FormResult a))
|
-> Colonnade h r (DBCell (RWST (Maybe (Env, FileEnv), UniWorX, [Lang]) Enctype Ints (HandlerFor UniWorX)) (FormResult a))
|
||||||
formColonnade = id
|
formColonnade = id
|
||||||
|
|
||||||
|
-- | force the column list type for simple tables that do not contain forms, and especially no dbSelect, avoids explicit type signatures
|
||||||
dbColonnade :: Colonnade h r (DBCell DB x)
|
dbColonnade :: Colonnade h r (DBCell DB x)
|
||||||
-> Colonnade h r (DBCell DB x)
|
-> Colonnade h r (DBCell DB x)
|
||||||
dbColonnade = id
|
dbColonnade = id
|
||||||
|
|||||||
Reference in New Issue
Block a user