mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 15:14:49 +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
|
case tE of
|
||||||
Left errs -> do
|
Left errs -> do
|
||||||
-- save current form values in session
|
-- save current form values in session
|
||||||
setMessage $ toHtml $ intercalate "; " errs
|
-- setMessage $ toHtml $ intercalate "; " errs
|
||||||
redirect RedirectTemporary RegisterR
|
setMessage [$hamlet|
|
||||||
|
Errors:<br>
|
||||||
|
$forall e<-errs
|
||||||
|
#{e}<br>
|
||||||
|
|]
|
||||||
|
redirectParams RedirectTemporary RegisterR [("add","1")]
|
||||||
|
|
||||||
Right t -> do
|
Right t -> do
|
||||||
let t' = txnTieKnot t -- XXX move into balanceTransaction
|
let t' = txnTieKnot t -- XXX move into balanceTransaction
|
||||||
liftIO $ appendToJournalFile journalpath $ showTransaction t'
|
liftIO $ appendToJournalFile journalpath $ showTransaction t'
|
||||||
setMessage $ toHtml $ (printf "Added transaction:\n%s" (show t') :: String)
|
-- setMessage $ toHtml $ (printf "Added transaction:\n%s" (show t') :: String)
|
||||||
redirect RedirectTemporary RegisterR
|
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.
|
-- | Handle a post from the journal edit form.
|
||||||
handleEdit :: Handler RepPlain
|
handleEdit :: Handler RepPlain
|
||||||
|
Loading…
Reference in New Issue
Block a user