web: reduce ui over-complexity
For now, you can do three things in the web ui: add a transaction, view journal entries, view an account register. Filtering is not quite right yet.
This commit is contained in:
		
							parent
							
								
									adde48a805
								
							
						
					
					
						commit
						884f64e292
					
				| @ -6,6 +6,7 @@ module Handler.Common where | |||||||
| import Import | import Import | ||||||
| 
 | 
 | ||||||
| import Data.List | import Data.List | ||||||
|  | import Data.Maybe | ||||||
| import Data.Text(pack) | import Data.Text(pack) | ||||||
| import Data.Time.Calendar | import Data.Time.Calendar | ||||||
| import System.FilePath (takeFileName) | import System.FilePath (takeFileName) | ||||||
| @ -56,16 +57,7 @@ sidebar vd@VD{..} = | |||||||
|    <a#addformlink href="#" onclick="return addformToggle(event)" title="Add a new transaction to the journal" style="margin-top:1em;">Add a transaction.. |    <a#addformlink href="#" onclick="return addformToggle(event)" title="Add a new transaction to the journal" style="margin-top:1em;">Add a transaction.. | ||||||
| 
 | 
 | ||||||
|   <p style="margin-top:1em;"> |   <p style="margin-top:1em;"> | ||||||
|    <a href=@{JournalR} title="Show general journal entries, most recent first">Journal |    <a href=@{JournalR} title="Show transactions in all accounts, most recent first">All accounts | ||||||
|    <span.hoverlinks> |  | ||||||
|       |  | ||||||
|     <a href=@{JournalEntriesR} title="Show raw journal entries, in file order">raw |  | ||||||
|       |  | ||||||
|     <a#editformlink href="#" onclick="return editformToggle(event)" title="Edit the journal"> |  | ||||||
|      edit |  | ||||||
| 
 |  | ||||||
|   <p style="margin-top:1em;"> |  | ||||||
|    <a href=@{RegisterR} title="Show transactions in all accounts, most recent first">Register |  | ||||||
| 
 | 
 | ||||||
|   <div#accounts style="margin-top:.5em;"> |   <div#accounts style="margin-top:.5em;"> | ||||||
|    ^{accounts} |    ^{accounts} | ||||||
| @ -404,8 +396,13 @@ $forall p' <- tpostings t | |||||||
|   <tr.item.#{evenodd}.posting> |   <tr.item.#{evenodd}.posting> | ||||||
|    <td.date> |    <td.date> | ||||||
|    <td.description> |    <td.description> | ||||||
|    <td.account> <a href="@?{accountUrl here $ paccount p'}" title="Show transactions in #{paccount p'}">#{elideRight 40 $ paccount p'} |    <td.account> #{elideRight 40 $ paccount p'} | ||||||
|    <td.amount style="text-align:right;">#{mixedAmountAsHtml $ pamount p'} |    <td.amount style="text-align:right;">#{mixedAmountAsHtml $ pamount p'} | ||||||
|  | <tr> | ||||||
|  |  <td>  | ||||||
|  |  <td> | ||||||
|  |  <td> | ||||||
|  |  <td> | ||||||
| |] | |] | ||||||
|      where |      where | ||||||
|        evenodd = if even n then "even" else "odd" :: String |        evenodd = if even n then "even" else "odd" :: String | ||||||
| @ -433,37 +430,39 @@ registerItemsHtml _ vd (balancelabel,items) = [hamlet| | |||||||
|   <th.account style="text-align:left;">To/From Account(s) |   <th.account style="text-align:left;">To/From Account(s) | ||||||
|     <!-- \ # |     <!-- \ # | ||||||
|     <a#all-postings-toggle-link.togglelink href="#" title="Toggle all split postings">[+] --> |     <a#all-postings-toggle-link.togglelink href="#" title="Toggle all split postings">[+] --> | ||||||
|  |   $if inacct | ||||||
|    <th.amount style="text-align:right;">Amount |    <th.amount style="text-align:right;">Amount | ||||||
|    <th.balance style="text-align:right;">#{balancelabel} |    <th.balance style="text-align:right;">#{balancelabel} | ||||||
| 
 | 
 | ||||||
|  $forall i <- numberTransactionsReportItems items |  $forall i <- numberTransactionsReportItems items | ||||||
|   ^{itemAsHtml vd i} |   ^{itemAsHtml vd i} | ||||||
|  | 
 | ||||||
|  |] |  |] | ||||||
|  where |  where | ||||||
|    -- inacct = inAccount qopts |    inacct = isJust $ inAccount $ qopts vd | ||||||
|    -- filtering = m /= Any |    -- filtering = m /= Any | ||||||
|    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute |    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute | ||||||
|    itemAsHtml VD{..} (n, newd, newm, _, (t, _, split, acct, amt, bal)) = [hamlet| |    itemAsHtml VD{..} (n, newd, newm, _, (t, _, split, acct, amt, bal)) = [hamlet| | ||||||
|  | 
 | ||||||
| <tr.item.#{evenodd}.#{firstposting}.#{datetransition}> | <tr.item.#{evenodd}.#{firstposting}.#{datetransition}> | ||||||
|  <td.date>#{date} |  <td.date>#{date} | ||||||
|  <td.description title="#{show t}">#{elideRight 30 desc} |  <td.description title="#{show t}">#{elideRight 30 desc} | ||||||
|  <td.account title="#{show t}"> |  <td.account title="#{show t}"> | ||||||
|   <a> |  | ||||||
|   \#{elideRight 40 acct} |   \#{elideRight 40 acct} | ||||||
|     |  $if inacct | ||||||
|   <a.postings-toggle-link.togglelink href="#" title="Toggle all postings"> |  | ||||||
|    [+] |  | ||||||
|   <td.amount style="text-align:right; white-space:nowrap;"> |   <td.amount style="text-align:right; white-space:nowrap;"> | ||||||
|    $if showamt |    $if showamt | ||||||
|     \#{mixedAmountAsHtml amt} |     \#{mixedAmountAsHtml amt} | ||||||
|   <td.balance style="text-align:right;">#{mixedAmountAsHtml bal} |   <td.balance style="text-align:right;">#{mixedAmountAsHtml bal} | ||||||
|  |  $else | ||||||
|   $forall p' <- tpostings t |   $forall p' <- tpostings t | ||||||
|  <tr.item.#{evenodd}.posting style=#{postingsdisplaystyle}> |    <tr.item.#{evenodd}.posting> | ||||||
|    <td.date> |    <td.date> | ||||||
|    <td.description> |    <td.description> | ||||||
|    <td.account> <a href="@?{accountUrl here $ paccount p'}" title="Show transactions in #{paccount p'}">#{elideRight 40 $ paccount p'} |    <td.account> <a href="@?{accountUrl here $ paccount p'}" title="Show transactions in #{paccount p'}">#{elideRight 40 $ paccount p'} | ||||||
|     <td.amount style="text-align:right;">#{mixedAmountAsHtml $ pamount p'} |     <td.amount style="text-align:right;">#{mixedAmountAsHtml $ pamount p'} | ||||||
|     <td.balance style="text-align:right;"> |     <td.balance style="text-align:right;"> | ||||||
|  | 
 | ||||||
| |] | |] | ||||||
|      where |      where | ||||||
|        evenodd = if even n then "even" else "odd" :: String |        evenodd = if even n then "even" else "odd" :: String | ||||||
| @ -473,7 +472,6 @@ $forall p' <- tpostings t | |||||||
|        (firstposting, date, desc) = (False, show $ tdate t, tdescription t) |        (firstposting, date, desc) = (False, show $ tdate t, tdescription t) | ||||||
|        -- acctquery = (here, [("q", pack $ accountQuery acct)]) |        -- acctquery = (here, [("q", pack $ accountQuery acct)]) | ||||||
|        showamt = not split || not (isZeroMixedAmount amt) |        showamt = not split || not (isZeroMixedAmount amt) | ||||||
|        postingsdisplaystyle = if showpostings then "" else "display:none;" :: String |  | ||||||
| 
 | 
 | ||||||
