From 6158d16443d46fea8b17c8d17de22d9164b90506 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 12 Dec 2020 11:51:58 -0800 Subject: [PATCH] ;ui: refactor, simplify query --- hledger-ui/Hledger/UI/Main.hs | 3 +-- hledger-ui/Hledger/UI/RegisterScreen.hs | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index bcce81887..e7d9fcd51 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -54,8 +54,7 @@ main = do opts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rspec@ReportSpec{rsOpts=ropts},rawopts_=rawopts}} <- getHledgerUIOpts -- when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts) - -- always include forecasted periodic transactions when loading data; - -- they will be toggled on and off in the UI. + -- always generate forecasted periodic transactions; their visibility will be toggled by the UI. let copts' = copts{reportspec_=rspec{rsOpts=ropts{forecast_=Just $ fromMaybe nulldatespan (forecast_ ropts)}}} case True of diff --git a/hledger-ui/Hledger/UI/RegisterScreen.hs b/hledger-ui/Hledger/UI/RegisterScreen.hs index e5e59e2d8..bd1df92a6 100644 --- a/hledger-ui/Hledger/UI/RegisterScreen.hs +++ b/hledger-ui/Hledger/UI/RegisterScreen.hs @@ -66,8 +66,10 @@ rsInit d reset ui@UIState{aopts=_uopts@UIOpts{cliopts_=CliOpts{reportspec_=rspec -- XXX temp inclusive = tree_ ropts || rsForceInclusive thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount + rspec' = rspec{rsOpts=ropts{depth_=Nothing}} - q = And [rsQuery rspec, periodq, excludeforecastq (forecast_ ropts)] + -- Further restrict the query based on the current period and future/forecast mode. + q = simplifyQuery $ And [rsQuery rspec, periodq, excludeforecastq (forecast_ ropts)] where periodq = Date $ periodAsDateSpan $ period_ ropts -- Except in forecast mode, exclude future/forecast transactions. @@ -98,8 +100,9 @@ rsInit d reset ui@UIState{aopts=_uopts@UIOpts{cliopts_=CliOpts{reportspec_=rspec ,rsItemBalanceAmount = showMixedOneLine showAmountWithoutPrice Nothing (Just 32) False bal ,rsItemTransaction = t } - -- blank items are added to allow more control of scroll position; we won't allow movement over these - blankitems = replicate 100 -- 100 ought to be enough for anyone + -- blank items are added to allow more control of scroll position; we won't allow movement over these. + -- XXX Ugly. Changing to 0 helps when debugging. + blankitems = replicate 100 -- "100 ought to be enough for anyone" RegisterScreenItem{rsItemDate = "" ,rsItemStatus = Unmarked ,rsItemDescription = ""