aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View
diff options
context:
space:
mode:
authorJoris2016-06-23 23:43:23 +0200
committerJoris2016-06-23 23:43:23 +0200
commit4ce4de89a5400b0d8b9cddaa2922901a081fdaaa (patch)
treeb65e9ef809c2ec7608101563eb3378eaeeddf12b /src/client/elm/View
parent36a90770ebeb9bd99e136bfe035fdda5dfabc304 (diff)
Use a dialog to add a payment
Diffstat (limited to 'src/client/elm/View')
-rw-r--r--src/client/elm/View/Form.elm41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/client/elm/View/Form.elm b/src/client/elm/View/Form.elm
index a85ba8a..5471e7d 100644
--- a/src/client/elm/View/Form.elm
+++ b/src/client/elm/View/Form.elm
@@ -1,11 +1,12 @@
module View.Form exposing
( textInput
+ , radioInputs
)
import Html exposing (..)
import Html.Attributes exposing (..)
-import Form exposing (Form)
+import Form exposing (Form, FieldState)
import Form.Input as Input
import Form.Error as FormError exposing (Error(..))
@@ -40,29 +41,41 @@ textInput translations form htmlMap fieldName =
Nothing -> text ""
]
-simpleTextInput : Translations -> Form String a -> (Html Form.Msg -> Html msg) -> String -> Html msg
-simpleTextInput translations form htmlMap fieldName =
- let field = Form.getFieldAsString fieldName form
+radioInputs : Translations -> Form String a -> (Html Form.Msg -> Html msg) -> String -> List String -> Html msg
+radioInputs translations form htmlMap radioName fieldNames =
+ let field = Form.getFieldAsString radioName form
in div
[ classList
- [ ("textInput", True)
+ [ ("radioGroup", True)
, ("error", isJust field.liveError)
]
]
- [ htmlMap <|
- Input.textInput
- field
- [ id fieldName
- , classList [ ("filled", isJust field.value) ]
- ]
- , label
- [ for fieldName ]
- [ text (Translations.getMessage fieldName translations) ]
+ [ div
+ [ class "title" ]
+ [ text (Translations.getMessage radioName translations) ]
+ , div
+ [ class "radioElems" ]
+ (List.map (radioInput translations field htmlMap) fieldNames)
, case field.liveError of
Just error -> formError translations error
Nothing -> text ""
]
+radioInput : Translations -> FieldState String String -> (Html Form.Msg -> Html msg) -> String -> Html msg
+radioInput translations field htmlMap fieldName =
+ label
+ [ for fieldName ]
+ [ htmlMap <|
+ Input.radioInput
+ field.path
+ field
+ [ id fieldName
+ , value fieldName
+ , checked (field.value == Just fieldName)
+ ]
+ , text (Translations.getMessage fieldName translations)
+ ]
+
formError : Translations -> FormError.Error String -> Html msg
formError translations error =
let errorElement error params =