diff --git a/hledger-web/Hledger/Web/Foundation.hs b/hledger-web/Hledger/Web/Foundation.hs index 54832af47..d8d156975 100644 --- a/hledger-web/Hledger/Web/Foundation.hs +++ b/hledger-web/Hledger/Web/Foundation.hs @@ -114,7 +114,7 @@ instance Yesod App where master <- getYesod here <- fromMaybe RootR <$> getCurrentRoute - VD {caps, j, m, opts, q, qopts} <- getViewData + VD{opts, j, qparam, q, qopts, caps} <- getViewData msg <- getMessage showSidebar <- shouldShowSidebar @@ -124,14 +124,14 @@ instance Yesod App where {accountlistmode_ = ALTree -- force tree mode for sidebar ,empty_ = True -- show zero items by default } - rspec' = rspec{_rsQuery=m,_rsReportOpts=ropts'} + rspec' = rspec{_rsQuery=q,_rsReportOpts=ropts'} hideEmptyAccts <- if empty_ ropts then return True else (== Just "1") . lookup "hideemptyaccts" . reqCookies <$> getRequest let accounts = - balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j q qopts $ + balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j qparam qopts $ balanceReport rspec' j topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text @@ -195,8 +195,8 @@ data ViewData = VD { opts :: WebOpts -- ^ the command-line options at startup , today :: Day -- ^ today's date (for queries containing relative dates) , j :: Journal -- ^ the up-to-date parsed unfiltered journal - , q :: Text -- ^ the current q parameter, the main query expression - , m :: Query -- ^ a query parsed from the q parameter + , qparam :: Text -- ^ the current "q" request parameter + , q :: Query -- ^ a query parsed from the q parameter , qopts :: [QueryOpt] -- ^ query options parsed from the q parameter , caps :: [Capability] -- ^ capabilities enabled for this request } deriving (Show) @@ -242,7 +242,7 @@ getViewData = do Left e -> [] <$ addMessage "" ("Unknown permission: " <> toHtml (BC.unpack e)) Right c -> pure [c] - return VD{opts, today, j, q=qparam, m=q, qopts, caps} -- adapt to old q, m field names for now + return VD{opts, today, j, qparam, q, qopts, caps} checkServerSideUiEnabled :: Handler () checkServerSideUiEnabled = do diff --git a/hledger-web/Hledger/Web/Handler/JournalR.hs b/hledger-web/Hledger/Web/Handler/JournalR.hs index 5eb9ef06c..168efe803 100644 --- a/hledger-web/Hledger/Web/Handler/JournalR.hs +++ b/hledger-web/Hledger/Web/Handler/JournalR.hs @@ -20,14 +20,14 @@ import Hledger.Web.Widget.Common getJournalR :: Handler Html getJournalR = do checkServerSideUiEnabled - VD{caps, j, m, opts, q, qopts, today} <- getViewData + VD{caps, j, q, opts, qparam, qopts, today} <- getViewData when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability") let title = case inAccount qopts of Nothing -> "General Journal" Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)" - title' = title <> if m /= Any then ", filtered" else "" - acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)]) - rspec = (reportspec_ $ cliopts_ opts){_rsQuery = filterQuery (not . queryIsDepth) m} + title' = title <> if q /= Any then ", filtered" else "" + acctlink a = (RegisterR, [("q", replaceInacct qparam $ accountQuery a)]) + rspec = (reportspec_ $ cliopts_ opts){_rsQuery = filterQuery (not . queryIsDepth) q} items = reverse $ entriesReport rspec j transactionFrag = transactionFragment j diff --git a/hledger-web/Hledger/Web/Handler/RegisterR.hs b/hledger-web/Hledger/Web/Handler/RegisterR.hs index dad399963..7ae4a8014 100644 --- a/hledger-web/Hledger/Web/Handler/RegisterR.hs +++ b/hledger-web/Hledger/Web/Handler/RegisterR.hs @@ -26,26 +26,26 @@ import Hledger.Web.Widget.Common getRegisterR :: Handler Html getRegisterR = do checkServerSideUiEnabled - VD{caps, j, m, opts, q, qopts, today} <- getViewData + VD{caps, j, q, opts, qparam, qopts, today} <- getViewData when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability") let (a,inclsubs) = fromMaybe ("all accounts",True) $ inAccount qopts s1 = if inclsubs then "" else " (excluding subaccounts)" - s2 = if m /= Any then ", filtered" else "" + s2 = if q /= Any then ", filtered" else "" header = a <> s1 <> s2 let rspec = reportspec_ (cliopts_ opts) acctQuery = fromMaybe Any (inAccountQuery qopts) - acctlink acc = (RegisterR, [("q", replaceInacct q $ accountQuery acc)]) + acctlink acc = (RegisterR, [("q", replaceInacct qparam $ accountQuery acc)]) otherTransAccounts = map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) . undecorateLinks . elideRightDecorated 40 . decorateLinks . - addCommas . preferReal . otherTransactionAccounts m acctQuery + addCommas . preferReal . otherTransactionAccounts q acctQuery addCommas xs = zip xs $ zip (map (T.unpack . accountSummarisedName . paccount) xs) $ tail $ (", "<$xs) ++ [""] - items = accountTransactionsReport rspec{_rsQuery=m} j acctQuery + items = accountTransactionsReport rspec{_rsQuery=q} j acctQuery balancelabel | isJust (inAccount qopts), balanceaccum_ (_rsReportOpts rspec) == Historical = "Historical Total" | isJust (inAccount qopts) = "Period Total" diff --git a/hledger-web/Hledger/Web/Widget/Common.hs b/hledger-web/Hledger/Web/Widget/Common.hs index fe7054561..1ed40a19b 100644 --- a/hledger-web/Hledger/Web/Widget/Common.hs +++ b/hledger-web/Hledger/Web/Widget/Common.hs @@ -77,7 +77,7 @@ helplink topic label _ = H.a ! A.href u ! A.target "hledgerhelp" $ toHtml label -- | Render a "BalanceReport" as html. balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> Text -> [QueryOpt] -> BalanceReport -> HtmlUrl r -balanceReportAsHtml (journalR, registerR) here hideEmpty j q qopts (items, total) = +balanceReportAsHtml (journalR, registerR) here hideEmpty j qparam qopts (items, total) = $(hamletFile "templates/balance-report.hamlet") where l = ledgerFromJournal Any j diff --git a/hledger-web/templates/balance-report.hamlet b/hledger-web/templates/balance-report.hamlet index e27598722..bd0b1879a 100644 --- a/hledger-web/templates/balance-report.hamlet +++ b/hledger-web/templates/balance-report.hamlet @@ -11,11 +11,11 @@ $forall (acct, adisplay, aindent, abal) <- items