diff options
author | Joris | 2016-03-30 00:28:55 +0200 |
---|---|---|
committer | Joris | 2016-03-30 00:28:55 +0200 |
commit | baefda5a902a94cedf84cfcd2ae550267e5d932e (patch) | |
tree | 72fa7b4e6c49d025563e3d7cba1ec13af43aa1c2 /src/client/elm/LoggedIn/Home/View | |
parent | 76f8b85eb9f796d6df861a04f702ef5f48630795 (diff) |
Merge punctual and monthly payments in client model
Diffstat (limited to 'src/client/elm/LoggedIn/Home/View')
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Monthly.elm | 10 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Paging.elm | 4 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Table.elm | 1 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/client/elm/LoggedIn/Home/View/Monthly.elm b/src/client/elm/LoggedIn/Home/View/Monthly.elm index 487c05d..c1f3b51 100644 --- a/src/client/elm/LoggedIn/Home/View/Monthly.elm +++ b/src/client/elm/LoggedIn/Home/View/Monthly.elm @@ -15,7 +15,7 @@ import LoggedIn.Home.Model as HomeModel import LoggedIn.Home.View.Price exposing (price) import LoggedIn.Home.View.Expand exposing (..) -import Model.Payment as Payment exposing (Payment) +import Model.Payment as Payment exposing (Payment, monthlyPayments) import Model.Translations exposing (getMessage, getParamMessage) import LoggedData exposing (LoggedData) @@ -26,7 +26,7 @@ import View.Icon exposing (renderIcon) view : LoggedData -> HomeModel.Model -> Html view loggedData homeModel = - if List.length loggedData.monthlyPayments == 0 + if List.length (monthlyPayments loggedData.payments) == 0 then text "" else @@ -44,8 +44,8 @@ view loggedData homeModel = monthlyCount : LoggedData -> HomeModel.Model -> Html monthlyCount loggedData homeModel = - let count = List.length loggedData.monthlyPayments - total = List.sum << List.map .cost <| loggedData.monthlyPayments + let count = List.length (monthlyPayments loggedData.payments) + total = List.sum << List.map .cost <| (monthlyPayments loggedData.payments) key = if count > 1 then "PluralMonthlyCount" else "SingularMonthlyCount" in button [ class "header" @@ -59,7 +59,7 @@ paymentsTable : LoggedData -> HomeModel.Model -> Html paymentsTable loggedData homeModel = div [ class "table" ] - ( loggedData.monthlyPayments + ( (monthlyPayments loggedData.payments) |> List.sortBy (String.toLower << .name) |> List.map (paymentLine loggedData homeModel) ) diff --git a/src/client/elm/LoggedIn/Home/View/Paging.elm b/src/client/elm/LoggedIn/Home/View/Paging.elm index 09a5b62..8433494 100644 --- a/src/client/elm/LoggedIn/Home/View/Paging.elm +++ b/src/client/elm/LoggedIn/Home/View/Paging.elm @@ -15,7 +15,7 @@ import LoggedIn.Home.Model as HomeModel import Action exposing (Action) import LoggedData exposing (LoggedData) -import Model.Payment exposing (Payments, perPage) +import Model.Payment exposing (Payments, perPage, punctualPayments) import View.Icon exposing (renderIcon) @@ -24,7 +24,7 @@ showedPages = 5 paymentsPaging : Address Action -> Payments -> HomeModel.Model -> Html paymentsPaging address payments homeModel = - let maxPage = ceiling (toFloat (List.length payments) / toFloat perPage) + let maxPage = ceiling (toFloat (List.length (punctualPayments payments)) / toFloat perPage) pages = truncatePages homeModel.currentPage [1..maxPage] in if maxPage == 1 then diff --git a/src/client/elm/LoggedIn/Home/View/Table.elm b/src/client/elm/LoggedIn/Home/View/Table.elm index 58f2d0b..c73b428 100644 --- a/src/client/elm/LoggedIn/Home/View/Table.elm +++ b/src/client/elm/LoggedIn/Home/View/Table.elm @@ -46,6 +46,7 @@ headerLine loggedData = paymentLines : LoggedData -> HomeModel.Model -> List Html paymentLines loggedData homeModel = loggedData.payments + |> punctualPayments |> List.sortBy (Date.toTime << .creation) |> List.reverse |> List.drop ((homeModel.currentPage - 1) * perPage) |