web: Replace RecordWildCards with NamedFieldPuns, remove unused parameters
This commit is contained in:
		
							parent
							
								
									1d2b3521f6
								
							
						
					
					
						commit
						d760904982
					
				| @ -1,5 +1,5 @@ | |||||||
| {-# OPTIONS_GHC -fno-warn-orphans #-} | {-# OPTIONS_GHC -fno-warn-orphans #-} | ||||||
| {-# LANGUAGE CPP, LambdaCase, MultiParamTypeClasses, NamedFieldPuns, OverloadedStrings, RecordWildCards, QuasiQuotes, TemplateHaskell, TypeFamilies, TypeSynonymInstances, FlexibleInstances #-} | {-# LANGUAGE CPP, LambdaCase, MultiParamTypeClasses, NamedFieldPuns, OverloadedStrings, QuasiQuotes, TemplateHaskell, TypeFamilies, TypeSynonymInstances, FlexibleInstances #-} | ||||||
| -- | Define the web application's foundation, in the usual Yesod style. | -- | Define the web application's foundation, in the usual Yesod style. | ||||||
| --   See a default Yesod app's comments for more details of each part. | --   See a default Yesod app's comments for more details of each part. | ||||||
| 
 | 
 | ||||||
| @ -87,7 +87,7 @@ instance Yesod App where | |||||||
|     defaultLayout widget = do |     defaultLayout widget = do | ||||||
|         master <- getYesod |         master <- getYesod | ||||||
|         lastmsg <- getMessage |         lastmsg <- getMessage | ||||||
|         vd@VD{..} <- getViewData |         VD{j, opts} <- getViewData | ||||||
| 
 | 
 | ||||||
|         -- We break up the default layout into two components: |         -- We break up the default layout into two components: | ||||||
|         -- default-layout is the contents of the body tag, and |         -- default-layout is the contents of the body tag, and | ||||||
| @ -237,8 +237,8 @@ getLastMessage = cached getMessage | |||||||
| -- add form dialog, part of the default template | -- add form dialog, part of the default template | ||||||
| 
 | 
 | ||||||
| -- | Add transaction form. | -- | Add transaction form. | ||||||
| addform :: ViewData -> HtmlUrl AppRoute | addform :: Journal -> HtmlUrl AppRoute | ||||||
| addform VD{..} = [hamlet| | addform j = [hamlet| | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
|   jQuery(document).ready(function() { |   jQuery(document).ready(function() { | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE CPP, FlexibleContexts, OverloadedStrings, QuasiQuotes, RecordWildCards, ScopedTypeVariables, TypeFamilies #-} | {-# LANGUAGE CPP, FlexibleContexts, OverloadedStrings, QuasiQuotes, NamedFieldPuns, ScopedTypeVariables, TypeFamilies #-} | ||||||
| -- | Add form data & handler. (The layout and js are defined in | -- | Add form data & handler. (The layout and js are defined in | ||||||
| -- Foundation so that the add form can be in the default layout for | -- Foundation so that the add form can be in the default layout for | ||||||
| -- all views.) | -- all views.) | ||||||
| @ -47,7 +47,7 @@ addForm today j = AddForm | |||||||
| postAddForm :: Handler Html | postAddForm :: Handler Html | ||||||
| postAddForm = do | postAddForm = do | ||||||
|   -- 1. process the fixed fields with yesod-form |   -- 1. process the fixed fields with yesod-form | ||||||
|   VD{..} <- getViewData |   VD{today, j} <- getViewData | ||||||
|   formresult <- runInputPostResult (addForm today j) |   formresult <- runInputPostResult (addForm today j) | ||||||
| 
 | 
 | ||||||
|   ok <- case formresult of |   ok <- case formresult of | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE CPP, OverloadedStrings, QuasiQuotes, RecordWildCards #-} | {-# LANGUAGE CPP, OverloadedStrings, QuasiQuotes, NamedFieldPuns #-} | ||||||
| -- | Common page components and rendering helpers. | -- | Common page components and rendering helpers. | ||||||
| -- For global page layout, see Application.hs. | -- For global page layout, see Application.hs. | ||||||
| 
 | 
 | ||||||
| @ -44,7 +44,7 @@ hledgerLayout vd title content = do | |||||||
| 
 | 
 | ||||||
| -- | Global toolbar/heading area. | -- | Global toolbar/heading area. | ||||||
| topbar :: ViewData -> HtmlUrl AppRoute | topbar :: ViewData -> HtmlUrl AppRoute | ||||||
| topbar VD{..} = [hamlet| | topbar VD{j, showsidebar} = [hamlet| | ||||||
| <div#spacer .#{showsm} .#{showmd} .col-xs-2> | <div#spacer .#{showsm} .#{showmd} .col-xs-2> | ||||||
|  <h1> |  <h1> | ||||||
|   <button .visible-xs .btn .btn-default type="button" data-toggle="offcanvas"> |   <button .visible-xs .btn .btn-default type="button" data-toggle="offcanvas"> | ||||||
| @ -60,7 +60,7 @@ topbar VD{..} = [hamlet| | |||||||
| 
 | 
 | ||||||
| -- | The sidebar used on most views. | -- | The sidebar used on most views. | ||||||
| sidebar :: ViewData -> HtmlUrl AppRoute | sidebar :: ViewData -> HtmlUrl AppRoute | ||||||
| sidebar vd@VD{..} = | sidebar vd@VD{am, here, j, opts, showsidebar} = | ||||||
|  [hamlet| |  [hamlet| | ||||||
|  <div #sidebar-menu .#{showmd} .#{showsm} .sidebar-offcanvas> |  <div #sidebar-menu .#{showmd} .#{showsm} .sidebar-offcanvas> | ||||||
|   <table .main-menu .table> |   <table .main-menu .table> | ||||||
| @ -99,7 +99,7 @@ sidebar vd@VD{..} = | |||||||
| 
 | 
 | ||||||
| -- | Search form for entering custom queries to filter journal data. | -- | Search form for entering custom queries to filter journal data. | ||||||
| searchform :: ViewData -> HtmlUrl AppRoute | searchform :: ViewData -> HtmlUrl AppRoute | ||||||
| searchform VD{..} = [hamlet| | searchform VD{q, here} = [hamlet| | ||||||
| <div#searchformdiv .row> | <div#searchformdiv .row> | ||||||
|  <form#searchform .form-inline method=GET> |  <form#searchform .form-inline method=GET> | ||||||
|   <div .form-group .col-md-12 .col-sm-12 .col-xs-12> |   <div .form-group .col-md-12 .col-sm-12 .col-xs-12> | ||||||
| @ -174,7 +174,7 @@ helplink topic label = [hamlet| | |||||||
| 
 | 
 | ||||||
| -- | Render a "BalanceReport" as html. | -- | Render a "BalanceReport" as html. | ||||||
| balanceReportAsHtml :: ViewData -> BalanceReport -> HtmlUrl AppRoute | balanceReportAsHtml :: ViewData -> BalanceReport -> HtmlUrl AppRoute | ||||||
| balanceReportAsHtml VD{..} (items, total) = | balanceReportAsHtml VD{j, qopts} (items, total) = | ||||||
|  [hamlet| |  [hamlet| | ||||||
|   $forall i <- items |   $forall i <- items | ||||||
|    ^{itemAsHtml i} |    ^{itemAsHtml i} | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE OverloadedStrings, QuasiQuotes, RecordWildCards #-} | {-# LANGUAGE OverloadedStrings, QuasiQuotes, NamedFieldPuns #-} | ||||||
| -- | /journal handlers. | -- | /journal handlers. | ||||||
| 
 | 
 | ||||||
| module Handler.JournalR where | module Handler.JournalR where | ||||||
| @ -18,7 +18,7 @@ import Hledger.Web.WebOptions | |||||||
| -- | The formatted journal view, with sidebar. | -- | The formatted journal view, with sidebar. | ||||||
| getJournalR :: Handler Html | getJournalR :: Handler Html | ||||||
| getJournalR = do | getJournalR = do | ||||||
|   vd@VD{..} <- getViewData |   vd@VD{j, m, opts, qopts} <- getViewData | ||||||
|   let -- XXX like registerReportAsHtml |   let -- XXX like registerReportAsHtml | ||||||
|       title = case inAccount qopts of |       title = case inAccount qopts of | ||||||
|                 Nothing       -> "General Journal" <> s2 |                 Nothing       -> "General Journal" <> s2 | ||||||
| @ -26,7 +26,7 @@ getJournalR = do | |||||||
|                   where s1 = if inclsubs then "" else " (excluding subaccounts)" |                   where s1 = if inclsubs then "" else " (excluding subaccounts)" | ||||||
|                 where |                 where | ||||||
|                   s2 = if m /= Any then ", filtered" else "" |                   s2 = if m /= Any then ", filtered" else "" | ||||||
|       maincontent = journalTransactionsReportAsHtml vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m |       maincontent = journalTransactionsReportAsHtml $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m | ||||||
|   hledgerLayout vd "journal" [hamlet| |   hledgerLayout vd "journal" [hamlet| | ||||||
|        <div .row> |        <div .row> | ||||||
|         <h2 #contenttitle>#{title} |         <h2 #contenttitle>#{title} | ||||||
| @ -40,8 +40,8 @@ postJournalR :: Handler Html | |||||||
| postJournalR = postAddForm | postJournalR = postAddForm | ||||||
| 
 | 
 | ||||||
| -- | Render a "TransactionsReport" as html for the formatted journal view. | -- | Render a "TransactionsReport" as html for the formatted journal view. | ||||||
| journalTransactionsReportAsHtml :: ViewData -> TransactionsReport -> HtmlUrl AppRoute | journalTransactionsReportAsHtml :: TransactionsReport -> HtmlUrl AppRoute | ||||||
| journalTransactionsReportAsHtml vd (_,items) = [hamlet| | journalTransactionsReportAsHtml (_,items) = [hamlet| | ||||||
| <table .transactionsreport .table .table-condensed> | <table .transactionsreport .table .table-condensed> | ||||||
|  <thead> |  <thead> | ||||||
|   <th .date style="text-align:left;"> |   <th .date style="text-align:left;"> | ||||||
| @ -50,11 +50,11 @@ journalTransactionsReportAsHtml vd (_,items) = [hamlet| | |||||||
|   <th .account style="text-align:left;">Account |   <th .account style="text-align:left;">Account | ||||||
|   <th .amount style="text-align:right;">Amount |   <th .amount style="text-align:right;">Amount | ||||||
|  $forall i <- numberTransactionsReportItems items |  $forall i <- numberTransactionsReportItems items | ||||||
|   ^{itemAsHtml vd i} |   ^{itemAsHtml i} | ||||||
|  |] |  |] | ||||||
|  where |  where | ||||||
|    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute |    itemAsHtml :: (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute | ||||||
|    itemAsHtml VD{..} (_, _, _, _, (torig, _, split, _, amt, _)) = [hamlet| |    itemAsHtml (_, _, _, _, (torig, _, split, _, amt, _)) = [hamlet| | ||||||
| <tr .title #transaction-#{tindex torig}> | <tr .title #transaction-#{tindex torig}> | ||||||
|  <td .date nowrap>#{date} |  <td .date nowrap>#{date} | ||||||
|  <td .description colspan=2>#{textElideRight 60 desc} |  <td .description colspan=2>#{textElideRight 60 desc} | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE OverloadedStrings, QuasiQuotes, RecordWildCards #-} | {-# LANGUAGE OverloadedStrings, QuasiQuotes, NamedFieldPuns #-} | ||||||
| -- | /register handlers. | -- | /register handlers. | ||||||
| 
 | 
 | ||||||
| module Handler.RegisterR where | module Handler.RegisterR where | ||||||
| @ -23,7 +23,7 @@ import Hledger.Web.WebOptions | |||||||
| -- | The main journal/account register view, with accounts sidebar. | -- | The main journal/account register view, with accounts sidebar. | ||||||
| getRegisterR :: Handler Html | getRegisterR :: Handler Html | ||||||
| getRegisterR = do | getRegisterR = do | ||||||
|   vd@VD{..} <- getViewData |   vd@VD{j, m, opts, qopts} <- getViewData | ||||||
|   let title = a <> s1 <> s2 |   let title = a <> s1 <> s2 | ||||||
|         where |         where | ||||||
|           (a,inclsubs) = fromMaybe ("all accounts",True) $ inAccount qopts |           (a,inclsubs) = fromMaybe ("all accounts",True) $ inAccount qopts | ||||||
| @ -46,7 +46,7 @@ registerReportHtml vd r = [hamlet| | |||||||
| 
 | 
 | ||||||
| -- | Generate html for a transaction list from an "TransactionsReport". | -- | Generate html for a transaction list from an "TransactionsReport". | ||||||
| registerItemsHtml :: ViewData -> TransactionsReport -> HtmlUrl AppRoute | registerItemsHtml :: ViewData -> TransactionsReport -> HtmlUrl AppRoute | ||||||
| registerItemsHtml vd (balancelabel,items) = [hamlet| | registerItemsHtml VD{qopts} (balancelabel,items) = [hamlet| | ||||||
| <div .table-responsive> | <div .table-responsive> | ||||||
|  <table.registerreport .table .table-striped .table-condensed> |  <table.registerreport .table .table-striped .table-condensed> | ||||||
|   <thead> |   <thead> | ||||||
| @ -59,14 +59,14 @@ registerItemsHtml vd (balancelabel,items) = [hamlet| | |||||||
|     <th style="text-align:right; white-space:normal;">Amount Out/In |     <th style="text-align:right; white-space:normal;">Amount Out/In | ||||||
|     <th style="text-align:right; white-space:normal;">#{balancelabel'} |     <th style="text-align:right; white-space:normal;">#{balancelabel'} | ||||||
|   $forall i <- numberTransactionsReportItems items |   $forall i <- numberTransactionsReportItems items | ||||||
|    ^{itemAsHtml vd i} |    ^{itemAsHtml i} | ||||||
|  |] |  |] | ||||||
|  where |  where | ||||||
|    insomeacct = isJust $ inAccount $ qopts vd |    insomeacct = isJust $ inAccount qopts | ||||||
|    balancelabel' = if insomeacct then balancelabel else "Total" |    balancelabel' = if insomeacct then balancelabel else "Total" | ||||||
| 
 | 
 | ||||||
|    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute |    itemAsHtml :: (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute | ||||||
|    itemAsHtml VD{..} (n, newd, newm, _, (torig, tacct, split, acct, amt, bal)) = [hamlet| |    itemAsHtml (n, newd, newm, _, (torig, tacct, split, acct, amt, bal)) = [hamlet| | ||||||
| <tr ##{tindex torig} .item.#{evenodd}.#{firstposting}.#{datetransition} title="#{show torig}" style="vertical-align:top;"> | <tr ##{tindex torig} .item.#{evenodd}.#{firstposting}.#{datetransition} title="#{show torig}" style="vertical-align:top;"> | ||||||
|  <td .date> |  <td .date> | ||||||
|   <a href="@{JournalR}#transaction-#{tindex torig}">#{date} |   <a href="@{JournalR}#transaction-#{tindex torig}">#{date} | ||||||
|  | |||||||
| @ -104,4 +104,4 @@ $newline never | |||||||
|                 $maybe m <- lastmsg |                 $maybe m <- lastmsg | ||||||
|                   $if isPrefixOf "Errors" (renderHtml m) |                   $if isPrefixOf "Errors" (renderHtml m) | ||||||
|                     <div #message>#{m} |                     <div #message>#{m} | ||||||
|                 ^{addform vd} |                 ^{addform j} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user