web: Simplify HTML and CSS
This commit is contained in:
		
							parent
							
								
									df425802d4
								
							
						
					
					
						commit
						930b38a345
					
				| @ -29,7 +29,9 @@ getRegisterR = do | |||||||
|       s2 = if m /= Any then ", filtered" else "" |       s2 = if m /= Any then ", filtered" else "" | ||||||
|       header = a <> s1 <> s2 |       header = a <> s1 <> s2 | ||||||
| 
 | 
 | ||||||
|   let r@(balancelabel,items) = accountTransactionsReport (reportopts_ $ cliopts_ opts) j m $ fromMaybe Any $ inAccountQuery qopts |   let ropts = reportopts_ (cliopts_ opts) | ||||||
|  |       acctQuery = fromMaybe Any (inAccountQuery qopts) | ||||||
|  |       r@(balancelabel,items) = accountTransactionsReport ropts j m acctQuery | ||||||
|       balancelabel' = if isJust (inAccount qopts) then balancelabel else "Total" |       balancelabel' = if isJust (inAccount qopts) then balancelabel else "Total" | ||||||
|   defaultLayout $ do |   defaultLayout $ do | ||||||
|     setTitle "register - hledger-web" |     setTitle "register - hledger-web" | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ addModal :: | |||||||
| addModal addR j today = do | addModal addR j today = do | ||||||
|   (addView, addEnctype) <- generateFormPost (addForm j today) |   (addView, addEnctype) <- generateFormPost (addForm j today) | ||||||
|   [whamlet| |   [whamlet| | ||||||
| <div .modal.fade #addmodal tabindex="-1" role="dialog" aria-labelledby="addLabel" aria-hidden="true"> | <div .modal #addmodal tabindex="-1" role="dialog" aria-labelledby="addLabel" aria-hidden="true"> | ||||||
|   <div .modal-dialog .modal-lg> |   <div .modal-dialog .modal-lg> | ||||||
|     <div .modal-content> |     <div .modal-content> | ||||||
|       <div .modal-header> |       <div .modal-header> | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ | |||||||
| {-# LANGUAGE NamedFieldPuns #-} | {-# LANGUAGE NamedFieldPuns #-} | ||||||
| {-# LANGUAGE OverloadedStrings #-} | {-# LANGUAGE OverloadedStrings #-} | ||||||
| {-# LANGUAGE QuasiQuotes #-} | {-# LANGUAGE QuasiQuotes #-} | ||||||
|  | {-# LANGUAGE TemplateHaskell #-} | ||||||
| 
 | 
 | ||||||
| module Widget.Common | module Widget.Common | ||||||
|   ( accountQuery |   ( accountQuery | ||||||
| @ -24,6 +25,7 @@ import Text.Blaze ((!), textValue) | |||||||
| import qualified Text.Blaze.Html5 as H | import qualified Text.Blaze.Html5 as H | ||||||
| import qualified Text.Blaze.Html5.Attributes as A | import qualified Text.Blaze.Html5.Attributes as A | ||||||
| import Text.Blaze.Internal (preEscapedString) | import Text.Blaze.Internal (preEscapedString) | ||||||
|  | import Text.Hamlet (hamletFile) | ||||||
| import Yesod | import Yesod | ||||||
| 
 | 
 | ||||||
| import Hledger | import Hledger | ||||||
| @ -57,39 +59,13 @@ helplink topic label _ = H.a ! A.href u ! A.target "hledgerhelp" $ toHtml label | |||||||
| 
 | 
 | ||||||
| -- | Render a "BalanceReport" as html. | -- | Render a "BalanceReport" as html. | ||||||
| balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r | balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r | ||||||
| balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = [hamlet| | balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = | ||||||
| <tr :here == journalR:.inacct> |   $(hamletFile "templates/balance-report.hamlet") | ||||||
|   <td .top .acct> |   where | ||||||
|     <a href=@{journalR} :here == journalR:.inacct |     l = ledgerFromJournal Any j | ||||||
|        title="Show general journal entries, most recent first"> |     indent a = preEscapedString $ concat $ replicate (2 + 2 * a) " " | ||||||
|       Journal |     hasSubAccounts acct = maybe True (not . null . asubs) (ledgerAccount l acct) | ||||||
|   <td .top> |     matchesAcctSelector acct = Just True == ((`matchesAccount` acct) <$> inAccountQuery qopts) | ||||||
| $forall (acct, adisplay, aindent, abal) <- items |  | ||||||
|   <tr .#{inacctClass acct} :isZeroMixedAmount abal && hideEmpty:.hide> |  | ||||||
|     <td .acct :isZeroMixedAmount abal:.empty> |  | ||||||
|       <div .ff-wrapper> |  | ||||||
|         \#{indent aindent} |  | ||||||
|         <a href="@?{acctLink acct}" .#{inacctClass acct} |  | ||||||
|            title="Show transactions affecting this account and subaccounts"> |  | ||||||
|           #{adisplay} |  | ||||||
|         $if hasSubs acct |  | ||||||
|           <a href="@?{acctOnlyLink acct}" .only .hidden-sm .hidden-xs |  | ||||||
|              title="Show transactions affecting this account but not subaccounts">only |  | ||||||
|     <td> |  | ||||||
|       ^{mixedAmountAsHtml abal} |  | ||||||
| <tr .total> |  | ||||||
|   <td> |  | ||||||
|   <td> |  | ||||||
|     ^{mixedAmountAsHtml total} |  | ||||||
| |] where |  | ||||||
|   l = ledgerFromJournal Any j |  | ||||||
|   inacctClass acct = case inAccountQuery qopts of |  | ||||||
|     Just m' -> if m' `matchesAccount` acct then "inacct" else "" |  | ||||||
|     Nothing -> "" :: Text |  | ||||||
|   hasSubs acct = maybe True (not . null . asubs) (ledgerAccount l acct) |  | ||||||
|   indent a = preEscapedString $ concat $ replicate (2 + 2 * a) " " |  | ||||||
|   acctLink acct = (registerR, [("q", accountQuery acct)]) |  | ||||||
|   acctOnlyLink acct = (registerR, [("q", accountOnlyQuery acct)]) |  | ||||||
| 
 | 
 | ||||||
| accountQuery :: AccountName -> Text | accountQuery :: AccountName -> Text | ||||||
| accountQuery = ("inacct:" <>) .  quoteIfSpaced | accountQuery = ("inacct:" <>) .  quoteIfSpaced | ||||||
|  | |||||||
| @ -39,9 +39,6 @@ | |||||||
|   max-height:300px; |   max-height:300px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .tt-suggestions { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| .tt-suggestion { | .tt-suggestion { | ||||||
|   padding: 3px 20px; |   padding: 3px 20px; | ||||||
|   font-size: 18px; |   font-size: 18px; | ||||||
| @ -51,7 +48,6 @@ | |||||||
| .tt-suggestion.tt-cursor { | .tt-suggestion.tt-cursor { | ||||||
|   color: #fff; |   color: #fff; | ||||||
|   background-color: #0097cf; |   background-color: #0097cf; | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .tt-suggestion p { | .tt-suggestion p { | ||||||
| @ -105,51 +101,37 @@ ul { | |||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu a { | #sidebar-menu .main-menu a { | ||||||
|     display: inline; |     display: inline; | ||||||
| 	  font-size: 16px; |     font-size: 16px; | ||||||
| 	  font-weight: 500; |     font-weight: 500; | ||||||
| 	  color: #2F2F2F; |     color: #2F2F2F; | ||||||
| 	  padding: 4px 20px; |     padding: 4px 20px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu a:hover { | #sidebar-menu .main-menu a:hover { | ||||||
| 	  color: #11427D; |     color: #11427D; | ||||||
| 	  text-decoration: none; |     text-decoration: none; | ||||||
| 	  background-color: transparent; |     background-color: transparent; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu .only{ | #sidebar-menu .main-menu .only { | ||||||
|     visibility: hidden; |     visibility: hidden; | ||||||
|     padding: 1px; |     padding: 1px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu tr:hover > td > div > .only { | #sidebar-menu .main-menu tr:hover .only { | ||||||
|     visibility: visible; |     visibility: visible; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu .only:hover{ | #sidebar-menu .main-menu .inacct, #sidebar-menu .main-menu .inacct .acct-name { | ||||||
|     border-left: none; |  | ||||||
| } |  | ||||||
| #sidebar-menu .main-menu .balance { |  | ||||||
|     float: right; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #sidebar-menu .main-menu .total { |  | ||||||
|     border-left: none; |  | ||||||
|     border-right: none; |  | ||||||
|     border-bottom: none; |  | ||||||
|     border-top: 1px solid black; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #sidebar-menu .main-menu .inacct { |  | ||||||
|     font-weight: bold; |     font-weight: bold; | ||||||
| 	  color: #11427D; |     color: #11427D; | ||||||
|     background-color: #f9f9f9; |     background-color: #f9f9f9; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu .amount { | #sidebar-menu .main-menu .amount { | ||||||
|     float: right; |     float: right; | ||||||
|     overflow-x:auto; |     overflow-x:auto; | ||||||
| 	  font-weight: 500 !important; |     font-weight: 500 !important; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #sidebar-menu .main-menu .acct { | #sidebar-menu .main-menu .acct { | ||||||
| @ -157,7 +139,7 @@ ul { | |||||||
|     vertical-align:bottom; |     vertical-align:bottom; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .transactionsreport .nonhead { | .transactionsreport .posting td { | ||||||
|     border: none !important; |     border: none !important; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -167,7 +167,7 @@ function addformAddPosting() { | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var prevLastRow = $('.amount-input:last'); |   var prevLastRow = $('#addform .account-group:last'); | ||||||
|   prevLastRow.off('keypress'); |   prevLastRow.off('keypress'); | ||||||
| 
 | 
 | ||||||
|   // Clone the currently last row
 |   // Clone the currently last row
 | ||||||
| @ -201,8 +201,8 @@ function addformDeletePosting() { | |||||||
|     || $('.amount-input:last').is(':focus'); |     || $('.amount-input:last').is(':focus'); | ||||||
|   // delete last row
 |   // delete last row
 | ||||||
|   $('#addform .account-group:last').remove(); |   $('#addform .account-group:last').remove(); | ||||||
|   if(focuslost){ |   if (focuslost) { | ||||||
|     focus($('account-input:last')); |     focus($('.account-input:last')); | ||||||
|   } |   } | ||||||
|   // Rebind keypress
 |   // Rebind keypress
 | ||||||
|   $('.amount-input:last').keypress(addformAddPosting); |   $('.amount-input:last').keypress(addformAddPosting); | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ | |||||||
| 
 | 
 | ||||||
| <div .account-postings> | <div .account-postings> | ||||||
|   $forall (n, (acc, amt, accE, amtE)) <- msgs |   $forall (n, (acc, amt, accE, amtE)) <- msgs | ||||||
|     <div .form-group .row .account-group #grp#{n}> |     <div .form-group .row .account-group> | ||||||
|       <div .col-md-8 .col-xs-8 .col-sm-8 :isJust accE:.has-error> |       <div .col-md-8 .col-xs-8 .col-sm-8 :isJust accE:.has-error> | ||||||
|         <input .account-input.form-control.input-lg.typeahead type=text |         <input .account-input.form-control.input-lg.typeahead type=text | ||||||
|           name=account placeholder="Account #{n}" value="#{acc}"> |           name=account placeholder="Account #{n}" value="#{acc}"> | ||||||
| @ -65,6 +65,7 @@ $if length journals > 1 | |||||||
|       $forall p <- journals |       $forall p <- journals | ||||||
|         <option value=#{p}>#{p} |         <option value=#{p}>#{p} | ||||||
| <span .small style="padding-left:2em;"> | <span .small style="padding-left:2em;"> | ||||||
|   Enter a value in the last field for |   Enter a value in the last field for # | ||||||
|     <a href="#" onclick="addformAddPosting(); return false;">more |   <a href="#" onclick="addformAddPosting(); return false;"> | ||||||
|     (or ctrl +, ctrl -) |     more | ||||||
|  |   \ (or ctrl +, ctrl -) | ||||||
|  | |||||||
							
								
								
									
										25
									
								
								hledger-web/templates/balance-report.hamlet
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								hledger-web/templates/balance-report.hamlet
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | <tr :here == journalR:.inacct> | ||||||
|  |   <td .top .acct> | ||||||
|  |     <a href=@{journalR} :here == journalR:.inacct | ||||||
|  |        title="Show general journal entries, most recent first"> | ||||||
|  |       Journal | ||||||
|  |   <td .top> | ||||||
|  | $forall (acct, adisplay, aindent, abal) <- items | ||||||
|  |   <tr | ||||||
|  |      :matchesAcctSelector acct:.inacct | ||||||
|  |      :isZeroMixedAmount abal && hideEmpty:.hide> | ||||||
|  |     <td .acct :isZeroMixedAmount abal:.empty> | ||||||
|  |       <div .ff-wrapper> | ||||||
|  |         \#{indent aindent} | ||||||
|  |         <a.acct-name href="@?{(registerR, [("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 | ||||||
|  |              title="Show transactions affecting this account but not subaccounts">only | ||||||
|  |     <td> | ||||||
|  |       ^{mixedAmountAsHtml abal} | ||||||
|  | <tr .total> | ||||||
|  |   <td> | ||||||
|  |   <td> | ||||||
|  |     ^{mixedAmountAsHtml total} | ||||||
| @ -1,4 +1,6 @@ | |||||||
| <h2 #contenttitle>#{title'} | <h2> | ||||||
|  |   #{title'} | ||||||
|  | 
 | ||||||
| <a #addformlink href="#" role="button" style="cursor:pointer; margin-top:1em;" | <a #addformlink href="#" role="button" style="cursor:pointer; margin-top:1em;" | ||||||
|    data-toggle="modal" data-target="#addmodal" title="Add a new transaction to the journal"> |    data-toggle="modal" data-target="#addmodal" title="Add a new transaction to the journal"> | ||||||
|   Add a transaction |   Add a transaction | ||||||
| @ -13,21 +15,23 @@ | |||||||
| 
 | 
 | ||||||
|     $forall (torig, _, split, _, amt, _) <- items |     $forall (torig, _, split, _, amt, _) <- items | ||||||
|       <tr .title #transaction-#{tindex torig}> |       <tr .title #transaction-#{tindex torig}> | ||||||
|         <td .date nowrap>#{show (tdate torig)} |         <td .date nowrap> | ||||||
|         <td .description colspan=2>#{textElideRight 60 (tdescription torig)} |           #{show (tdate torig)} | ||||||
|  |         <td colspan=2> | ||||||
|  |           #{textElideRight 60 (tdescription torig)} | ||||||
|         <td .amount style="text-align:right;"> |         <td .amount style="text-align:right;"> | ||||||
|           $if not split && not (isZeroMixedAmount amt) |           $if not split && not (isZeroMixedAmount amt) | ||||||
|             \^{mixedAmountAsHtml amt} |             ^{mixedAmountAsHtml amt} | ||||||
| 
 | 
 | ||||||
|       $forall Posting { paccount = acc, pamount = amt } <- tpostings torig |       $forall Posting { paccount = acc, pamount = amt } <- tpostings torig | ||||||
|         <tr .item.posting title="#{show torig}"> |         <tr .posting title="#{show torig}"> | ||||||
|           <td .nonhead> |           <td> | ||||||
|           <td .nonhead> |           <td> | ||||||
|           <td .nonhead> |           <td> | ||||||
|               |               | ||||||
|             <a href="@?{acctlink acc}##{tindex torig}" title="#{acc}"> |             <a href="@?{acctlink acc}##{tindex torig}" title="#{acc}"> | ||||||
|               #{elideAccountName 40 acc} |               #{elideAccountName 40 acc} | ||||||
|           <td .amount .nonhead style="text-align:right;"> |           <td .amount style="text-align:right;"> | ||||||
|             ^{mixedAmountAsHtml amt} |             ^{mixedAmountAsHtml amt} | ||||||
| 
 | 
 | ||||||
| ^{addModal AddR j today} | ^{addModal AddR j today} | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| <h2 #contenttitle> | <h2> | ||||||
|   #{header} |   #{header} | ||||||
| 
 | 
 | ||||||
| <div .hidden-xs> | <div .hidden-xs> | ||||||
| @ -19,15 +19,18 @@ | |||||||
| 
 | 
 | ||||||
|     <tbody> |     <tbody> | ||||||
|       $forall (torig, tacct, split, acct, amt, bal) <- items |       $forall (torig, tacct, split, acct, amt, bal) <- items | ||||||
|         <tr ##{tindex torig} .item title="#{show torig}" style="vertical-align:top;"> |         <tr ##{tindex torig} title="#{show torig}" style="vertical-align:top;"> | ||||||
|           <td .date> |           <td .date> | ||||||
|             <a href="@{JournalR}#transaction-#{tindex torig}"> |             <a href="@{JournalR}#transaction-#{tindex torig}"> | ||||||
|               #{show (tdate tacct)} |               #{show (tdate tacct)} | ||||||
|           <td .description title="#{show torig}">#{textElideRight 30 (tdescription tacct)} |           <td title="#{show torig}"> | ||||||
|           <td .account>#{elideRight 40 acct} |             #{textElideRight 30 (tdescription tacct)} | ||||||
|  |           <td .account> | ||||||
|  |             #{elideRight 40 acct} | ||||||
|           <td .amount style="text-align:right; white-space:nowrap;"> |           <td .amount style="text-align:right; white-space:nowrap;"> | ||||||
|             $if not split || not (isZeroMixedAmount amt) |             $if not split || not (isZeroMixedAmount amt) | ||||||
|               ^{mixedAmountAsHtml amt} |               ^{mixedAmountAsHtml amt} | ||||||
|           <td .balance style="text-align:right;">^{mixedAmountAsHtml bal} |           <td style="text-align:right;"> | ||||||
|  |             ^{mixedAmountAsHtml bal} | ||||||
| 
 | 
 | ||||||
| ^{addModal AddR j today} | ^{addModal AddR j today} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user