diff options
Diffstat (limited to 'Handler/Common')
-rw-r--r-- | Handler/Common/Types.hs | 23 |
1 files changed, 20 insertions, 3 deletions
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 | |||
8 | 8 | ||
9 | data InventoryState = InventoryState | 9 | data InventoryState = InventoryState |
10 | { stock :: [Entity Item] | 10 | { stock :: [Entity Item] |
11 | , formState :: Maybe FormState | 11 | , invFormState :: Maybe (FormState ItemId) |
12 | } | 12 | } |
13 | 13 | ||
14 | data FormState = InsertForm | 14 | data ReferenceState = ReferenceState |
15 | { reference :: [Entity Reference] | ||
16 | , refFormState :: Maybe (FormState ReferenceId) | ||
17 | } | ||
18 | |||
19 | class HasFormState a where | ||
20 | type family UpdateId a :: * | ||
21 | formState :: a -> Maybe (FormState (UpdateId a)) | ||
22 | |||
23 | instance HasFormState InventoryState where | ||
24 | type UpdateId InventoryState = ItemId | ||
25 | formState = invFormState | ||
26 | |||
27 | instance HasFormState ReferenceState where | ||
28 | type UpdateId ReferenceState = ReferenceId | ||
29 | formState = refFormState | ||
30 | |||
31 | data FormState id = InsertForm | ||
15 | { fsInsertForm :: Widget | 32 | { fsInsertForm :: Widget |
16 | , fsInsertEncoding :: Enctype | 33 | , fsInsertEncoding :: Enctype |
17 | } | 34 | } |
18 | | UpdateForm | 35 | | UpdateForm |
19 | { fsUpdateItem :: ItemId | 36 | { fsUpdateId :: id |
20 | , fsUpdateForm :: Widget | 37 | , fsUpdateForm :: Widget |
21 | , fsUpdateEncoding :: Enctype | 38 | , fsUpdateEncoding :: Enctype |
22 | } | 39 | } |