diff options
-rw-r--r-- | CHANGES.md | 11 | ||||
-rw-r--r-- | Hledger/Web/Foundation.hs | 1 | ||||
-rw-r--r-- | Hledger/Web/Handler/JournalR.hs | 2 | ||||
-rw-r--r-- | Hledger/Web/Handler/RegisterR.hs | 18 | ||||
-rw-r--r-- | Hledger/Web/Main.hs | 2 | ||||
-rw-r--r-- | Hledger/Web/Test.hs | 23 | ||||
-rw-r--r-- | Hledger/Web/Widget/AddForm.hs | 4 | ||||
-rw-r--r-- | Hledger/Web/Widget/Common.hs | 8 | ||||
-rw-r--r-- | hledger-web.1 | 22 | ||||
-rw-r--r-- | hledger-web.cabal | 14 | ||||
-rw-r--r-- | hledger-web.info | 50 | ||||
-rw-r--r-- | hledger-web.txt | 87 | ||||
-rw-r--r-- | static/hledger.js | 5 | ||||
-rw-r--r-- | templates/chart.hamlet | 21 | ||||
-rw-r--r-- | templates/register.hamlet | 4 |
15 files changed, 176 insertions, 96 deletions
@@ -1,6 +1,17 @@ User-visible changes in hledger-web. See also the hledger changelog. +# 1.21 2021-03-10 + +- Register: a date range can be selected by dragging over a region on + the chart. (Arnout Engelen, #1471) + +- Add form: the description field's autocompletions now also offer + declared and used payee names. + +- New flags `--man` and `--info` open the man page or info manual. + (See hledger changelog) + # 1.20.4 2021-01-29 - Use hledger 1.20.4. diff --git a/Hledger/Web/Foundation.hs b/Hledger/Web/Foundation.hs index 93ce3bc..577bfa5 100644 --- a/Hledger/Web/Foundation.hs +++ b/Hledger/Web/Foundation.hs @@ -160,6 +160,7 @@ instance Yesod App where addScript $ StaticR js_jquery_cookie_js addScript $ StaticR js_jquery_hotkeys_js addScript $ StaticR js_jquery_flot_min_js + addScript $ StaticR js_jquery_flot_selection_min_js addScript $ StaticR js_jquery_flot_time_min_js addScript $ StaticR js_jquery_flot_tooltip_min_js toWidget [hamlet| \<!--[if lte IE 8]> <script type="text/javascript" src="@{StaticR js_excanvas_min_js}"></script> <![endif]--> |] diff --git a/Hledger/Web/Handler/JournalR.hs b/Hledger/Web/Handler/JournalR.hs index b071388..4e8dd20 100644 --- a/Hledger/Web/Handler/JournalR.hs +++ b/Hledger/Web/Handler/JournalR.hs @@ -27,7 +27,7 @@ getJournalR = do Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)" title' = title <> if m /= Any then ", filtered" else "" acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)]) - (_, items) = transactionsReport (rsOpts . reportspec_ $ cliopts_ opts) j m + items = transactionsReport (rsOpts . reportspec_ $ cliopts_ opts) j m transactionFrag = transactionFragment j defaultLayout $ do diff --git a/Hledger/Web/Handler/RegisterR.hs b/Hledger/Web/Handler/RegisterR.hs index c0a7e9d..192ed96 100644 --- a/Hledger/Web/Handler/RegisterR.hs +++ b/Hledger/Web/Handler/RegisterR.hs @@ -19,7 +19,7 @@ import Hledger.Web.WebOptions import Hledger.Web.Widget.AddForm (addModal) import Hledger.Web.Widget.Common (accountQuery, mixedAmountAsHtml, - transactionFragment, removeInacct, replaceInacct) + transactionFragment, removeDates, removeInacct, replaceInacct) -- | The main journal/account register view, with accounts sidebar. getRegisterR :: Handler Html @@ -44,8 +44,11 @@ getRegisterR = do zip xs $ zip (map (T.unpack . accountSummarisedName . paccount) xs) $ tail $ (", "<$xs) ++ [""] - r@(balancelabel,items) = accountTransactionsReport rspec j m acctQuery - balancelabel' = if isJust (inAccount qopts) then balancelabel else "Total" + items = accountTransactionsReport rspec j m acctQuery + balancelabel + | isJust (inAccount qopts), balancetype_ (rsOpts rspec) == HistoricalBalance = "Historical Total" + | isJust (inAccount qopts) = "Period Total" + | otherwise = "Total" transactionFrag = transactionFragment j defaultLayout $ do setTitle "register - hledger-web" @@ -96,18 +99,17 @@ decorateLinks = -- | Generate javascript/html for a register balance line chart based on -- the provided "TransactionsReportItem"s. -registerChartHtml :: [(CommoditySymbol, (String, [TransactionsReportItem]))] -> HtmlUrl AppRoute -registerChartHtml percommoditytxnreports = $(hamletFile "templates/chart.hamlet") +registerChartHtml :: Text -> String -> [(CommoditySymbol, [TransactionsReportItem])] -> HtmlUrl AppRoute +registerChartHtml q title percommoditytxnreports = $(hamletFile "templates/chart.hamlet") -- have to make sure plot is not called when our container (maincontent) -- is hidden, eg with add form toggled where - charttitle = case maybe "" (fst . snd) $ listToMaybe percommoditytxnreports of - "" -> "" - s -> s <> ":" + charttitle = if null title then "" else title ++ ":" colorForCommodity = fromMaybe 0 . flip lookup commoditiesIndex commoditiesIndex = zip (map fst percommoditytxnreports) [0..] :: [(CommoditySymbol,Int)] simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts shownull c = if null c then " " else c + nodatelink = (RegisterR, [("q", T.unwords $ removeDates q)]) dayToJsTimestamp :: Day -> Integer dayToJsTimestamp d = diff --git a/Hledger/Web/Main.hs b/Hledger/Web/Main.hs index c879019..37a4cbe 100644 --- a/Hledger/Web/Main.hs +++ b/Hledger/Web/Main.hs @@ -54,6 +54,8 @@ hledgerWebMain = do when (debug_ > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show wopts) if | "help" `inRawOpts` rawopts_ -> putStr (showModeUsage webmode) >> exitSuccess + | "info" `inRawOpts` rawopts_ -> runInfoForTopic "hledger-web" Nothing + | "man" `inRawOpts` rawopts_ -> runManForTopic "hledger-web" Nothing | "version" `inRawOpts` rawopts_ -> putStrLn prognameandversion >> exitSuccess | "binary-filename" `inRawOpts` rawopts_ -> putStrLn (binaryfilename progname) | "test" `inRawOpts` rawopts_ -> do diff --git a/Hledger/Web/Test.hs b/Hledger/Web/Test.hs index 3e1368e..6a5e3c5 100644 --- a/Hledger/Web/Test.hs +++ b/Hledger/Web/Test.hs @@ -38,9 +38,12 @@ hledgerWebTest = do } } - -- https://hackage.haskell.org/package/yesod-test-1.6.10/docs/Yesod-Test.html -- http://hspec.github.io/writing-specs.html - -- + -- https://hackage.haskell.org/package/yesod-test-1.6.10/docs/Yesod-Test.html + -- "The best way to see an example project using yesod-test is to create a scaffolded Yesod project: + -- stack new projectname yesodweb/sqlite + -- (See https://github.com/commercialhaskell/stack-templates/wiki#yesod for the full list of Yesod templates)" + -- Since these tests use makeFoundation, the startup code in Hledger.Web.Main is not tested. XXX -- -- Be aware that unusual combinations of opts/files here could cause problems, @@ -60,6 +63,22 @@ hledgerWebTest = do statusIs 200 bodyContains "accounts" + -- WIP + -- yit "shows the add form" $ do + -- get JournalR + -- -- printBody + -- -- let addbutton = "button:contains('add')" + -- -- bodyContains addbutton + -- -- htmlAnyContain "button:visible" "add" + -- printMatches "div#addmodal:visible" + -- htmlCount "div#addmodal:visible" 0 + + -- -- clickOn "a#addformlink" + -- -- printBody + -- -- bodyContains addbutton + + -- yit "can add transactions" $ do + -- test with forecasted transactions d <- getCurrentDay let diff --git a/Hledger/Web/Widget/AddForm.hs b/Hledger/Web/Widget/AddForm.hs index bc9138c..d7e50f5 100644 --- a/Hledger/Web/Widget/AddForm.hs +++ b/Hledger/Web/Widget/AddForm.hs @@ -14,7 +14,6 @@ module Hledger.Web.Widget.AddForm import Control.Monad.State.Strict (evalStateT) import Data.Bifunctor (first) import Data.List (dropWhileEnd, intercalate, unfoldr) -import Data.List.Extra (nubSort) import Data.Maybe (isJust) #if !(MIN_VERSION_base(4,13,0)) import Data.Semigroup ((<>)) @@ -28,6 +27,7 @@ import Yesod import Hledger import Hledger.Web.Settings (widgetFile) +import Data.List.Extra (nubSort) addModal :: ( MonadWidget m @@ -72,7 +72,7 @@ addForm j today = identifyForm "add" $ \extra -> do let (postRes, displayRows) = validatePostings acctRes amtRes -- bindings used in add-form.hamlet - let descriptions = nubSort $ tdescription <$> jtxns j + let descriptions = nubSort $ journalPayeesDeclaredOrUsed j ++ journalDescriptions j journals = fst <$> jfiles j pure (validateTransaction dateRes descRes postRes, $(widgetFile "add-form")) diff --git a/Hledger/Web/Widget/Common.hs b/Hledger/Web/Widget/Common.hs index 34ecff7..8b28994 100644 --- a/Hledger/Web/Widget/Common.hs +++ b/Hledger/Web/Widget/Common.hs @@ -15,6 +15,7 @@ module Hledger.Web.Widget.Common , writeJournalTextIfValidAndChanged , journalFile404 , transactionFragment + , removeDates , removeInacct , replaceInacct ) where @@ -120,6 +121,13 @@ transactionFragment j Transaction{tindex, tsourcepos} = -- or 0 if this txn has no known file (eg a forecasted txn) tfileindex = maybe 0 (+1) $ elemIndex (sourceFilePath tsourcepos) (journalFilePaths j) +removeDates :: Text -> [Text] +removeDates = + map quoteIfSpaced . + filter (\term -> + not $ T.isPrefixOf "date:" term || T.isPrefixOf "date2:" term) . + Query.words'' Query.prefixes + removeInacct :: Text -> [Text] removeInacct = map quoteIfSpaced . diff --git a/hledger-web.1 b/hledger-web.1 index 2d4e762..a256479 100644 --- a/hledger-web.1 +++ b/hledger-web.1 @@ -1,11 +1,12 @@ -.TH "HLEDGER-WEB" "1" "December 2020" "hledger-web-1.20.4 " "hledger User Manuals" +.TH "HLEDGER-WEB" "1" "December 2020" "hledger-web-1.21 " "hledger User Manuals" .SH NAME .PP -A web interface (WUI) for the hledger accounting tool. +hledger-web is a web interface (WUI) for the hledger accounting tool. +This manual is for hledger-web 1.21. .SH SYNOPSIS .PP \f[C]hledger-web [OPTIONS]\f[R] @@ -183,8 +184,9 @@ convert amounts to their market value in commodity COMM \f[B]\f[CB]--value\f[B]\f[R] convert amounts to cost or market value, more flexibly than -B/-V/-X .TP -\f[B]\f[CB]--infer-value\f[B]\f[R] -with -V/-X/--value, also infer market prices from transactions +\f[B]\f[CB]--infer-market-prices\f[B]\f[R] +use transaction prices (recorded with \[at] or \[at]\[at]) as additional +market prices, as if they were P directives .TP \f[B]\f[CB]--auto\f[B]\f[R] apply automated posting rules to modify transactions. @@ -211,10 +213,16 @@ Some reporting options can also be written as query arguments. hledger help options: .TP \f[B]\f[CB]-h --help\f[B]\f[R] -show general usage (or after COMMAND, command usage) +show general or COMMAND help +.TP +\f[B]\f[CB]--man\f[B]\f[R] +show general or COMMAND user manual with man +.TP +\f[B]\f[CB]--info\f[B]\f[R] +show general or COMMAND user manual with info .TP \f[B]\f[CB]--version\f[B]\f[R] -show version +show general or ADDONCMD version .TP \f[B]\f[CB]--debug[=N]\f[B]\f[R] show debug output (levels 1-9, default: 1) @@ -611,5 +619,3 @@ Released under GNU GPL v3 or later. .SH SEE ALSO hledger(1), hledger\-ui(1), hledger\-web(1), ledger(1) - -hledger_journal(5), hledger_csv(5), hledger_timeclock(5), hledger_timedot(5) diff --git a/hledger-web.cabal b/hledger-web.cabal index 9ca6836..b238044 100644 --- a/hledger-web.cabal +++ b/hledger-web.cabal @@ -4,10 +4,10 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 4d6a3569da376b1fdb1d8a7bbd69b24d6c64f28a67423fb84318b64a36282cbe +-- hash: c793d9fd89a3465f15601f7ef6a3f790ccd62c4f8e5139e54ca0ed071c5e2f35 name: hledger-web -version: 1.20.4 +version: 1.21 synopsis: Web-based user interface for the hledger accounting system description: A simple web-based user interface for the hledger accounting system, providing a more modern UI than the command-line or terminal interfaces. @@ -152,7 +152,7 @@ library hs-source-dirs: ./. ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints - cpp-options: -DVERSION="1.20.4" + cpp-options: -DVERSION="1.21" build-depends: Decimal >=0.5.1 , aeson >=1 @@ -171,8 +171,8 @@ library , extra >=1.6.3 , filepath , hjsmin - , hledger >=1.20.4 && <1.21 - , hledger-lib >=1.20.4 && <1.21 + , hledger >=1.21 && <1.22 + , hledger-lib >=1.21 && <1.22 , hspec , http-client , http-conduit @@ -212,7 +212,7 @@ executable hledger-web hs-source-dirs: app ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints - cpp-options: -DVERSION="1.20.4" + cpp-options: -DVERSION="1.21" build-depends: base , hledger-web @@ -232,7 +232,7 @@ test-suite test hs-source-dirs: test ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints - cpp-options: -DVERSION="1.20.4" + cpp-options: -DVERSION="1.21" build-depends: base , hledger diff --git a/hledger-web.info b/hledger-web.info index dafdd72..bc3e128 100644 --- a/hledger-web.info +++ b/hledger-web.info @@ -7,7 +7,8 @@ File: hledger-web.info, Node: Top, Up: (dir) hledger-web(1) ************** -A web interface (WUI) for the hledger accounting tool. +hledger-web is a web interface (WUI) for the hledger accounting tool. +This manual is for hledger-web 1.21. `hledger-web [OPTIONS]' `hledger web -- [OPTIONS]' @@ -194,8 +195,9 @@ before options, as shown in the synopsis above. convert amounts to cost or market value, more flexibly than -B/-V/-X -`--infer-value' - with -V/-X/-value, also infer market prices from transactions +`--infer-market-prices' + use transaction prices (recorded with @ or @@) as additional market + prices, as if they were P directives `--auto' apply automated posting rules to modify transactions. @@ -220,10 +222,16 @@ the last one takes precedence. hledger help options: `-h --help' - show general usage (or after COMMAND, command usage) + show general or COMMAND help + +`--man' + show general or COMMAND user manual with man + +`--info' + show general or COMMAND user manual with info `--version' - show version + show general or ADDONCMD version `--debug[=N]' show debug output (levels 1-9, default: 1) @@ -599,21 +607,21 @@ awkward. Tag Table: Node: Top84 -Node: OPTIONS1696 -Ref: #options1801 -Node: PERMISSIONS8880 -Ref: #permissions9019 -Node: EDITING UPLOADING DOWNLOADING10231 -Ref: #editing-uploading-downloading10412 -Node: RELOADING11243 -Ref: #reloading11377 -Node: JSON API11809 -Ref: #json-api11923 -Node: ENVIRONMENT17412 -Ref: #environment17528 -Node: FILES18260 -Ref: #files18360 -Node: BUGS18573 -Ref: #bugs18651 +Node: OPTIONS1748 +Ref: #options1853 +Node: PERMISSIONS9104 +Ref: #permissions9243 +Node: EDITING UPLOADING DOWNLOADING10455 +Ref: #editing-uploading-downloading10636 +Node: RELOADING11467 +Ref: #reloading11601 +Node: JSON API12033 +Ref: #json-api12147 +Node: ENVIRONMENT17636 +Ref: #environment17752 +Node: FILES18484 +Ref: #files18584 +Node: BUGS18797 +Ref: #bugs18875 End Tag Table diff --git a/hledger-web.txt b/hledger-web.txt index ea808a4..09881dc 100644 --- a/hledger-web.txt +++ b/hledger-web.txt @@ -4,50 +4,51 @@ HLEDGER-WEB(1) hledger User Manuals HLEDGER-WEB(1) NAME - A web interface (WUI) for the hledger accounting tool. + hledger-web is a web interface (WUI) for the hledger accounting tool. + This manual is for hledger-web 1.21. SYNOPSIS hledger-web [OPTIONS] hledger web -- [OPTIONS] DESCRIPTION - hledger is a reliable, cross-platform set of programs for tracking - money, time, or any other commodity, using double-entry accounting and - a simple, editable file format. hledger is inspired by and largely + hledger is a reliable, cross-platform set of programs for tracking + money, time, or any other commodity, using double-entry accounting and + a simple, editable file format. hledger is inspired by and largely compatible with ledger(1). - hledger-web is hledger's web interface. It starts a simple web appli- + hledger-web is hledger's web interface. It starts a simple web appli- cation for browsing and adding transactions, and optionally opens it in - a web browser window if possible. It provides a more user-friendly UI - than the hledger CLI or hledger-ui interface, showing more at once - (accounts, the current account register, balance charts) and allowing + a web browser window if possible. It provides a more user-friendly UI + than the hledger CLI or hledger-ui interface, showing more at once + (accounts, the current account register, balance charts) and allowing history-aware data entry, interactive searching, and bookmarking. - hledger-web also lets you share a ledger with multiple users, or even - the public web. There is no access control, so if you need that you - should put it behind a suitable web proxy. As a small protection - against data loss when running an unprotected instance, it writes a + hledger-web also lets you share a ledger with multiple users, or even + the public web. There is no access control, so if you need that you + should put it behind a suitable web proxy. As a small protection + against data loss when running an unprotected instance, it writes a numbered backup of the main journal file (only ?) on every edit. - Like hledger, it reads data from one or more files in hledger journal, - timeclock, timedot, or CSV format specified with -f, or $LEDGER_FILE, - or $HOME/.hledger.journal (on windows, perhaps - C:/Users/USER/.hledger.journal). For more about this see hledger(1), + Like hledger, it reads data from one or more files in hledger journal, + timeclock, timedot, or CSV format specified with -f, or $LEDGER_FILE, + or $HOME/.hledger.journal (on windows, perhaps + C:/Users/USER/.hledger.journal). For more about this see hledger(1), hledger_journal(5) etc. OPTIONS Command-line options and arguments may be used to set an initial filter - on the data. These filter options are not shown in the web UI, but it + on the data. These filter options are not shown in the web UI, but it will be applied in addition to any search query entered there. - Note: if invoking hledger-web as a hledger subcommand, write -- before + Note: if invoking hledger-web as a hledger subcommand, write -- before options, as shown in the synopsis above. --serve serve and log requests, don't browse or auto-exit --serve-api - like --serve, but serve only the JSON web API, without the + like --serve, but serve only the JSON web API, without the server-side web UI --host=IPADDR @@ -57,30 +58,30 @@ OPTIONS listen on this TCP port (default: 5000) --socket=SOCKETFILE - use a unix domain socket file to listen for requests instead of - a TCP socket. Implies --serve. It can only be used if the + use a unix domain socket file to listen for requests instead of + a TCP socket. Implies --serve. It can only be used if the operating system can provide this type of socket. --base-url=URL - set the base url (default: http://IPADDR:PORT). You would + set the base url (default: http://IPADDR:PORT). You would change this when sharing over the network, or integrating within a larger website. --file-url=URL set the static files url (default: BASEURL/static). hledger-web - normally serves static files itself, but if you wanted to serve - them from another server for efficiency, you would set the url + normally serves static files itself, but if you wanted to serve + them from another server for efficiency, you would set the url with this. --capabilities=CAP[,CAP..] - enable the view, add, and/or manage capabilities (default: + enable the view, add, and/or manage capabilities (default: view,add) --capabilities-header=HTTPHEADER - read capabilities to enable from a HTTP header, like X-Sand- + read capabilities to enable from a HTTP header, like X-Sand- storm-Permissions (default: disabled) - --test run hledger-web's tests and exit. hspec test runner args may + --test run hledger-web's tests and exit. hspec test runner args may follow a --, eg: hledger-web --test -- --help hledger input options: @@ -90,7 +91,7 @@ OPTIONS $LEDGER_FILE or $HOME/.hledger.journal) --rules-file=RULESFILE - Conversion rules file to use when reading CSV (default: + Conversion rules file to use when reading CSV (default: FILE.rules) --separator=CHAR @@ -109,7 +110,7 @@ OPTIONS assignments) -s --strict - do extra error checking (check that all posted accounts are + do extra error checking (check that all posted accounts are declared) hledger reporting options: @@ -136,11 +137,11 @@ OPTIONS multiperiod/multicolumn report by year -p --period=PERIODEXP - set start date, end date, and/or reporting interval all at once + set start date, end date, and/or reporting interval all at once using period expressions syntax --date2 - match the secondary date instead (see command help for other + match the secondary date instead (see command help for other effects) -U --unmarked @@ -159,25 +160,26 @@ OPTIONS hide/aggregate accounts or postings more than NUM levels deep -E --empty - show items with zero amount, normally hidden (and vice-versa in + show items with zero amount, normally hidden (and vice-versa in hledger-ui/hledger-web) -B --cost convert amounts to their cost/selling amount at transaction time -V --market - convert amounts to their market value in default valuation com- + convert amounts to their market value in default valuation com- modities -X --exchange=COMM convert amounts to their market value in commodity COMM --value - convert amounts to cost or market value, more flexibly than + convert amounts to cost or market value, more flexibly than -B/-V/-X - --infer-value - with -V/-X/--value, also infer market prices from transactions + --infer-market-prices + use transaction prices (recorded with @ or @@) as additional + market prices, as if they were P directives --auto apply automated posting rules to modify transactions. @@ -201,10 +203,14 @@ OPTIONS hledger help options: -h --help - show general usage (or after COMMAND, command usage) + show general or COMMAND help + + --man show general or COMMAND user manual with man + + --info show general or COMMAND user manual with info --version - show version + show general or ADDONCMD version --debug[=N] show debug output (levels 1-9, default: 1) @@ -547,9 +553,6 @@ COPYRIGHT SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) - hledger_journal(5), hledger_csv(5), hledger_timeclock(5), hledger_time- - dot(5) - -hledger-web-1.20.4 December 2020 HLEDGER-WEB(1) +hledger-web-1.21 December 2020 HLEDGER-WEB(1) diff --git a/static/hledger.js b/static/hledger.js index bb46868..824de62 100644 --- a/static/hledger.js +++ b/static/hledger.js @@ -58,7 +58,10 @@ function registerChart($container, series) { { /* general chart options */ xaxis: { mode: "time", - timeformat: "%Y/%m/%d" + timeformat: "%Y/%m/%d", + }, + selection: { + mode: "x" }, legend: { position: 'sw' diff --git a/templates/chart.hamlet b/templates/chart.hamlet index 7c32556..02e7ab2 100644 --- a/templates/chart.hamlet +++ b/templates/chart.hamlet @@ -6,7 +6,7 @@ if ($chartdiv.is(':visible')) { \$('#register-chart-label').text('#{charttitle}'); var seriesData = [ - $forall (c,(_,items)) <- percommoditytxnreports + $forall (c,items) <- percommoditytxnreports /* we render each commodity using two series: * one with extra data points added to show a stepped balance line */ { @@ -38,7 +38,7 @@ #{simpleMixedAmountQuantity $ triCommodityBalance c i}, '#{showMixedAmountWithZeroCommodity $ triCommodityAmount c i}', '#{showMixedAmountWithZeroCommodity $ triCommodityBalance c i}', - '#{concat $ intersperse "\\n" $ lines $ showTransaction $ triOrigTransaction i}', + '#{concat $ intersperse "\\n" $ lines $ T.unpack $ showTransaction $ triOrigTransaction i}', #{tindex $ triOrigTransaction i} ], /* [] */ @@ -55,5 +55,22 @@ ] var plot = registerChart($chartdiv, seriesData); \$chartdiv.bind("plotclick", registerChartClick); + plot.setSelection({ xaxis: { from: 500, to: 700 } }); + \$chartdiv.bind("plotselected", function(event, ranges) { + console.log("selected", ranges.xaxis.from, ranges.xaxis.to); + /* Round down for the 'from' day: */ + var from = new Date(ranges.xaxis.from); + /* Round up for the 'to' day: */ + var to = new Date(ranges.xaxis.to + (24 * 60 * 60 * 1000) - 1); + var range = + from.getFullYear() + "/" + (from.getMonth() + 1) + "/" + from.getDate() + "-" + + to.getFullYear() + "/" + (to.getMonth() + 1) + "/" + to.getDate(); + var baselink = "@?{nodatelink}"; + if (baselink.endsWith("?q")) { + document.location = baselink + "=date:" + range; + } else { + document.location = baselink + "%20date:" + range; + } + }); }; }); diff --git a/templates/register.hamlet b/templates/register.hamlet index 0c890c6..fbdc6f0 100644 --- a/templates/register.hamlet +++ b/templates/register.hamlet @@ -2,7 +2,7 @@ #{header} <div .hidden-xs> - ^{registerChartHtml $ transactionsReportByCommodity r} + ^{registerChartHtml q balancelabel $ transactionsReportByCommodity items} <div.table-responsive> <table .table.table-striped.table-condensed> @@ -15,7 +15,7 @@ <th style="text-align:left;">To/From Account(s) <th style="text-align:right; white-space:normal;">Amount Out/In <th style="text-align:right; white-space:normal;"> - #{balancelabel'} + #{balancelabel} <tbody> $forall (torig, tacct, split, _acct, amt, bal) <- items |