aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm
diff options
context:
space:
mode:
authorJoris2016-03-28 18:04:25 +0200
committerJoris2016-03-28 18:04:25 +0200
commitcc58377a48d13ef85cedb5ec0e19eb8b879dd497 (patch)
tree8a400e8e208f9ca7a94a3dad054bdad2b4a04b0f /src/client/elm
parent166cd04e4b28770ede854dafc9ae30eae64102fe (diff)
Compute payment count client side
Diffstat (limited to 'src/client/elm')
-rw-r--r--src/client/elm/LoggedIn/Home/Model.elm6
-rw-r--r--src/client/elm/LoggedIn/Home/Update.elm2
-rw-r--r--src/client/elm/LoggedIn/Home/View/Paging.elm2
-rw-r--r--src/client/elm/Model/Init.elm1
-rw-r--r--src/client/elm/Server.elm1
5 files changed, 3 insertions, 9 deletions
diff --git a/src/client/elm/LoggedIn/Home/Model.elm b/src/client/elm/LoggedIn/Home/Model.elm
index 14ab86c..f8d24f5 100644
--- a/src/client/elm/LoggedIn/Home/Model.elm
+++ b/src/client/elm/LoggedIn/Home/Model.elm
@@ -14,12 +14,11 @@ import LoggedIn.Home.AddPayment.Model as AddPaymentModel
import LoggedIn.Home.Monthly.Model as MonthlyModel
type alias Model =
- { users : Users
- , add : AddPaymentModel.Model
+ { add : AddPaymentModel.Model
, monthly : MonthlyModel.Model
, account : AccountModel.Model
+ , users : Users
, payments : Payments
- , paymentsCount : Int
, paymentEdition : Maybe PaymentId
, currentPage : Int
}
@@ -31,7 +30,6 @@ init initData =
, monthly = MonthlyModel.init initData.monthlyPayments
, account = AccountModel.init initData.me initData.incomes
, payments = initData.payments
- , paymentsCount = initData.paymentsCount
, paymentEdition = Nothing
, currentPage = 1
}
diff --git a/src/client/elm/LoggedIn/Home/Update.elm b/src/client/elm/LoggedIn/Home/Update.elm
index 352c76b..ee0a7c3 100644
--- a/src/client/elm/LoggedIn/Home/Update.elm
+++ b/src/client/elm/LoggedIn/Home/Update.elm
@@ -80,7 +80,6 @@ update model action loggedInModel =
, add = newAdd
, account = loggedInModel.account
, payments = newPayment :: loggedInModel.payments
- , paymentsCount = loggedInModel.paymentsCount + 1
}
, Effects.none
)
@@ -117,7 +116,6 @@ update model action loggedInModel =
( { loggedInModel
| account = loggedInModel.account
, payments = deletePayment payment.id loggedInModel.payments
- , paymentsCount = loggedInModel.paymentsCount - 1
}
, Effects.none
)
diff --git a/src/client/elm/LoggedIn/Home/View/Paging.elm b/src/client/elm/LoggedIn/Home/View/Paging.elm
index 31aa032..9942aa8 100644
--- a/src/client/elm/LoggedIn/Home/View/Paging.elm
+++ b/src/client/elm/LoggedIn/Home/View/Paging.elm
@@ -23,7 +23,7 @@ showedPages = 5
paymentsPaging : Address Action -> HomeModel.Model -> Html
paymentsPaging address homeModel =
- let maxPage = ceiling (toFloat homeModel.paymentsCount / toFloat perPage)
+ let maxPage = ceiling (toFloat (List.length homeModel.payments) / toFloat perPage)
pages = truncatePages homeModel.currentPage [1..maxPage]
in if maxPage == 1
then
diff --git a/src/client/elm/Model/Init.elm b/src/client/elm/Model/Init.elm
index d9dbc36..7028427 100644
--- a/src/client/elm/Model/Init.elm
+++ b/src/client/elm/Model/Init.elm
@@ -11,6 +11,5 @@ type alias Init =
, me : UserId
, payments : Payments
, monthlyPayments : Payments
- , paymentsCount : Int
, incomes : Incomes
}
diff --git a/src/client/elm/Server.elm b/src/client/elm/Server.elm
index b6928de..b4afe20 100644
--- a/src/client/elm/Server.elm
+++ b/src/client/elm/Server.elm
@@ -27,7 +27,6 @@ init =
`Task.andMap` (Http.get ("id" := userIdDecoder) "/api/whoAmI")
`Task.andMap` (Http.get paymentsDecoder "/api/payments")
`Task.andMap` (Http.get paymentsDecoder "/api/monthlyPayments")
- `Task.andMap` (Http.get ("number" := Json.int) "/api/payments/count")
`Task.andMap` (Http.get incomesDecoder "/api/incomes")
signIn : String -> Task Http.Error ()