mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 21:02:04 +03:00
web: stay on add form; format errors/added transaction a little better
This commit is contained in:
parent
ed3cdf377c
commit
5106938b4b
@ -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:<br>
|
||||
$forall e<-errs
|
||||
#{e}<br>
|
||||
|]
|
||||
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|<span>Added transaction:<small><pre>#{chomp $ show t'}</pre></small>|]
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user