From 70720548c9af024dbb6080638ac8e5470c2213eb Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 25 Jun 2016 15:10:03 +0200 Subject: Use the search to view either punctual or monthly payments --- src/client/elm/Dialog/Model.elm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/client/elm/Dialog/Model.elm (limited to 'src/client/elm/Dialog/Model.elm') 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) -- cgit v1.2.3