;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, | ||||
|   matchesPriceDirective, | ||||
|   words'', | ||||
|   prefixes, | ||||
|   -- * tests | ||||
|   tests_Query | ||||
| ) | ||||
|  | ||||
| @ -122,7 +122,7 @@ instance Yesod App where | ||||
|         -- flip the default for items with zero amounts, show them by default | ||||
|         ropts' = ropts { empty_ = not (empty_ ropts) } | ||||
|         accounts = | ||||
|           balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j qopts $ | ||||
|           balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j q qopts $ | ||||
|           balanceReport ropts' m j | ||||
| 
 | ||||
|         topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text | ||||
|  | ||||
| @ -37,6 +37,7 @@ import Yesod | ||||
| import Hledger | ||||
| import Hledger.Cli.Utils (writeFileWithBackupIfChanged) | ||||
| import Hledger.Web.Settings (manualurl) | ||||
| import qualified Hledger.Query as Query | ||||
| 
 | ||||
| #if MIN_VERSION_yesod(1,6,0) | ||||
| 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 | ||||
| 
 | ||||
| -- | Render a "BalanceReport" as html. | ||||
| balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r | ||||
| balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = | ||||
| balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> Text -> [QueryOpt] -> BalanceReport -> HtmlUrl r | ||||
| balanceReportAsHtml (journalR, registerR) here hideEmpty j q qopts (items, total) = | ||||
|   $(hamletFile "templates/balance-report.hamlet") | ||||
|   where | ||||
|     l = ledgerFromJournal Any j | ||||
| @ -113,3 +114,13 @@ transactionFragment j = | ||||
|     in  \t -> | ||||
|             printf "transaction-%d-%d" | ||||
|                 (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> | ||||
|       <div .ff-wrapper> | ||||
|         \#{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"> | ||||
|           #{adisplay} | ||||
|         $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 | ||||
|     <td> | ||||
|       ^{mixedAmountAsHtml abal} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user