| -- | Generate javascript/html for a register balance line chart based on | -- | Generate javascript/html for a register balance line chart based on | ||||||
| -- the provided "TransactionsReportItem"s. | -- the provided "TransactionsReportItem"s. | ||||||
|  | |||||||
| @ -25,9 +25,9 @@ getJournalR = do | |||||||
|       filtering = m /= Any |       filtering = m /= Any | ||||||
|       -- showlastcolumn = if injournal && not filtering then False else True |       -- showlastcolumn = if injournal && not filtering then False else True | ||||||
|       title = case inacct of |       title = case inacct of | ||||||
|                 Nothing       -> "Journal"++s2 |                 Nothing       -> "General Journal"++s2 | ||||||
|                 Just (a,inclsubs) -> "Transactions in "++a++s1++s2 |                 Just (a,inclsubs) -> "Transactions in "++a++s1++s2 | ||||||
|                                       where s1 = if inclsubs then " (and subaccounts)" else "" |                                       where s1 = if inclsubs then " including subs" else " excluding subs" | ||||||
|                 where |                 where | ||||||
|                   s2 = if filtering then ", filtered" else "" |                   s2 = if filtering then ", filtered" else "" | ||||||
|       maincontent = journalTransactionsReportAsHtml opts vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m |       maincontent = journalTransactionsReportAsHtml opts vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ getRegisterR = do | |||||||
|       title = "Transactions in "++a++s1++s2 |       title = "Transactions in "++a++s1++s2 | ||||||
|                where |                where | ||||||
|                  (a,inclsubs) = fromMaybe ("all accounts",False) $ inAccount qopts |                  (a,inclsubs) = fromMaybe ("all accounts",False) $ inAccount qopts | ||||||
|                  s1 = if inclsubs then " (and subaccounts)" else "" |                  s1 = if inclsubs then " including subs" else " excluding subs" | ||||||
|                  s2 = if filtering then ", filtered" else "" |                  s2 = if filtering then ", filtered" else "" | ||||||
|       maincontent = registerReportHtml opts vd $ accountTransactionsReport (reportopts_ $ cliopts_ opts) j m $ fromMaybe Any $ inAccountQuery qopts |       maincontent = registerReportHtml opts vd $ accountTransactionsReport (reportopts_ $ cliopts_ opts) j m $ fromMaybe Any $ inAccountQuery qopts | ||||||
|   defaultLayout $ do |   defaultLayout $ do | ||||||
|  | |||||||
| @ -5,4 +5,4 @@ module Handler.RootR where | |||||||
| import Import | import Import | ||||||
| 
 | 
 | ||||||
| getRootR :: Handler Html | getRootR :: Handler Html | ||||||
| getRootR = redirect defaultroute where defaultroute = RegisterR | getRootR = redirect defaultroute where defaultroute = JournalR | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user