From fc9a3ca6a5226f78a3a0ec51af3d8d287ccb2e1b Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 2 Jan 2016 22:45:20 +0100 Subject: Merge deletePayment with deleteMonthlyPayment --- src/client/elm/Model/Action/LoggedInAction.elm | 7 +++---- src/client/elm/Model/Action/MonthlyAction.elm | 4 ++-- src/client/elm/Model/Communication.elm | 6 ++---- src/client/elm/Model/Payment.elm | 3 +++ src/client/elm/Model/View/LoggedIn/AddPayment.elm | 8 +++----- src/client/elm/Model/View/LoggedInView.elm | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src/client/elm/Model') diff --git a/src/client/elm/Model/Action/LoggedInAction.elm b/src/client/elm/Model/Action/LoggedInAction.elm index 00e0a3e..aaf3c7f 100644 --- a/src/client/elm/Model/Action/LoggedInAction.elm +++ b/src/client/elm/Model/Action/LoggedInAction.elm @@ -2,18 +2,17 @@ module Model.Action.LoggedInAction ( LoggedInAction(..) ) where -import Model.Payment exposing (Payments, Payment, PaymentId) +import Model.Payment exposing (Payments, Payment, PaymentId, PaymentFrequency) import Model.Action.MonthlyAction exposing (MonthlyAction) import Model.Action.AccountAction exposing (AccountAction) import Model.Action.AddPaymentAction exposing (AddPaymentAction) -import Model.View.LoggedIn.AddPayment exposing (Frequency) type LoggedInAction = UpdateAdd AddPaymentAction | UpdatePayments Payments - | AddPayment PaymentId String Int Frequency + | AddPayment PaymentId String Int PaymentFrequency + | DeletePayment Payment PaymentFrequency | ToggleEdit PaymentId - | DeletePayment Payment | UpdatePage Int | UpdateMonthly MonthlyAction | UpdateAccount AccountAction diff --git a/src/client/elm/Model/Action/MonthlyAction.elm b/src/client/elm/Model/Action/MonthlyAction.elm index d985ccc..c2de3e5 100644 --- a/src/client/elm/Model/Action/MonthlyAction.elm +++ b/src/client/elm/Model/Action/MonthlyAction.elm @@ -2,9 +2,9 @@ module Model.Action.MonthlyAction ( MonthlyAction(..) ) where -import Model.Payment exposing (Payment, PaymentId) +import Model.Payment exposing (Payment) type MonthlyAction = ToggleDetail | AddPayment Payment - | DeletePayment PaymentId + | DeletePayment Payment diff --git a/src/client/elm/Model/Communication.elm b/src/client/elm/Model/Communication.elm index 616d78f..b8da175 100644 --- a/src/client/elm/Model/Communication.elm +++ b/src/client/elm/Model/Communication.elm @@ -6,12 +6,10 @@ import Time exposing (Time) import Model.User exposing (UserId) import Model.Payment exposing (..) -import Model.View.LoggedIn.AddPayment exposing (Frequency) type Communication = SignIn String - | AddPayment String Int Frequency | SetIncome Time Int - | DeletePayment Payment Int - | DeleteMonthlyPayment PaymentId + | AddPayment String Int PaymentFrequency + | DeletePayment Payment PaymentFrequency | SignOut diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index cabdd43..31aba1d 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -6,6 +6,7 @@ module Model.Payment , paymentsDecoder , paymentIdDecoder , deletePayment + , PaymentFrequency(..) ) where import Date exposing (..) @@ -29,6 +30,8 @@ type alias Payment = type alias PaymentId = Int +type PaymentFrequency = Punctual | Monthly + paymentsDecoder : Json.Decoder Payments paymentsDecoder = Json.list paymentDecoder diff --git a/src/client/elm/Model/View/LoggedIn/AddPayment.elm b/src/client/elm/Model/View/LoggedIn/AddPayment.elm index b70b0c6..fc4d3a0 100644 --- a/src/client/elm/Model/View/LoggedIn/AddPayment.elm +++ b/src/client/elm/Model/View/LoggedIn/AddPayment.elm @@ -1,6 +1,5 @@ module Model.View.LoggedIn.AddPayment ( AddPayment - , Frequency(..) , initAddPayment , validateName , validateCost @@ -11,16 +10,17 @@ import Result as Result exposing (Result(..)) import Utils.Validation exposing (..) import Model.Translations exposing (..) +import Model.Payment exposing (PaymentFrequency(..)) type alias AddPayment = { name : String , nameError : Maybe String , cost : String , costError : Maybe String - , frequency : Frequency + , frequency : PaymentFrequency } -initAddPayment : Frequency -> AddPayment +initAddPayment : PaymentFrequency -> AddPayment initAddPayment frequency = { name = "" , nameError = Nothing @@ -39,5 +39,3 @@ validateCost cost translations = cost |> validateNonEmpty (getMessage "CostRequired" translations) |> flip Result.andThen (validateNumber (getMessage "CostRequired" translations) ((/=) 0)) - -type Frequency = Punctual | Monthly diff --git a/src/client/elm/Model/View/LoggedInView.elm b/src/client/elm/Model/View/LoggedInView.elm index 712ce2d..75285b1 100644 --- a/src/client/elm/Model/View/LoggedInView.elm +++ b/src/client/elm/Model/View/LoggedInView.elm @@ -4,7 +4,7 @@ module Model.View.LoggedInView ) where import Model.User exposing (Users, UserId) -import Model.Payment exposing (Payments) +import Model.Payment exposing (Payments, PaymentFrequency(..)) import Model.Payer exposing (Payers) import Model.View.LoggedIn.AddPayment exposing (..) import Model.View.LoggedIn.Edition exposing (..) -- cgit v1.2.3