web: expand postings on journal register by default, p parameter of 1 or 0 overrides

A toggle all link in the column heading is commented out as it's too slow.
This commit is contained in:
Simon Michael 2011-06-27 14:07:06 +00:00
parent 1d0f14e55e
commit f28fbb4870
5 changed files with 18 additions and 6 deletions

View File

@ -15,6 +15,7 @@ $(document).ready(function() {
/* set up various show/hide toggles */
$('#search-help-link').click(function() { $('#search-help').slideToggle('fast'); event.preventDefault(); });
$('#accounts-toggle-link').click(function() { $('#accounts').slideToggle('fast'); event.preventDefault(); });
$('#all-postings-toggle-link').click(function() { $('.posting').toggle(); event.preventDefault(); });
$('.postings-toggle-link').click(function() { $(this).parent().parent().nextUntil(':not(.posting)').toggle(); event.preventDefault(); });
});

View File

@ -108,11 +108,12 @@ table.journalreport { border-spacing: 0; }
.balancereport td { padding:0; }
.totalrule td { border-top:thin solid black; }
.hidden { display:none; }
table.registerreport { border-spacing:0; }
table.registerreport tr { vertical-align:top; }
table.registerreport td { padding-bottom:0.2em; }
table.registerreport .date { white-space:nowrap; }
table.registerreport tr.posting { display:none; font-size:smaller; }
table.registerreport tr.posting { font-size:smaller; }
table.registerreport tr.posting .account { padding-left:1.5em; }
table.registerreport tr.posting .amount { padding-right:0.5em; }
tr.firstposting td { }

View File

@ -2,7 +2,10 @@
<tr.headings
<th.date align=left>Date
<th.description align=left>Description
<th.account align=left>Account
<th.account align=left>
Account
<!-- \ #
<a#all-postings-toggle-link.togglelink href="#" title="Toggle all split postings">[+/-] -->
<th.amount align=right>Amount
<th.balance align=right>#{balancelabel}

View File

@ -16,7 +16,7 @@
<td.balance align=right>#{mixedAmountAsHtml bal}
$if split
$forall p <- tpostings t'
<tr.item.#{evenodd}.posting
<tr.item.#{evenodd}.posting.#{displayclass}
<td.date
<td.description
<td.account>&nbsp;<a href="@?{accountUrl here $ paccount p}" title="#{stringIfLongerThan 40 $ paccount p}">#{elideRight 40 $ paccount p}

View File

@ -166,7 +166,7 @@ accountRegisterReportAsHtml :: [Opt] -> ViewData -> AccountRegisterReport -> Ham
accountRegisterReportAsHtml _ vd (balancelabel,items) = $(Settings.hamletFile "accountregisterreport")
where
itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, AccountRegisterReportItem) -> Hamlet AppRoute
itemAsHtml VD{here=here} (n, newd, newm, newy, (t, t', split, acct, amt, bal)) = $(Settings.hamletFile "accountregisterreportitem")
itemAsHtml VD{here=here,p=p} (n, newd, newm, newy, (t, t', split, acct, amt, bal)) = $(Settings.hamletFile "accountregisterreportitem")
where
evenodd = if even n then "even" else "odd" :: String
datetransition | newm = "newmonth"
@ -175,6 +175,7 @@ accountRegisterReportAsHtml _ vd (balancelabel,items) = $(Settings.hamletFile "a
(firstposting, date, desc) = (False, show $ tdate t, tdescription t)
acctquery = (here, [("q", pack $ accountQuery acct)])
showamt = not split || not (isZeroMixedAmount amt)
displayclass = if p then "" else "hidden" :: String
stringIfLongerThan :: Int -> String -> String
stringIfLongerThan n s = if length s > n then s else ""
@ -416,7 +417,8 @@ nulltemplate = [$hamlet||]
-- | A bundle of data useful for handlers and their templates.
data ViewData = VD {
opts :: [Opt] -- ^ command-line options at startup
,q :: String -- ^ current q parameter (the query expression for filtering transactions)
,q :: String -- ^ current q parameter, the query expression
,p :: Bool -- ^ current p parameter, 1 or 0 shows/hides all postings, default is based on query
,m :: Matcher -- ^ a matcher parsed from the query expr
,qopts :: [QueryOpt] -- ^ query options parsed from the query expr
,j :: Journal -- ^ the up-to-date parsed unfiltered journal
@ -429,6 +431,7 @@ mkvd :: ViewData
mkvd = VD {
opts = []
,q = ""
,p = False
,m = MatchAny
,qopts = []
,j = nulljournal
@ -448,7 +451,11 @@ getViewData = do
today <- liftIO getCurrentDay
q <- getParameter "q"
let (m,qopts) = parseQuery today q
return mkvd{opts=opts, q=q, m=m, qopts=qopts, j=j, today=today, here=here', msg=msg}
p <- getParameter "p"
let p' | p == "1" = True
| p == "0" = False
| otherwise = isNothing $ inAccountMatcher qopts
return mkvd{opts=opts, q=q, p=p', m=m, qopts=qopts, j=j, today=today, here=here', msg=msg}
where
-- | Update our copy of the journal if the file changed. If there is an
-- error while reloading, keep the old one and return the error, and set a