web: separate period and acct/desc filtering a bit
This commit is contained in:
		
							parent
							
								
									cf62482102
								
							
						
					
					
						commit
						f3ffef2d8a
					
				| @ -244,7 +244,7 @@ getAccountsPage = do | |||||||
| balanceReportAsHtml :: [Opt] -> TemplateData -> BalanceReport -> Hamlet HledgerWebAppRoute | balanceReportAsHtml :: [Opt] -> TemplateData -> BalanceReport -> Hamlet HledgerWebAppRoute | ||||||
| balanceReportAsHtml _ td@TD{here=here,a=a,p=p} (items,total) = [$hamlet| | balanceReportAsHtml _ td@TD{here=here,a=a,p=p} (items,total) = [$hamlet| | ||||||
| %table.balancereport | %table.balancereport | ||||||
|  ^allaccts^ |  ^accountsheading^ | ||||||
|  $forall items i |  $forall items i | ||||||
|   ^itemAsHtml' i^ |   ^itemAsHtml' i^ | ||||||
|  %tr.totalrule |  %tr.totalrule | ||||||
| @ -254,39 +254,33 @@ balanceReportAsHtml _ td@TD{here=here,a=a,p=p} (items,total) = [$hamlet| | |||||||
|   %td!align=right $mixedAmountAsHtml.total$ |   %td!align=right $mixedAmountAsHtml.total$ | ||||||
| |] | |] | ||||||
|  where |  where | ||||||
|    filtering = not $ null a && null p |    accountsheading = [$hamlet| | ||||||
|    showmore = if filtering then [$hamlet| |                       accounts | ||||||
| ^showmore'^ |                       \ $ | ||||||
| \ | $ |                       %span#showmoreaccounts ^showmore^ ^showall^ | ||||||
| %a!href=@here@ show all |                       <br /> | ||||||
| |] else nulltemplate |                       <br /> | ||||||
|    showmore' = case (filtering, items) of |                       |] | ||||||
|                  -- cunning parent account logic |        where | ||||||
|                  (True, ((acct, _, _, _):_)) -> |          filteringaccts = not $ null a | ||||||
|                      let a' = if isAccountRegex a then a else acct |          showmore = case (filteringaccts, items) of | ||||||
|                          a'' = accountNameToAccountRegex $ parentAccountName $ accountRegexToAccountName a' |                       -- cunning parent account logic | ||||||
|                          parenturl = (here, [("a",a''), ("p",p)]) |                       (True, ((acct, _, _, _):_)) -> | ||||||
|                      in [$hamlet| |                           let a' = if isAccountRegex a then a else acct | ||||||
|                          \ | $ |                               a'' = accountNameToAccountRegex $ parentAccountName $ accountRegexToAccountName a' | ||||||
|                          %a!href=@?parenturl@ show more ↑ |                               parenturl = (here, [("a",a''), ("p",p)]) | ||||||
|                          |] |                           in [$hamlet| | ||||||
|                  _ -> nulltemplate |                               \ | $ | ||||||
|    allacctslink = True |                               %a!href=@?parenturl@ show more ↑ | ||||||
|    allaccts = if allacctslink |                               |] | ||||||
|                then -- [$hamlet|%tr.$current$ |                       _ -> nulltemplate | ||||||
|                     --           %td |          showall = if filteringaccts | ||||||
|                     --            %a!href=@?u@ all accounts |                     then [$hamlet| | ||||||
|                     --           %td |                           \ | $ | ||||||
|                     [$hamlet| |                           %a!href=@?allurl@ show all | ||||||
| accounts |                           |] | ||||||
| \ $ |                     else nulltemplate | ||||||
| %span#showmoreaccounts ^showmore^ |              where allurl = (here, [("p",p)]) | ||||||
| <br /> |  | ||||||
| <br /> |  | ||||||
| |] |  | ||||||
|                else nulltemplate |  | ||||||
|    --     where u = (here, [("a",".*"),("p",p)]) |  | ||||||
|    -- current = "" -- if a == ".*" then "current" else "" |  | ||||||
|    itemAsHtml' = itemAsHtml td |    itemAsHtml' = itemAsHtml td | ||||||
|    itemAsHtml :: TemplateData -> BalanceReportItem -> Hamlet HledgerWebAppRoute |    itemAsHtml :: TemplateData -> BalanceReportItem -> Hamlet HledgerWebAppRoute | ||||||
|    itemAsHtml TD{p=p} (acct, adisplay, adepth, abal) = [$hamlet| |    itemAsHtml TD{p=p} (acct, adisplay, adepth, abal) = [$hamlet| | ||||||
| @ -297,7 +291,7 @@ accounts | |||||||
|       %td.balance!align=right $mixedAmountAsHtml.abal$ |       %td.balance!align=right $mixedAmountAsHtml.abal$ | ||||||
|      |] where |      |] where | ||||||
|        current = "" -- if not (null a) && containsRegex a acct then "current" else "" |        current = "" -- if not (null a) && containsRegex a acct then "current" else "" | ||||||
|        indent = preEscapedString $ concat $ replicate (2 * (adepth + if allacctslink then 1 else 0)) " " |        indent = preEscapedString $ concat $ replicate (2 * adepth) " " | ||||||
|        aurl = printf ".?a=%s%s" (accountNameToAccountRegex acct) p' :: String |        aurl = printf ".?a=%s%s" (accountNameToAccountRegex acct) p' :: String | ||||||
|        p' = if null p then "" else printf "&p=%s" p |        p' = if null p then "" else printf "&p=%s" p | ||||||
| 
 | 
 | ||||||
| @ -806,7 +800,7 @@ navbar TD{p=p,j=j,today=today} = [$hamlet| | |||||||
|     journaltitle = printf "%s" (takeFileName $ filepath j) :: String |     journaltitle = printf "%s" (takeFileName $ filepath j) :: String | ||||||
|     journalinfo  = printf "%s" (showspan span) :: String |     journalinfo  = printf "%s" (showspan span) :: String | ||||||
|     showspan (DateSpan Nothing Nothing) = "" |     showspan (DateSpan Nothing Nothing) = "" | ||||||
|     showspan s = " (showing " ++ dateSpanAsText s ++ ")" |     showspan s = " (" ++ dateSpanAsText s ++ ")" | ||||||
|     span = either (const $ DateSpan Nothing Nothing) snd (parsePeriodExpr today p) |     span = either (const $ DateSpan Nothing Nothing) snd (parsePeriodExpr today p) | ||||||
| 
 | 
 | ||||||
| navlinks :: TemplateData -> Hamlet HledgerWebAppRoute | navlinks :: TemplateData -> Hamlet HledgerWebAppRoute | ||||||
| @ -817,11 +811,11 @@ navlinks td = [$hamlet| | |||||||
|   ^accountsregisterlink^ |   ^accountsregisterlink^ | ||||||
|   \ | $ |   \ | $ | ||||||
|   %a#addformlink!href!onclick="return addformToggle()" add transaction |   %a#addformlink!href!onclick="return addformToggle()" add transaction | ||||||
|  |   %a#importformlink!href!onclick="return importformToggle()"!style=display:none; import transactions | ||||||
|   \ | $ |   \ | $ | ||||||
|   %a#editformlink!href!onclick="return editformToggle()" edit journal |   %a#editformlink!href!onclick="return editformToggle()" edit journal | ||||||
| |] | |] | ||||||
|   -- \ | $ | --  \ | $ | ||||||
|   -- %a#importformlink!href!onclick="return importformToggle()" import transactions |  | ||||||
|  where |  where | ||||||
|    accountsjournallink  = navlink td "journal" AccountsJournalPage |    accountsjournallink  = navlink td "journal" AccountsJournalPage | ||||||
|    accountsregisterlink = navlink td "register" AccountsRegisterPage |    accountsregisterlink = navlink td "register" AccountsRegisterPage | ||||||
| @ -837,28 +831,40 @@ filterform :: TemplateData -> Hamlet HledgerWebAppRoute | |||||||
| filterform TD{here=here,a=a,p=p} = [$hamlet| | filterform TD{here=here,a=a,p=p} = [$hamlet| | ||||||
|  #filterformdiv |  #filterformdiv | ||||||
|   %form#filterform.form!method=GET!style=display:$visible$; |   %form#filterform.form!method=GET!style=display:$visible$; | ||||||
|    %span.$filtering$ |    %table.form | ||||||
|     filter by account/description: |     %tr.$filteringperiodclass$ | ||||||
|     \ $ |      %td | ||||||
|     %input!name=a!size=50!value=$a$ |       filter by period: | ||||||
|     ^ahelp^ |       \ $ | ||||||
|     \ $ |      %td | ||||||
|     in period: |       %input!name=p!size=60!value=$p$ | ||||||
|     \ $ |       ^phelp^ | ||||||
|     %input!name=p!size=25!value=$p$ |       \ $ | ||||||
|     ^phelp^ |      %td!align=right | ||||||
|     \ $ |       ^stopfilteringperiod^ | ||||||
|     %input!type=submit!value=filter $ |     %tr.$filteringclass$ | ||||||
|     \ $ |      %td | ||||||
|     ^stopfiltering^ |       filter by account/description: | ||||||
|  |       \ $ | ||||||
|  |      %td | ||||||
|  |       %input!name=a!size=60!value=$a$ | ||||||
|  |       ^ahelp^ | ||||||
|  |       \ $ | ||||||
|  |       %input!type=submit!value=filter $ | ||||||
|  |       \ $ | ||||||
|  |      %td!align=right | ||||||
|  |       ^stopfiltering^ | ||||||
| |] | |] | ||||||
|  where |  where | ||||||
|   ahelp = helplink "filter-patterns" "?" |   ahelp = helplink "filter-patterns" "?" | ||||||
|   phelp = helplink "period-expressions" "?" |   phelp = helplink "period-expressions" "?" | ||||||
|   (filtering, visible, _, stopfiltering) |   filtering = not $ null a | ||||||
|    | null a && null p = ("", defaultdisplay, [$hamlet|%a#filterformlink!href!onclick="return filterformToggle()" filter...|], nulltemplate) -- [$hamlet|filter by $|]) |   filteringperiod = not $ null p | ||||||
|    | otherwise        = ("filtering", defaultdisplay, [$hamlet|filtering...|], [$hamlet|%a#stopfilterlink!href=@here@ stop filtering|]) |   visible = "block" | ||||||
|   defaultdisplay = "block" |   filteringclass = if filtering then "filtering" else "" | ||||||
|  |   filteringperiodclass = if filteringperiod then "filtering" else "" | ||||||
|  |   stopfiltering = if filtering then [$hamlet|%a#stopfilterlink!href=@here@ stop filtering acct/desc|] else nulltemplate | ||||||
|  |   stopfilteringperiod = if filteringperiod then [$hamlet|%a#stopfilterlink!href=@here@ stop filtering period|] else nulltemplate | ||||||
| 
 | 
 | ||||||
| helplink :: String -> String -> Hamlet HledgerWebAppRoute | helplink :: String -> String -> Hamlet HledgerWebAppRoute | ||||||
| helplink topic label = [$hamlet|%a!href=$u$!target=hledgerhelp $label$|] | helplink topic label = [$hamlet|%a!href=$u$!target=hledgerhelp $label$|] | ||||||
|  | |||||||
| @ -80,3 +80,4 @@ table.registerreport        { border-spacing:0; } | |||||||
| #addform #addbuttonrow      { text-align:right; } | #addform #addbuttonrow      { text-align:right; } | ||||||
| /* #editform                   { width:95%; } */ | /* #editform                   { width:95%; } */ | ||||||
| #editform textarea          { width:100%; background-color:#eee; padding:4px; } | #editform textarea          { width:100%; background-color:#eee; padding:4px; } | ||||||
|  | #filterform table           { border-spacing:0; padding-left:1em; } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user