ui: indicate when balance assertions are ignored

The indication takes up lots of space, may need refinement.
It's currently not shown on the error screen.
This commit is contained in:
Simon Michael 2016-07-06 15:04:34 -07:00
parent 347e9dc701
commit 19fc5b61f7
4 changed files with 29 additions and 19 deletions

View File

@ -100,7 +100,7 @@ asInit d reset ui@UIState{
asInit _ _ _ = error "init function called with wrong screen type, should not happen" asInit _ _ _ = error "init function called with wrong screen type, should not happen"
asDraw :: UIState -> [Widget] asDraw :: UIState -> [Widget]
asDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} asDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,ajournal=j ,ajournal=j
,aScreen=s@AccountsScreen{} ,aScreen=s@AccountsScreen{}
,aMode=mode ,aMode=mode
@ -110,18 +110,22 @@ asDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
-- Minibuffer e -> [minibuffer e, maincontent] -- Minibuffer e -> [minibuffer e, maincontent]
_ -> [maincontent] _ -> [maincontent]
where where
toplabel = files toplabel =
<+> nonzero files
<+> str " accounts" <+> nonzero
<+> withAttr (borderAttr <> "query") (str (if flat_ ropts then " (flat)" else "")) <+> str " accounts"
<+> borderQueryStr querystr <+> withAttr (borderAttr <> "query") (str (if flat_ ropts then " (flat)" else ""))
<+> togglefilters <+> borderQueryStr querystr
<+> borderDepthStr mdepth <+> togglefilters
<+> str " (" <+> borderDepthStr mdepth
<+> cur <+> str " ("
<+> str "/" <+> cur
<+> total <+> str "/"
<+> str ")" <+> total
<+> str ")"
<+> (if ignore_assertions_ copts
then withAttr (borderAttr <> "query") (str " ignoring balance assertions")
else str "")
files = case journalFilePaths j of files = case journalFilePaths j of
[] -> str "" [] -> str ""
f:_ -> withAttr ("border" <> "bold") $ str $ takeFileName f f:_ -> withAttr ("border" <> "bold") $ str $ takeFileName f

View File

@ -9,6 +9,7 @@ module Hledger.UI.ErrorScreen
where where
import Brick import Brick
-- import Brick.Widgets.Border (borderAttr)
import Control.Monad import Control.Monad
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Data.Monoid import Data.Monoid
@ -36,15 +37,18 @@ esInit _ _ ui@UIState{aScreen=ErrorScreen{}} = ui
esInit _ _ _ = error "init function called with wrong screen type, should not happen" esInit _ _ _ = error "init function called with wrong screen type, should not happen"
esDraw :: UIState -> [Widget] esDraw :: UIState -> [Widget]
esDraw UIState{ -- aopts=_uopts@UIOpts{cliopts_=_copts@CliOpts{reportopts_=_ropts@ReportOpts{query_=querystr}}}, esDraw UIState{ --aopts=UIOpts{cliopts_=copts@CliOpts{}}
aScreen=ErrorScreen{..} aScreen=ErrorScreen{..}
,aMode=mode} = ,aMode=mode} =
case mode of case mode of
Help -> [helpDialog, maincontent] Help -> [helpDialog, maincontent]
-- Minibuffer e -> [minibuffer e, maincontent] -- Minibuffer e -> [minibuffer e, maincontent]
_ -> [maincontent] _ -> [maincontent]
where where
toplabel = withAttr ("border" <> "bold") (str "Oops. Please fix this problem then press g to reload") toplabel =
withAttr ("border" <> "bold") (str "Oops. Please fix this problem then press g to reload")
-- <+> (if ignore_assertions_ copts then withAttr (borderAttr <> "query") (str " ignoring") else str " not ignoring")
maincontent = Widget Greedy Greedy $ do maincontent = Widget Greedy Greedy $ do
render $ defaultLayout toplabel bottomlabel $ withAttr "error" $ str $ esError render $ defaultLayout toplabel bottomlabel $ withAttr "error" $ str $ esError
where where

View File

@ -99,7 +99,7 @@ rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajo
rsInit _ _ _ = error "init function called with wrong screen type, should not happen" rsInit _ _ _ = error "init function called with wrong screen type, should not happen"
rsDraw :: UIState -> [Widget] rsDraw :: UIState -> [Widget]
rsDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,aScreen=RegisterScreen{..} ,aScreen=RegisterScreen{..}
,aMode=mode ,aMode=mode
} = } =
@ -120,6 +120,7 @@ rsDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
<+> str "/" <+> str "/"
<+> total <+> total
<+> str ")" <+> str ")"
<+> (if ignore_assertions_ copts then withAttr (borderAttr <> "query") (str " ignoring balance assertions") else str "")
togglefilters = togglefilters =
case concat [ case concat [
if cleared_ ropts then ["cleared"] else [] if cleared_ ropts then ["cleared"] else []

View File

@ -46,7 +46,7 @@ tsInit _d _reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=_ropts}}
tsInit _ _ _ = error "init function called with wrong screen type, should not happen" tsInit _ _ _ = error "init function called with wrong screen type, should not happen"
tsDraw :: UIState -> [Widget] tsDraw :: UIState -> [Widget]
tsDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,aScreen=TransactionScreen{ ,aScreen=TransactionScreen{
tsTransaction=(i,t) tsTransaction=(i,t)
,tsTransactions=nts ,tsTransactions=nts
@ -69,6 +69,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
<+> togglefilters <+> togglefilters
<+> borderQueryStr (query_ ropts) <+> borderQueryStr (query_ ropts)
<+> str (" in "++T.unpack (replaceHiddenAccountsNameWith "All" acct)++")") <+> str (" in "++T.unpack (replaceHiddenAccountsNameWith "All" acct)++")")
<+> (if ignore_assertions_ copts then withAttr (borderAttr <> "query") (str " ignoring balance assertions") else str "")
togglefilters = togglefilters =
case concat [ case concat [
if cleared_ ropts then ["cleared"] else [] if cleared_ ropts then ["cleared"] else []