From 5106938b4b381245eecc53fba3e3f0cd2b3f87da Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 14 Jun 2011 21:12:24 +0000 Subject: [PATCH] web: stay on add form; format errors/added transaction a little better --- hledger-web/Hledger/Web/Handlers.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hledger-web/Hledger/Web/Handlers.hs b/hledger-web/Hledger/Web/Handlers.hs index 8d47d8a48..3e08c0121 100644 --- a/hledger-web/Hledger/Web/Handlers.hs +++ b/hledger-web/Hledger/Web/Handlers.hs @@ -505,14 +505,23 @@ handleAdd = do case tE of Left errs -> do -- save current form values in session - setMessage $ toHtml $ intercalate "; " errs - redirect RedirectTemporary RegisterR + -- setMessage $ toHtml $ intercalate "; " errs + setMessage [$hamlet| + Errors:
+ $forall e<-errs + #{e}
+ |] + redirectParams RedirectTemporary RegisterR [("add","1")] Right t -> do let t' = txnTieKnot t -- XXX move into balanceTransaction liftIO $ appendToJournalFile journalpath $ showTransaction t' - setMessage $ toHtml $ (printf "Added transaction:\n%s" (show t') :: String) - redirect RedirectTemporary RegisterR + -- setMessage $ toHtml $ (printf "Added transaction:\n%s" (show t') :: String) + setMessage [$hamlet|Added transaction:
#{chomp $ show t'}
|] + redirectParams RedirectTemporary RegisterR [("add","1")] + +chomp :: String -> String +chomp = reverse . dropWhile (`elem` "\r\n") . reverse -- | Handle a post from the journal edit form. handleEdit :: Handler RepPlain