aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View/Form.elm
diff options
context:
space:
mode:
authorJoris2016-06-25 22:51:12 +0200
committerJoris2016-06-25 22:51:12 +0200
commit0886d5916ae28e2a0d1d5c70fb81842a6d0dc70f (patch)
tree8016750c80cac177d2bf315b2f59605f3a8f80d3 /src/client/elm/View/Form.elm
parent70720548c9af024dbb6080638ac8e5470c2213eb (diff)
downloadbudget-0886d5916ae28e2a0d1d5c70fb81842a6d0dc70f.tar.gz
budget-0886d5916ae28e2a0d1d5c70fb81842a6d0dc70f.tar.bz2
budget-0886d5916ae28e2a0d1d5c70fb81842a6d0dc70f.zip
Add a remove icon to empty a input text field
Diffstat (limited to 'src/client/elm/View/Form.elm')
-rw-r--r--src/client/elm/View/Form.elm62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/client/elm/View/Form.elm b/src/client/elm/View/Form.elm
index b123db9..9b83bf7 100644
--- a/src/client/elm/View/Form.elm
+++ b/src/client/elm/View/Form.elm
@@ -5,10 +5,15 @@ module View.Form exposing
import Html exposing (..)
import Html.Attributes exposing (..)
+import Html.Events exposing (..)
+
+import FontAwesome
+import View.Color as Color
import Form exposing (Form, FieldState)
import Form.Input as Input
import Form.Error as FormError exposing (Error(..))
+import Form.Field as Field
import Msg exposing (Msg)
@@ -18,8 +23,8 @@ import Model.Translations as Translations exposing (Translations)
import Utils.Maybe exposing (isJust)
-textInput : Translations -> Form String a -> (Html Form.Msg -> Html msg) -> String -> String -> Html msg
-textInput translations form htmlMap formName fieldName =
+textInput : Translations -> Form String a -> String -> String -> Html Form.Msg
+textInput translations form formName fieldName =
let field = Form.getFieldAsString fieldName form
in div
[ classList
@@ -27,22 +32,24 @@ textInput translations form htmlMap formName fieldName =
, ("error", isJust field.liveError)
]
]
- [ htmlMap <|
- Input.textInput
- field
- [ id (formName ++ fieldName)
- , classList [ ("filled", isJust field.value) ]
- ]
+ [ Input.textInput
+ field
+ [ id (formName ++ fieldName)
+ , classList [ ("filled", isJust field.value) ]
+ ]
, label
[ for (formName ++ fieldName) ]
[ text (Translations.getMessage (formName ++ fieldName) translations) ]
+ , button
+ [ onClick (Form.Input fieldName Field.EmptyField) ]
+ [ FontAwesome.times Color.silver 15 ]
, case field.liveError of
Just error -> formError translations error
Nothing -> text ""
]
-radioInputs : Translations -> Form String a -> (Html Form.Msg -> Html msg) -> String -> String -> List String -> Html msg
-radioInputs translations form htmlMap formName radioName fieldNames =
+radioInputs : Translations -> Form String a -> String -> String -> List String -> Html Form.Msg
+radioInputs translations form formName radioName fieldNames =
let field = Form.getFieldAsString radioName form
in div
[ classList
@@ -55,29 +62,28 @@ radioInputs translations form htmlMap formName radioName fieldNames =
[ text (Translations.getMessage (formName ++ radioName) translations) ]
, div
[ class "radioInputs" ]
- (List.map (radioInput translations field htmlMap formName) fieldNames)
+ (List.map (radioInput translations field formName) fieldNames)
, case field.liveError of
Just error -> formError translations error
Nothing -> text ""
]
-radioInput : Translations -> FieldState String String -> (Html Form.Msg -> Html msg) -> String -> String -> Html msg
-radioInput translations field htmlMap formName fieldName =
- htmlMap <|
- div
- [ class "radioInput" ]
- [ Input.radioInput
- field.path
- field
- [ id (formName ++ fieldName)
- , value fieldName
- , checked (field.value == Just fieldName)
- ]
- , label
- [ for (formName ++ fieldName) ]
- [ text (Translations.getMessage (formName ++ fieldName) translations)
- ]
- ]
+radioInput : Translations -> FieldState String String -> String -> String -> Html Form.Msg
+radioInput translations field formName fieldName =
+ div
+ [ class "radioInput" ]
+ [ Input.radioInput
+ field.path
+ field
+ [ id (formName ++ fieldName)
+ , value fieldName
+ , checked (field.value == Just fieldName)
+ ]
+ , label
+ [ for (formName ++ fieldName) ]
+ [ text (Translations.getMessage (formName ++ fieldName) translations)
+ ]
+ ]
formError : Translations -> FormError.Error String -> Html msg
formError translations error =