From 7bc954b779a9bc4e1c5e60f2648101c62ed22e72 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 14 Mar 2017 18:33:42 +0100 Subject: Reference & list --- Handler/Common/Types.hs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'Handler/Common') diff --git a/Handler/Common/Types.hs b/Handler/Common/Types.hs index ca7cb8d..08653af 100644 --- a/Handler/Common/Types.hs +++ b/Handler/Common/Types.hs @@ -8,15 +8,32 @@ import Control.Lens data InventoryState = InventoryState { stock :: [Entity Item] - , formState :: Maybe FormState + , invFormState :: Maybe (FormState ItemId) } -data FormState = InsertForm +data ReferenceState = ReferenceState + { reference :: [Entity Reference] + , refFormState :: Maybe (FormState ReferenceId) + } + +class HasFormState a where + type family UpdateId a :: * + formState :: a -> Maybe (FormState (UpdateId a)) + +instance HasFormState InventoryState where + type UpdateId InventoryState = ItemId + formState = invFormState + +instance HasFormState ReferenceState where + type UpdateId ReferenceState = ReferenceId + formState = refFormState + +data FormState id = InsertForm { fsInsertForm :: Widget , fsInsertEncoding :: Enctype } | UpdateForm - { fsUpdateItem :: ItemId + { fsUpdateId :: id , fsUpdateForm :: Widget , fsUpdateEncoding :: Enctype } -- cgit v1.2.3