;web: maintain query when choosing a different 'inacct' account on the sidebar
This commit is contained in:
parent
54300328cd
commit
ec27eb6b17
@ -49,6 +49,7 @@ module Hledger.Query (
|
|||||||
matchesCommodity,
|
matchesCommodity,
|
||||||
matchesPriceDirective,
|
matchesPriceDirective,
|
||||||
words'',
|
words'',
|
||||||
|
prefixes,
|
||||||
-- * tests
|
-- * tests
|
||||||
tests_Query
|
tests_Query
|
||||||
)
|
)
|
||||||
|
|||||||
@ -122,7 +122,7 @@ instance Yesod App where
|
|||||||
-- flip the default for items with zero amounts, show them by default
|
-- flip the default for items with zero amounts, show them by default
|
||||||
ropts' = ropts { empty_ = not (empty_ ropts) }
|
ropts' = ropts { empty_ = not (empty_ ropts) }
|
||||||
accounts =
|
accounts =
|
||||||
balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j qopts $
|
balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j q qopts $
|
||||||
balanceReport ropts' m j
|
balanceReport ropts' m j
|
||||||
|
|
||||||
topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text
|
topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import Yesod
|
|||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.Cli.Utils (writeFileWithBackupIfChanged)
|
import Hledger.Cli.Utils (writeFileWithBackupIfChanged)
|
||||||
import Hledger.Web.Settings (manualurl)
|
import Hledger.Web.Settings (manualurl)
|
||||||
|
import qualified Hledger.Query as Query
|
||||||
|
|
||||||
#if MIN_VERSION_yesod(1,6,0)
|
#if MIN_VERSION_yesod(1,6,0)
|
||||||
journalFile404 :: FilePath -> Journal -> HandlerFor m (FilePath, Text)
|
journalFile404 :: FilePath -> Journal -> HandlerFor m (FilePath, Text)
|
||||||
@ -82,8 +83,8 @@ helplink topic label _ = H.a ! A.href u ! A.target "hledgerhelp" $ toHtml label
|
|||||||
where u = textValue $ manualurl <> if T.null topic then "" else T.cons '#' topic
|
where u = textValue $ manualurl <> if T.null topic then "" else T.cons '#' topic
|
||||||
|
|
||||||
-- | Render a "BalanceReport" as html.
|
-- | Render a "BalanceReport" as html.
|
||||||
balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r
|
balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> Text -> [QueryOpt] -> BalanceReport -> HtmlUrl r
|
||||||
balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) =
|
balanceReportAsHtml (journalR, registerR) here hideEmpty j q qopts (items, total) =
|
||||||
$(hamletFile "templates/balance-report.hamlet")
|
$(hamletFile "templates/balance-report.hamlet")
|
||||||
where
|
where
|
||||||
l = ledgerFromJournal Any j
|
l = ledgerFromJournal Any j
|
||||||
@ -113,3 +114,13 @@ transactionFragment j =
|
|||||||
in \t ->
|
in \t ->
|
||||||
printf "transaction-%d-%d"
|
printf "transaction-%d-%d"
|
||||||
(hm HashMap.! sourceFilePath (tsourcepos t)) (tindex t)
|
(hm HashMap.! sourceFilePath (tsourcepos t)) (tindex t)
|
||||||
|
|
||||||
|
removeInacct :: Text -> [Text]
|
||||||
|
removeInacct =
|
||||||
|
map quoteIfSpaced .
|
||||||
|
filter (\term ->
|
||||||
|
not $ T.isPrefixOf "inacct:" term || T.isPrefixOf "inacctonly:" term) .
|
||||||
|
Query.words'' Query.prefixes
|
||||||
|
|
||||||
|
replaceInacct :: Text -> Text -> Text
|
||||||
|
replaceInacct q acct = T.unwords $ acct : removeInacct q
|
||||||
|
|||||||
@ -11,11 +11,11 @@ $forall (acct, adisplay, aindent, abal) <- items
|
|||||||
<td .acct :isZeroMixedAmount abal:.empty>
|
<td .acct :isZeroMixedAmount abal:.empty>
|
||||||
<div .ff-wrapper>
|
<div .ff-wrapper>
|
||||||
\#{indent aindent}
|
\#{indent aindent}
|
||||||
<a.acct-name href="@?{(registerR, [("q", accountQuery acct)])}"
|
<a.acct-name href="@?{(registerR, [("q", replaceInacct q $ accountQuery acct)])}"
|
||||||
title="Show transactions affecting this account and subaccounts">
|
title="Show transactions affecting this account and subaccounts">
|
||||||
#{adisplay}
|
#{adisplay}
|
||||||
$if hasSubAccounts acct
|
$if hasSubAccounts acct
|
||||||
<a href="@?{(registerR, [("q", accountOnlyQuery acct)])}" .only.hidden-sm.hidden-xs
|
<a href="@?{(registerR, [("q", replaceInacct q $ accountOnlyQuery acct)])}" .only.hidden-sm.hidden-xs
|
||||||
title="Show transactions affecting this account but not subaccounts">only
|
title="Show transactions affecting this account but not subaccounts">only
|
||||||
<td>
|
<td>
|
||||||
^{mixedAmountAsHtml abal}
|
^{mixedAmountAsHtml abal}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user