ui: allow multiple status filters to be active at once (#564)

This commit is contained in:
Simon Michael 2017-06-15 18:15:37 -07:00
parent dcc58d4a2b
commit 22e751983b
4 changed files with 21 additions and 13 deletions

View File

@ -15,6 +15,7 @@ module Hledger.Reports.ReportOptions (
checkReportOpts,
flat_,
tree_,
reportOptsToggleStatus,
whichDateFromOpts,
journalSelectingAmountFromOpts,
queryFromOpts,
@ -284,6 +285,11 @@ simplifyStatuses l
l' = nub $ sort l
numstatuses = length [minBound .. maxBound :: Status]
-- | Add/remove this status from the status list. Used by hledger-ui.
reportOptsToggleStatus s ropts@ReportOpts{statuses_=ss}
| s `elem` ss = ropts{statuses_=filter (/= s) ss}
| otherwise = ropts{statuses_=simplifyStatuses (s:ss)}
type DisplayExp = String
maybedisplayopt :: Day -> RawOpts -> Maybe DisplayExp

View File

@ -32,10 +32,6 @@ toggleCleared :: UIState -> UIState
toggleCleared ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
ui{aopts=uopts{cliopts_=copts{reportopts_=reportOptsToggleStatus Cleared ropts}}}
reportOptsToggleStatus s ropts
| clearedstatus_ ropts == [s] = ropts{clearedstatus_=[]}
| otherwise = ropts{clearedstatus_=[s]}
-- | Toggle between showing all and showing only nonempty (more precisely, nonzero) items.
toggleEmpty :: UIState -> UIState
toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =

View File

@ -76,9 +76,9 @@ helpDialog =
,renderKey ("t", "set report period to today")
,str " "
,renderKey ("/", "set a filter query")
,renderKey ("U", "toggle unmarked/all")
,renderKey ("P", "toggle pending/all")
,renderKey ("C", "toggle cleared/all")
,renderKey ("U", "toggle unmarked filter")
,renderKey ("P", "toggle pending filter")
,renderKey ("C", "toggle cleared filter")
,renderKey ("R", "toggle real/all")
,renderKey ("Z", "toggle nonzero/all")
,renderKey ("DEL/BS", "remove filters")

View File

@ -163,9 +163,13 @@ balances are what you would see on a bank statement for that account (unless dis
a filter query). Period balances ignore transactions before the report start date, so they
show the change in balance during the report period. They are more useful eg when viewing a time log.
`C` toggles cleared mode, which shows balances for postings with [cleared status](/journal.html#status) only.
Similarly, `P` toggles pending mode, which shows balances for pending postings only,
and `U` toggles uncleared mode, which shows balances for unmarked postings only.
`U` toggles filtering by [unmarked status](/journal.html#status),
including or excluding unmarked postings in the balances.
Similarly, `P` toggles pending postings,
and `C` toggles cleared postings.
(By default, balances include all postings;
if you activate one or two status filters, only those postings are included;
and if you activate all three, the filter is removed.)
`R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored.
@ -202,9 +206,11 @@ In other words, the register always shows the transactions responsible for the p
shown on the accounts screen.
As on the accounts screen, this can be toggled with `F`.
`C` toggles cleared mode, which shows transactions with [cleared status](/journal.html#status) only.
Similarly, `P` toggles pending mode, which shows only pending transactions,
and `U` toggles uncleared mode, which shows only unmarked transactions.
`U` toggles filtering by [unmarked status](/journal.html#status), showing or hiding unmarked transactions.
Similarly, `P` toggles pending transactions, and `C` toggles cleared transactions.
(By default, transactions with all statuses are shown;
if you activate one or two status filters, only those transactions are shown;
and if you activate all three, the filter is removed.)q
`R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored.