diff options
author | Joris | 2016-06-25 15:10:03 +0200 |
---|---|---|
committer | Joris | 2016-06-25 22:09:04 +0200 |
commit | 70720548c9af024dbb6080638ac8e5470c2213eb (patch) | |
tree | a149bd6d8f1448de11ac4b0b41c52bc82052035a /src/client/elm/Dialog/Model.elm | |
parent | 4ce4de89a5400b0d8b9cddaa2922901a081fdaaa (diff) |
Use the search to view either punctual or monthly payments
Diffstat (limited to 'src/client/elm/Dialog/Model.elm')
-rw-r--r-- | src/client/elm/Dialog/Model.elm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client/elm/Dialog/Model.elm b/src/client/elm/Dialog/Model.elm new file mode 100644 index 0000000..9bd6a09 --- /dev/null +++ b/src/client/elm/Dialog/Model.elm @@ -0,0 +1,37 @@ +module Dialog.Model exposing + ( Model + , AddPayment + , init + , addPaymentInitial + ) + +import Form exposing (Form) +import Form.Field as Field exposing (Field) +import Form.Validate as Validate exposing (Validation) + +import Model.Payment as Payment + +type alias Model = + { addPayment : Form String AddPayment + } + +type alias AddPayment = + { name : String + , cost : Int + , frequency : Payment.Frequency + } + +init : Model +init = + { addPayment = Form.initial [] addPaymentValidation + } + +addPaymentInitial : Payment.Frequency -> List (String, Field) +addPaymentInitial frequency = [ ("frequency", Field.Radio (toString frequency)) ] + +addPaymentValidation : Validation String AddPayment +addPaymentValidation = + Validate.form3 AddPayment + (Validate.get "name" (Validate.string `Validate.andThen` (Validate.nonEmpty))) + (Validate.get "cost" (Validate.int `Validate.andThen` (Validate.minInt 1))) + (Validate.get "frequency" Payment.validateFrequency) |