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/UpdateItem.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Handler/UpdateItem.hs') 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 getUpdateItemR, postUpdateItemR :: ItemId -> Handler TypedContent getUpdateItemR = postUpdateItemR -postUpdateItemR fsUpdateItem = do - Just entity <- fmap (Entity fsUpdateItem) <$> runDB (get fsUpdateItem) +postUpdateItemR fsUpdateId = do + Just entity <- fmap (Entity fsUpdateId) <$> runDB (get fsUpdateId) ((updateResult, fsUpdateForm), fsUpdateEncoding) <- runFormPost . itemForm . Just $ entityVal entity mapM_ (addMessage "formError" . toHtml) =<< case updateResult of - FormSuccess Item{..} -> [] <$ runDB (update fsUpdateItem [ ItemKind =. itemKind - , ItemNormKind =. normalizeKind itemKind - , ItemBought =. itemBought - , ItemExpires =. itemExpires - , ItemOpened =. itemOpened - ]) + FormSuccess Item{..} -> [] <$ runDB (update fsUpdateId [ ItemKind =. itemKind + , ItemNormKind =. normalizeKind itemKind + , ItemBought =. itemBought + , ItemExpires =. itemExpires + , ItemOpened =. itemOpened + ]) FormFailure errors -> return errors _ -> return [] selectRep $ do provideRep $ case updateResult of - FormSuccess _ -> redirect $ InventoryListingR :#: fsUpdateItem :: Handler Html + FormSuccess _ -> redirect $ InventoryListingR :#: fsUpdateId :: Handler Html _ -> do (sortOn entityVal -> stock) <- runDB $ selectList [] [] defaultLayout $ inventoryListing InventoryState - { formState = Just UpdateForm{..} + { invFormState = Just UpdateForm{..} , .. } provideJson () -- cgit v1.2.3