web: register page: clip linked accounts to 40 characters

This was the behaviour before adding the links.
This commit is contained in:
Henning Thielemann 2019-06-10 19:33:16 +02:00 committed by Simon Michael
parent adbdbf002c
commit 1fa4419cd1
2 changed files with 30 additions and 3 deletions

View File

@ -34,8 +34,13 @@ getRegisterR = do
acctQuery = fromMaybe Any (inAccountQuery qopts)
acctlink acc = (RegisterR, [("q", accountQuery acc)])
otherTransAccounts =
map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) .
undecorateLinks . elideRightDecorated 40 . decorateLinks .
addCommas . preferReal . otherTransactionAccounts m acctQuery
addCommas xs = zip xs $ tail $ (","<$xs) ++ [T.empty]
addCommas xs =
zip xs $
zip (map (T.unpack . accountSummarisedName . paccount) xs) $
tail $ (", "<$xs) ++ [""]
r@(balancelabel,items) = accountTransactionsReport ropts j m acctQuery
balancelabel' = if isJust (inAccount qopts) then balancelabel else "Total"
defaultLayout $ do
@ -63,6 +68,28 @@ preferReal ps
| otherwise = realps
where realps = filter isReal ps
elideRightDecorated :: Int -> [(Maybe d, Char)] -> [(Maybe d, Char)]
elideRightDecorated width s =
if length s > width
then take (width - 2) s ++ map ((,) Nothing) ".."
else s
undecorateLinks :: [(Maybe acct, char)] -> [(acct, ([char], [char]))]
undecorateLinks [] = []
undecorateLinks xs0@(x:_) =
case x of
(Just acct, _) ->
let (link, xs1) = span (isJust . fst) xs0
(comma, xs2) = span (isNothing . fst) xs1
in (acct, (map snd link, map snd comma)) : undecorateLinks xs2
_ -> error "link name not decorated with account"
decorateLinks :: [(acct, ([char], [char]))] -> [(Maybe acct, char)]
decorateLinks =
concatMap
(\(acct, (name, comma)) ->
map ((,) (Just acct)) name ++ map ((,) Nothing) comma)
-- | Generate javascript/html for a register balance line chart based on
-- the provided "TransactionsReportItem"s.
registerChartHtml :: [(CommoditySymbol, (String, [TransactionsReportItem]))] -> HtmlUrl AppRoute

View File

@ -26,9 +26,9 @@
<td>
#{textElideRight 30 (tdescription tacct)}
<td .account>
$forall (Posting { paccount = acc }, comma) <- otherTransAccounts torig
$forall (Posting { paccount = acc }, (summName,comma)) <- otherTransAccounts torig
<a href="@?{acctlink acc}##{tindex torig}" title="#{acc}">
#{accountSummarisedName acc}</a>#{comma}
#{summName}</a>#{comma}
<td .amount style="text-align:right; white-space:nowrap;">
$if not split || not (isZeroMixedAmount amt)
^{mixedAmountAsHtml amt}