From 884f64e2922985978bec505ddf0cfb5650cc86ba Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 24 May 2014 08:23:02 -0700 Subject: [PATCH] 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. --- hledger-web/Handler/Common.hs | 54 +++++++++++++++----------------- hledger-web/Handler/JournalR.hs | 4 +-- hledger-web/Handler/RegisterR.hs | 2 +- hledger-web/Handler/RootR.hs | 2 +- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/hledger-web/Handler/Common.hs b/hledger-web/Handler/Common.hs index 32816ee61..fbd9160d7 100644 --- a/hledger-web/Handler/Common.hs +++ b/hledger-web/Handler/Common.hs @@ -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{..} = Add a transaction..

- Journal - -   - raw -   - - edit - -

- Register + All accounts ^{accounts} @@ -404,8 +396,13 @@ $forall p' <- tpostings t -  #{elideRight 40 $ paccount p'} +  #{elideRight 40 $ paccount p'} #{mixedAmountAsHtml $ pamount p'} + +   + + + |] where evenodd = if even n then "even" else "odd" :: String @@ -433,37 +430,39 @@ registerItemsHtml _ vd (balancelabel,items) = [hamlet| To/From Account(s) - Amount - #{balancelabel} + $if inacct + Amount + #{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| + #{date} #{elideRight 30 desc} - - \#{elideRight 40 acct} -   - - [+] - - $if showamt - \#{mixedAmountAsHtml amt} - #{mixedAmountAsHtml bal} -$forall p' <- tpostings t - + \#{elideRight 40 acct} + $if inacct + + $if showamt + \#{mixedAmountAsHtml amt} + #{mixedAmountAsHtml bal} + $else + $forall p' <- tpostings t +  #{elideRight 40 $ paccount p'} - #{mixedAmountAsHtml $ pamount p'} - + #{mixedAmountAsHtml $ pamount p'} + + |] 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. diff --git a/hledger-web/Handler/JournalR.hs b/hledger-web/Handler/JournalR.hs index 7c9276e47..43fe5aab2 100644 --- a/hledger-web/Handler/JournalR.hs +++ b/hledger-web/Handler/JournalR.hs @@ -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 diff --git a/hledger-web/Handler/RegisterR.hs b/hledger-web/Handler/RegisterR.hs index 9addca3b2..d8859a44c 100644 --- a/hledger-web/Handler/RegisterR.hs +++ b/hledger-web/Handler/RegisterR.hs @@ -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 diff --git a/hledger-web/Handler/RootR.hs b/hledger-web/Handler/RootR.hs index 5437efd9e..4c98c9408 100644 --- a/hledger-web/Handler/RootR.hs +++ b/hledger-web/Handler/RootR.hs @@ -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