diff options
Diffstat (limited to 'Handler')
-rw-r--r-- | Handler/Common.hs | 7 | ||||
-rw-r--r-- | Handler/InventoryListing.hs | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/Handler/Common.hs b/Handler/Common.hs index a1ae34b..aacab92 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs | |||
@@ -11,6 +11,7 @@ module Handler.Common | |||
11 | , FormState(..) | 11 | , FormState(..) |
12 | , HasFormState(..) | 12 | , HasFormState(..) |
13 | , stockSort, referenceSort | 13 | , stockSort, referenceSort |
14 | , humanId | ||
14 | ) where | 15 | ) where |
15 | 16 | ||
16 | import Import | 17 | import Import |
@@ -28,6 +29,12 @@ import Handler.Common.Types | |||
28 | 29 | ||
29 | import Text.Julius (RawJS(..)) | 30 | import Text.Julius (RawJS(..)) |
30 | 31 | ||
32 | import qualified Codec.Crockford as Crockford (encode) | ||
33 | import Database.Persist.Sql (fromSqlKey) | ||
34 | |||
35 | humanId :: ItemId -> String | ||
36 | humanId = Crockford.encode . fromSqlKey | ||
37 | |||
31 | dayFormat :: Day -> String | 38 | dayFormat :: Day -> String |
32 | dayFormat = formatTime defaultTimeLocale "%e. %b %y" | 39 | dayFormat = formatTime defaultTimeLocale "%e. %b %y" |
33 | 40 | ||
diff --git a/Handler/InventoryListing.hs b/Handler/InventoryListing.hs index c2ec5d1..d5252a1 100644 --- a/Handler/InventoryListing.hs +++ b/Handler/InventoryListing.hs | |||
@@ -11,8 +11,8 @@ postInventoryListingR = do | |||
11 | case insertResult of | 11 | case insertResult of |
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 | insert Item{..} | 14 | newItem <- insert Item{..} |
15 | return () | 15 | addMessage "insertSuccess" [hamlet|Inserted new item as #{humanId newItem}|] |
16 | FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors | 16 | FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors |
17 | _ -> return () | 17 | _ -> return () |
18 | 18 | ||