summaryrefslogtreecommitdiff
path: root/elm/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'elm/Lib')
-rw-r--r--elm/Lib/Api.elm1
-rw-r--r--elm/Lib/Html.elm27
2 files changed, 28 insertions, 0 deletions
diff --git a/elm/Lib/Api.elm b/elm/Lib/Api.elm
index 06072599..4df99fde 100644
--- a/elm/Lib/Api.elm
+++ b/elm/Lib/Api.elm
@@ -40,6 +40,7 @@ showResponse res =
Taken -> "Username already taken, please choose a different name."
DoubleEmail -> "Email address already used for another account."
DoubleIP -> "You can only register one account from the same IP within 24 hours."
+ BadCurPass -> "Current password is invalid."
expectResponse : (Response -> msg) -> Http.Expect msg
diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm
index 41f6e376..fd5ebf5d 100644
--- a/elm/Lib/Html.elm
+++ b/elm/Lib/Html.elm
@@ -13,6 +13,10 @@ onClickN : m -> Attribute m
onClickN action = custom "click" (JD.succeed { message = action, stopPropagation = True, preventDefault = True})
+-- Multi-<br> (ugly but oh, so, convenient)
+br_ : Int -> Html m
+br_ n = if n == 1 then br [] [] else span [] <| List.repeat n <| br [] []
+
-- Submit button with loading indicator and error message display
submitButton : String -> Api.State -> Bool -> Bool -> Html m
submitButton val state valid load = div []
@@ -85,3 +89,26 @@ inputCheck nam val onch = input (
]
++ (if nam == "" then [] else [ id nam, name nam ])
) []
+
+
+-- Generate a form field (table row) with a label. The `label` string can be:
+--
+-- "none" -> To generate a full-width field (colspan=2)
+-- "" -> Empty label
+-- "Some string" -> Text label
+-- "input::String" -> Label that refers to the named input
+--
+-- (Yeah, stringly typed arguments; I wish Elm had typeclasses)
+formField : String -> List (Html m) -> Html m
+formField lbl cont =
+ tr [ class "newfield" ]
+ [ if lbl == "none"
+ then text ""
+ else
+ td [ class "label" ]
+ [ case String.split "::" lbl of
+ [name, txt] -> label [ for name ] [ text txt ]
+ txt -> text <| String.concat txt
+ ]
+ , td (class "field" :: if lbl == "none" then [ colspan 2 ] else []) cont
+ ]