diff options
author | Joris | 2016-06-26 17:30:03 +0200 |
---|---|---|
committer | Joris | 2016-06-26 17:30:03 +0200 |
commit | 885dfd7708e338a3220c85b7f22a3ac267aad3f7 (patch) | |
tree | ff259354eb9fd97fc0bab2775296830dcced5693 /src/client/elm/Dialog/Model.elm | |
parent | cfade71c343eb29c8873011f5878a39aed8257b2 (diff) |
Add the clone functionality on payments
Diffstat (limited to 'src/client/elm/Dialog/Model.elm')
-rw-r--r-- | src/client/elm/Dialog/Model.elm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/elm/Dialog/Model.elm b/src/client/elm/Dialog/Model.elm index 2ac4591..6256fea 100644 --- a/src/client/elm/Dialog/Model.elm +++ b/src/client/elm/Dialog/Model.elm @@ -3,6 +3,7 @@ module Dialog.Model exposing , AddPayment , init , addPaymentInitial + , clonePaymentInitial ) import Date exposing (Date) @@ -13,7 +14,7 @@ import Form.Field as Field exposing (Field) import Form.Validate as Validate exposing (Validation) import Validation -import Model.Payment as Payment +import Model.Payment as Payment exposing (Payment, Frequency) import Model.Translations exposing (Translations) type alias Model = @@ -24,7 +25,7 @@ type alias AddPayment = { name : String , cost : Int , date : Date - , frequency : Payment.Frequency + , frequency : Frequency } init : Model @@ -32,12 +33,20 @@ init = { addPayment = Form.initial [] addPaymentValidation } -addPaymentInitial : Translations -> Date -> Payment.Frequency -> List (String, Field) +addPaymentInitial : Translations -> Date -> Frequency -> List (String, Field) addPaymentInitial translations date frequency = [ ("date", Field.Text (Date.shortView date translations)) , ("frequency", Field.Radio (toString frequency)) ] +clonePaymentInitial : Translations -> Date -> Payment -> List (String, Field) +clonePaymentInitial translations date payment = + [ ("name", Field.Text payment.name) + , ("cost", Field.Text (toString payment.cost)) + , ("date", Field.Text (Date.shortView date translations)) + , ("frequency", Field.Radio (toString payment.frequency)) + ] + addPaymentValidation : Validation String AddPayment addPaymentValidation = Validate.form4 AddPayment |