From f605541cbaaa3c339eef8f345547bcd653d3f721 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 27 Jun 2016 14:36:03 +0200 Subject: Add the edit functionnality on payments --- src/client/elm/Model/Payment.elm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/client/elm/Model') diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index 7e5b37d..b08166e 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -6,7 +6,8 @@ module Model.Payment exposing , Frequency(..) , paymentsDecoder , paymentIdDecoder - , deletePayment + , edit + , delete , totalPayments , punctual , monthly @@ -70,8 +71,11 @@ frequencyDecoder = _ -> Err ("Could not deduce Punctual nor Monthly from " ++ input) ) -deletePayment : PaymentId -> Payments -> Payments -deletePayment paymentId = List.filter (((/=) paymentId) << .id) +edit : Payment -> Payments -> Payments +edit payment payments = payment :: delete payment.id payments + +delete : PaymentId -> Payments -> Payments +delete paymentId = List.filter (((/=) paymentId) << .id) totalPayments : (Payment -> Bool) -> UserId -> Payments -> Int totalPayments paymentFilter userId payments = -- cgit v1.2.3