summaryrefslogtreecommitdiff
path: root/Handler/InventoryListing.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-15 21:39:15 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-15 21:39:15 +0100
commit3d828feba67f21ae62d1e6eb598a22ffaebf1174 (patch)
treef81437dab5090906362404b5df61aa5ab1f5203a /Handler/InventoryListing.hs
parent299731a0cef7462dd8c17bde7ba1a4aeb6f211cd (diff)
downloadbar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar
bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.gz
bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.bz2
bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.xz
bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.zip
Better ids & warnings
Diffstat (limited to 'Handler/InventoryListing.hs')
-rw-r--r--Handler/InventoryListing.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Handler/InventoryListing.hs b/Handler/InventoryListing.hs
index d5252a1..d87512a 100644
--- a/Handler/InventoryListing.hs
+++ b/Handler/InventoryListing.hs
@@ -12,7 +12,20 @@ postInventoryListingR = do
12 FormSuccess (Item{..} `WithType` t) -> runDB $ do 12 FormSuccess (Item{..} `WithType` t) -> runDB $ do
13 upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ] 13 upsertBy (UniqueKind itemNormKind) (Kind itemNormKind t) [ KindType =. t ]
14 newItem <- insert Item{..} 14 newItem <- insert Item{..}
15 addMessage "insertSuccess" [hamlet|Inserted new item as #{humanId newItem}|] 15 otherItems <- selectKeysList [ ItemNormKind ==. itemNormKind, ItemId !=. newItem ] []
16 when (not $ null otherItems) . addMessage "insertAmbiguous" $
17 [shamlet|
18 $newline never
19 There are other items of the same kind.
20 <ul>
21 $forall other <- otherItems
22 <li .itemId>#{humanId other}
23 |]
24 addMessage "insertSuccess" [shamlet|
25 $newline never
26 Inserted new item as #
27 <span .itemId>#{humanId newItem}
28 |]
16 FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors 29 FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors
17 _ -> return () 30 _ -> return ()
18 31