aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update/LoggedView
diff options
context:
space:
mode:
authorJoris2015-09-06 15:54:38 +0200
committerJoris2015-09-06 15:54:38 +0200
commit0ae7d068263dffbc1cc2dc92c7829dd0037c97e7 (patch)
treec07d2a2fe22ac7b8a45e71d9bbcb5826922cbae8 /src/client/Update/LoggedView
parente10531ba4e60c8709088798763ae3bae6608f9c9 (diff)
The user can remove a monthly payment
Diffstat (limited to 'src/client/Update/LoggedView')
-rw-r--r--src/client/Update/LoggedView/Monthly.elm16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/client/Update/LoggedView/Monthly.elm b/src/client/Update/LoggedView/Monthly.elm
index 8d02c5e..567025f 100644
--- a/src/client/Update/LoggedView/Monthly.elm
+++ b/src/client/Update/LoggedView/Monthly.elm
@@ -3,17 +3,25 @@ module Update.LoggedView.Monthly
, updateMonthly
) where
-import Model.Payment exposing (Payment)
+import Model.Payment exposing (Payment, PaymentId)
import Model.View.Payment.Monthly exposing (..)
type MonthlyAction =
ToggleDetail
- | AddMonthlyPayment Payment
+ | AddPayment Payment
+ | DeletePayment PaymentId
updateMonthly : MonthlyAction -> Monthly -> Monthly
updateMonthly action monthly =
case action of
ToggleDetail ->
{ monthly | visibleDetail <- not monthly.visibleDetail }
- AddMonthlyPayment payment ->
- { monthly | payments <- payment :: monthly.payments }
+ AddPayment payment ->
+ { monthly
+ | payments <- payment :: monthly.payments
+ , visibleDetail <- True
+ }
+ DeletePayment id ->
+ { monthly
+ | payments <- List.filter (\payment -> payment.id /= id) monthly.payments
+ }