mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
web: Add 'hide empty accounts' option (bound to 'e' key)
This commit is contained in:
parent
5f6da96baa
commit
df425802d4
@ -100,12 +100,13 @@ instance Yesod App where
|
||||
VD {j, m, opts, q, qopts} <- getViewData
|
||||
msg <- getMessage
|
||||
showSidebar <- shouldShowSidebar
|
||||
hideEmptyAccts <- (== Just "1") . lookup "hideemptyaccts" . reqCookies <$> getRequest
|
||||
|
||||
let ropts = reportopts_ (cliopts_ opts)
|
||||
-- flip the default for items with zero amounts, show them by default
|
||||
ropts' = ropts { empty_ = not (empty_ ropts) }
|
||||
accounts =
|
||||
balanceReportAsHtml (JournalR, RegisterR) here j qopts $
|
||||
balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j qopts $
|
||||
balanceReport ropts' m j
|
||||
|
||||
topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text
|
||||
@ -216,13 +217,12 @@ getCurrentJournal jref opts d = do
|
||||
j <- liftIO (readIORef jref)
|
||||
(ej, changed) <- liftIO $ journalReloadIfChanged opts d j
|
||||
-- re-apply any initial filter specified at startup
|
||||
let initq = queryFromOpts d $ reportopts_ opts
|
||||
if not changed
|
||||
then return (j,Nothing)
|
||||
else case filterJournalTransactions initq <$> ej of
|
||||
Right j' -> do
|
||||
liftIO $ writeIORef jref j'
|
||||
return (j',Nothing)
|
||||
Left e -> do
|
||||
setMessage "error while reading journal"
|
||||
return (j, Just e)
|
||||
let initq = queryFromOpts d (reportopts_ opts)
|
||||
case (changed, filterJournalTransactions initq <$> ej) of
|
||||
(False, _) -> return (j, Nothing)
|
||||
(True, Right j') -> do
|
||||
liftIO $ writeIORef jref j'
|
||||
return (j',Nothing)
|
||||
(True, Left e) -> do
|
||||
setMessage "error while reading journal"
|
||||
return (j, Just e)
|
||||
|
@ -56,8 +56,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 -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r
|
||||
balanceReportAsHtml (journalR, registerR) here j qopts (items, total) = [hamlet|
|
||||
balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r
|
||||
balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = [hamlet|
|
||||
<tr :here == journalR:.inacct>
|
||||
<td .top .acct>
|
||||
<a href=@{journalR} :here == journalR:.inacct
|
||||
@ -65,8 +65,8 @@ balanceReportAsHtml (journalR, registerR) here j qopts (items, total) = [hamlet|
|
||||
Journal
|
||||
<td .top>
|
||||
$forall (acct, adisplay, aindent, abal) <- items
|
||||
<tr .#{inacctClass acct}>
|
||||
<td .acct>
|
||||
<tr .#{inacctClass acct} :isZeroMixedAmount abal && hideEmpty:.hide>
|
||||
<td .acct :isZeroMixedAmount abal:.empty>
|
||||
<div .ff-wrapper>
|
||||
\#{indent aindent}
|
||||
<a href="@?{acctLink acct}" .#{inacctClass acct}
|
||||
|
@ -28,6 +28,7 @@ $(document).ready(function() {
|
||||
$('body').bind('keydown', 'shift+/', function(){ $('#helpmodal').modal('toggle'); return false; });
|
||||
$('body').bind('keydown', 'j', function(){ location.href = document.hledgerWebBaseurl+'/journal'; return false; });
|
||||
$('body').bind('keydown', 's', function(){ sidebarToggle(); return false; });
|
||||
$('body').bind('keydown', 'e', function(){ emptyAccountsToggle(); return false; });
|
||||
$('body').bind('keydown', 'a', function(){ addformShow(); return false; });
|
||||
$('body').bind('keydown', 'n', function(){ addformShow(); return false; });
|
||||
$('body').bind('keydown', 'f', function(){ $('#searchform input').focus(); return false; });
|
||||
@ -216,3 +217,8 @@ function sidebarToggle() {
|
||||
$('#spacer').toggleClass('col-md-4 col-sm-4 col-any-0');
|
||||
$.cookie('showsidebar', $('#sidebar-menu').hasClass('col-any-0') ? '0' : '1');
|
||||
}
|
||||
|
||||
function emptyAccountsToggle() {
|
||||
$('.acct.empty').parent().toggleClass('hide');
|
||||
$.cookie('hideemptyaccts', $.cookie('hideemptyaccts') === '1' ? '0' : '1')
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
<li> <code>a</code> - add a transaction (escape to cancel)
|
||||
<li> <code>s</code> - toggle sidebar
|
||||
<li> <code>f</code> - focus search form ("find")
|
||||
<li> <code>e</code> - hide empty accounts in sidebar
|
||||
<p>
|
||||
<b>General
|
||||
<ul>
|
||||
|
Loading…
Reference in New Issue
Block a user