From 0ae7d068263dffbc1cc2dc92c7829dd0037c97e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 15:54:38 +0200 Subject: The user can remove a monthly payment --- src/client/Update/LoggedView/Monthly.elm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/client/Update/LoggedView') 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 + } -- cgit v1.2.3