summaryrefslogtreecommitdiff
path: root/Handler/UpdateItem.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-14 18:33:42 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-14 18:33:42 +0100
commit7bc954b779a9bc4e1c5e60f2648101c62ed22e72 (patch)
treeb30851324772c14550c0444b7e79e36256f67900 /Handler/UpdateItem.hs
parent53fcf55c02f9335518c28d26429913258fc28f87 (diff)
downloadbar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar
bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.gz
bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.bz2
bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.xz
bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.zip
Reference & list
Diffstat (limited to 'Handler/UpdateItem.hs')
-rw-r--r--Handler/UpdateItem.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/Handler/UpdateItem.hs b/Handler/UpdateItem.hs
index 353572b..a4a29c2 100644
--- a/Handler/UpdateItem.hs
+++ b/Handler/UpdateItem.hs
@@ -6,28 +6,28 @@ import Handler.Common
6 6
7getUpdateItemR, postUpdateItemR :: ItemId -> Handler TypedContent 7getUpdateItemR, postUpdateItemR :: ItemId -> Handler TypedContent
8getUpdateItemR = postUpdateItemR 8getUpdateItemR = postUpdateItemR
9postUpdateItemR fsUpdateItem = do 9postUpdateItemR fsUpdateId = do
10 Just entity <- fmap (Entity fsUpdateItem) <$> runDB (get fsUpdateItem) 10 Just entity <- fmap (Entity fsUpdateId) <$> runDB (get fsUpdateId)
11 11
12 ((updateResult, fsUpdateForm), fsUpdateEncoding) <- runFormPost . itemForm . Just $ entityVal entity 12 ((updateResult, fsUpdateForm), fsUpdateEncoding) <- runFormPost . itemForm . Just $ entityVal entity
13 13
14 mapM_ (addMessage "formError" . toHtml) =<< case updateResult of 14 mapM_ (addMessage "formError" . toHtml) =<< case updateResult of
15 FormSuccess Item{..} -> [] <$ runDB (update fsUpdateItem [ ItemKind =. itemKind 15 FormSuccess Item{..} -> [] <$ runDB (update fsUpdateId [ ItemKind =. itemKind
16 , ItemNormKind =. normalizeKind itemKind 16 , ItemNormKind =. normalizeKind itemKind
17 , ItemBought =. itemBought 17 , ItemBought =. itemBought
18 , ItemExpires =. itemExpires 18 , ItemExpires =. itemExpires
19 , ItemOpened =. itemOpened 19 , ItemOpened =. itemOpened
20 ]) 20 ])
21 FormFailure errors -> return errors 21 FormFailure errors -> return errors
22 _ -> return [] 22 _ -> return []
23 23
24 selectRep $ do 24 selectRep $ do
25 provideRep $ case updateResult of 25 provideRep $ case updateResult of
26 FormSuccess _ -> redirect $ InventoryListingR :#: fsUpdateItem :: Handler Html 26 FormSuccess _ -> redirect $ InventoryListingR :#: fsUpdateId :: Handler Html
27 _ -> do 27 _ -> do
28 (sortOn entityVal -> stock) <- runDB $ selectList [] [] 28 (sortOn entityVal -> stock) <- runDB $ selectList [] []
29 defaultLayout $ inventoryListing InventoryState 29 defaultLayout $ inventoryListing InventoryState
30 { formState = Just UpdateForm{..} 30 { invFormState = Just UpdateForm{..}
31 , .. 31 , ..
32 } 32 }
33 provideJson () 33 provideJson ()