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 |     VD {j, m, opts, q, qopts} <- getViewData | ||||||
|     msg <- getMessage |     msg <- getMessage | ||||||
|     showSidebar <- shouldShowSidebar |     showSidebar <- shouldShowSidebar | ||||||
|  |     hideEmptyAccts <- (== Just "1") . lookup "hideemptyaccts" . reqCookies <$> getRequest | ||||||
| 
 | 
 | ||||||
|     let ropts = reportopts_ (cliopts_ opts) |     let ropts = reportopts_ (cliopts_ opts) | ||||||
|         -- 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 j qopts $ |           balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j 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 | ||||||
| @ -216,13 +217,12 @@ getCurrentJournal jref opts d = do | |||||||
|   j <- liftIO (readIORef jref) |   j <- liftIO (readIORef jref) | ||||||
|   (ej, changed) <- liftIO $ journalReloadIfChanged opts d j |   (ej, changed) <- liftIO $ journalReloadIfChanged opts d j | ||||||
|   -- re-apply any initial filter specified at startup |   -- re-apply any initial filter specified at startup | ||||||
|   let initq = queryFromOpts d $ reportopts_ opts |   let initq = queryFromOpts d (reportopts_ opts) | ||||||
|   if not changed |   case (changed, filterJournalTransactions initq <$> ej) of | ||||||
|     then return (j,Nothing) |     (False, _) -> return (j, Nothing) | ||||||
|     else case filterJournalTransactions initq <$> ej of |     (True, Right j') -> do | ||||||
|            Right j' -> do |       liftIO $ writeIORef jref j' | ||||||
|              liftIO $ writeIORef jref j' |       return (j',Nothing) | ||||||
|              return (j',Nothing) |     (True, Left e) -> do | ||||||
|            Left e -> do |       setMessage "error while reading journal" | ||||||
|              setMessage "error while reading journal" |       return (j, Just e) | ||||||
|              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 |   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 -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r | balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r | ||||||
| balanceReportAsHtml (journalR, registerR) here j qopts (items, total) = [hamlet| | balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = [hamlet| | ||||||
| <tr :here == journalR:.inacct> | <tr :here == journalR:.inacct> | ||||||
|   <td .top .acct> |   <td .top .acct> | ||||||
|     <a href=@{journalR} :here == journalR:.inacct |     <a href=@{journalR} :here == journalR:.inacct | ||||||
| @ -65,8 +65,8 @@ balanceReportAsHtml (journalR, registerR) here j qopts (items, total) = [hamlet| | |||||||
|       Journal |       Journal | ||||||
|   <td .top> |   <td .top> | ||||||
| $forall (acct, adisplay, aindent, abal) <- items | $forall (acct, adisplay, aindent, abal) <- items | ||||||
|   <tr .#{inacctClass acct}> |   <tr .#{inacctClass acct} :isZeroMixedAmount abal && hideEmpty:.hide> | ||||||
|     <td .acct> |     <td .acct :isZeroMixedAmount abal:.empty> | ||||||
|       <div .ff-wrapper> |       <div .ff-wrapper> | ||||||
|         \#{indent aindent} |         \#{indent aindent} | ||||||
|         <a href="@?{acctLink acct}" .#{inacctClass acct} |         <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', 'shift+/', function(){ $('#helpmodal').modal('toggle'); return false; }); | ||||||
|   $('body').bind('keydown', 'j',       function(){ location.href = document.hledgerWebBaseurl+'/journal'; 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', 's',       function(){ sidebarToggle(); return false; }); | ||||||
|  |   $('body').bind('keydown', 'e',       function(){ emptyAccountsToggle(); return false; }); | ||||||
|   $('body').bind('keydown', 'a',       function(){ addformShow(); return false; }); |   $('body').bind('keydown', 'a',       function(){ addformShow(); return false; }); | ||||||
|   $('body').bind('keydown', 'n',       function(){ addformShow(); return false; }); |   $('body').bind('keydown', 'n',       function(){ addformShow(); return false; }); | ||||||
|   $('body').bind('keydown', 'f',       function(){ $('#searchform input').focus(); 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'); |   $('#spacer').toggleClass('col-md-4 col-sm-4 col-any-0'); | ||||||
|   $.cookie('showsidebar', $('#sidebar-menu').hasClass('col-any-0') ? '0' : '1'); |   $.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>a</code> - add a transaction (escape to cancel) | ||||||
|                 <li> <code>s</code> - toggle sidebar |                 <li> <code>s</code> - toggle sidebar | ||||||
|                 <li> <code>f</code> - focus search form ("find") |                 <li> <code>f</code> - focus search form ("find") | ||||||
|  |                 <li> <code>e</code> - hide empty accounts in sidebar | ||||||
|             <p> |             <p> | ||||||
|               <b>General |               <b>General | ||||||
|               <ul> |               <ul> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user