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 Data.List | ||||
| import Data.Maybe | ||||
| import Data.Text(pack) | ||||
| import Data.Time.Calendar | ||||
| 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.. | ||||
| 
 | ||||
|   <p style="margin-top:1em;"> | ||||
|    <a href=@{JournalR} title="Show general journal entries, most recent first">Journal | ||||
|    <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 | ||||
|    <a href=@{JournalR} title="Show transactions in all accounts, most recent first">All accounts | ||||
| 
 | ||||
|   <div#accounts style="margin-top:.5em;"> | ||||
|    ^{accounts} | ||||
| @ -404,8 +396,13 @@ $forall p' <- tpostings t | ||||
|   <tr.item.#{evenodd}.posting> | ||||
|    <td.date> | ||||
|    <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'} | ||||
| <tr> | ||||
|  <td>  | ||||
|  <td> | ||||
|  <td> | ||||
|  <td> | ||||
| |] | ||||
|      where | ||||
|        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) | ||||
|     <!-- \ # | ||||
|     <a#all-postings-toggle-link.togglelink href="#" title="Toggle all split postings">[+] --> | ||||
|   $if inacct | ||||
|    <th.amount style="text-align:right;">Amount | ||||
|    <th.balance style="text-align:right;">#{balancelabel} | ||||
| 
 | ||||
|  $forall i <- numberTransactionsReportItems items | ||||
|   ^{itemAsHtml vd i} | ||||
| 
 | ||||
|  |] | ||||
|  where | ||||
|    -- inacct = inAccount qopts | ||||
|    inacct = isJust $ inAccount $ qopts vd | ||||
|    -- filtering = m /= Any | ||||
|    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute | ||||
|    itemAsHtml VD{..} (n, newd, newm, _, (t, _, split, acct, amt, bal)) = [hamlet| | ||||
| 
 | ||||
| <tr.item.#{evenodd}.#{firstposting}.#{datetransition}> | ||||
|  <td.date>#{date} | ||||
|  <td.description title="#{show t}">#{elideRight 30 desc} | ||||
|  <td.account title="#{show t}"> | ||||
|   <a> | ||||
|   \#{elideRight 40 acct} | ||||
|     | ||||
|   <a.postings-toggle-link.togglelink href="#" title="Toggle all postings"> | ||||
|    [+] | ||||
|  $if inacct | ||||
|   <td.amount style="text-align:right; white-space:nowrap;"> | ||||
|    $if showamt | ||||
|     \#{mixedAmountAsHtml amt} | ||||
|   <td.balance style="text-align:right;">#{mixedAmountAsHtml bal} | ||||
|  $else | ||||
|   $forall p' <- tpostings t | ||||
|  <tr.item.#{evenodd}.posting style=#{postingsdisplaystyle}> | ||||
|    <tr.item.#{evenodd}.posting> | ||||
|    <td.date> | ||||
|    <td.description> | ||||
|    <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.balance style="text-align:right;"> | ||||
| 
 | ||||
| |] | ||||
|      where | ||||
|        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) | ||||
|        -- acctquery = (here, [("q", pack $ accountQuery acct)]) | ||||
|        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 | ||||
| -- the provided "TransactionsReportItem"s. | ||||
|  | ||||
| @ -25,9 +25,9 @@ getJournalR = do | ||||
|       filtering = m /= Any | ||||
|       -- showlastcolumn = if injournal && not filtering then False else True | ||||
|       title = case inacct of | ||||
|                 Nothing       -> "Journal"++s2 | ||||
|                 Nothing       -> "General Journal"++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 | ||||
|                   s2 = if filtering then ", filtered" else "" | ||||
|       maincontent = journalTransactionsReportAsHtml opts vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m | ||||
|  | ||||
| @ -26,7 +26,7 @@ getRegisterR = do | ||||
|       title = "Transactions in "++a++s1++s2 | ||||
|                where | ||||
|                  (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 "" | ||||
|       maincontent = registerReportHtml opts vd $ accountTransactionsReport (reportopts_ $ cliopts_ opts) j m $ fromMaybe Any $ inAccountQuery qopts | ||||
|   defaultLayout $ do | ||||
|  | ||||
| @ -5,4 +5,4 @@ module Handler.RootR where | ||||
| import Import | ||||
| 
 | ||||
| getRootR :: Handler Html | ||||
| getRootR = redirect defaultroute where defaultroute = RegisterR | ||||
| getRootR = redirect defaultroute where defaultroute = JournalR | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user