;web: maintain queries in all other links, too

This commit is contained in:
Henning Thielemann 2020-05-26 13:04:26 +02:00 committed by Simon Michael
parent ec27eb6b17
commit ebe021b0c8
4 changed files with 11 additions and 7 deletions

View File

@ -13,19 +13,20 @@ import Hledger.Web.Import
import Hledger.Web.WebOptions import Hledger.Web.WebOptions
import Hledger.Web.Widget.AddForm (addModal) import Hledger.Web.Widget.AddForm (addModal)
import Hledger.Web.Widget.Common import Hledger.Web.Widget.Common
(accountQuery, mixedAmountAsHtml, transactionFragment) (accountQuery, mixedAmountAsHtml,
transactionFragment, replaceInacct)
-- | The formatted journal view, with sidebar. -- | The formatted journal view, with sidebar.
getJournalR :: Handler Html getJournalR :: Handler Html
getJournalR = do getJournalR = do
checkServerSideUiEnabled checkServerSideUiEnabled
VD{caps, j, m, opts, qopts, today} <- getViewData VD{caps, j, m, opts, q, qopts, today} <- getViewData
when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability") when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability")
let title = case inAccount qopts of let title = case inAccount qopts of
Nothing -> "General Journal" Nothing -> "General Journal"
Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)" Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)"
title' = title <> if m /= Any then ", filtered" else "" title' = title <> if m /= Any then ", filtered" else ""
acctlink a = (RegisterR, [("q", accountQuery a)]) acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)])
(_, items) = transactionsReport (reportopts_ $ cliopts_ opts) j m (_, items) = transactionsReport (reportopts_ $ cliopts_ opts) j m
transactionFrag = transactionFragment j transactionFrag = transactionFragment j

View File

@ -18,13 +18,14 @@ import Hledger.Web.Import
import Hledger.Web.WebOptions import Hledger.Web.WebOptions
import Hledger.Web.Widget.AddForm (addModal) import Hledger.Web.Widget.AddForm (addModal)
import Hledger.Web.Widget.Common import Hledger.Web.Widget.Common
(accountQuery, mixedAmountAsHtml, transactionFragment) (accountQuery, mixedAmountAsHtml,
transactionFragment, removeInacct, replaceInacct)
-- | The main journal/account register view, with accounts sidebar. -- | The main journal/account register view, with accounts sidebar.
getRegisterR :: Handler Html getRegisterR :: Handler Html
getRegisterR = do getRegisterR = do
checkServerSideUiEnabled checkServerSideUiEnabled
VD{caps, j, m, opts, qopts, today} <- getViewData VD{caps, j, m, opts, q, qopts, today} <- getViewData
when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability") when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability")
let (a,inclsubs) = fromMaybe ("all accounts",True) $ inAccount qopts let (a,inclsubs) = fromMaybe ("all accounts",True) $ inAccount qopts
@ -34,7 +35,7 @@ getRegisterR = do
let ropts = reportopts_ (cliopts_ opts) let ropts = reportopts_ (cliopts_ opts)
acctQuery = fromMaybe Any (inAccountQuery qopts) acctQuery = fromMaybe Any (inAccountQuery qopts)
acctlink acc = (RegisterR, [("q", accountQuery acc)]) acctlink acc = (RegisterR, [("q", replaceInacct q $ accountQuery acc)])
otherTransAccounts = otherTransAccounts =
map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) . map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) .
undecorateLinks . elideRightDecorated 40 . decorateLinks . undecorateLinks . elideRightDecorated 40 . decorateLinks .

View File

@ -15,6 +15,8 @@ module Hledger.Web.Widget.Common
, writeJournalTextIfValidAndChanged , writeJournalTextIfValidAndChanged
, journalFile404 , journalFile404
, transactionFragment , transactionFragment
, removeInacct
, replaceInacct
) where ) where
import Data.Default (def) import Data.Default (def)

View File

@ -21,7 +21,7 @@
$forall (torig, tacct, split, _acct, amt, bal) <- items $forall (torig, tacct, split, _acct, amt, bal) <- items
<tr ##{tindex torig} title="#{showTransaction torig}" style="vertical-align:top;"> <tr ##{tindex torig} title="#{showTransaction torig}" style="vertical-align:top;">
<td .date> <td .date>
<a href="@{JournalR}##{transactionFrag torig}"> <a href="@?{(JournalR, [("q", T.unwords $ removeInacct q)])}##{transactionFrag torig}">
#{show (tdate tacct)} #{show (tdate tacct)}
<td> <td>
#{textElideRight 30 (tdescription tacct)} #{textElideRight 30 (tdescription tacct)}