From 3853811450d4fe801da996eb48825049c3541030 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 16:46:59 +0200 Subject: Renaming PaymentView to LoggedInView --- src/client/Update/LoggedIn/Monthly.elm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/client/Update/LoggedIn/Monthly.elm (limited to 'src/client/Update/LoggedIn/Monthly.elm') diff --git a/src/client/Update/LoggedIn/Monthly.elm b/src/client/Update/LoggedIn/Monthly.elm new file mode 100644 index 0000000..1379323 --- /dev/null +++ b/src/client/Update/LoggedIn/Monthly.elm @@ -0,0 +1,27 @@ +module Update.LoggedIn.Monthly + ( MonthlyAction(..) + , updateMonthly + ) where + +import Model.Payment exposing (Payment, PaymentId) +import Model.View.LoggedIn.Monthly exposing (..) + +type MonthlyAction = + ToggleDetail + | AddPayment Payment + | DeletePayment PaymentId + +updateMonthly : MonthlyAction -> Monthly -> Monthly +updateMonthly action monthly = + case action of + ToggleDetail -> + { monthly | visibleDetail <- not monthly.visibleDetail } + 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