diff options
author | Yorhel <git@yorhel.nl> | 2019-10-16 15:48:59 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-10-16 15:49:03 +0200 |
commit | b7ed0a4f7b93707aee0c06b343685569e21fbab7 (patch) | |
tree | 9575dbea055346b031dd7401ab485aac0d9c2ea8 /elm/Lib | |
parent | 678f511619708ba893cb2414eead90cdae685708 (diff) |
Fix editing of staff entries without Wikidata
And I can't say the wikidata field is all that intuitive to edit. Need
to look at it later...
Diffstat (limited to 'elm/Lib')
-rw-r--r-- | elm/Lib/Html.elm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm index fe67da32..3aae21c7 100644 --- a/elm/Lib/Html.elm +++ b/elm/Lib/Html.elm @@ -113,11 +113,13 @@ inputRadio nam val onch = input ( -- Same as an inputText, but formats/parses an integer as Q### -inputWikidata : String -> Int -> (Int -> m) -> Html m +inputWikidata : String -> Maybe Int -> (Maybe Int -> m) -> Html m inputWikidata nam val onch = inputText nam - (if val == 0 then "" else "Q" ++ String.fromInt val) - (\v -> onch <| if v == "" then 0 else Maybe.withDefault val <| String.toInt <| if String.startsWith "Q" v then String.dropLeft 1 v else v) + (case val of + Nothing -> "" + Just v -> "Q" ++ String.fromInt v) + (\v -> onch <| if v == "" then Nothing else String.toInt <| if String.startsWith "Q" v then String.dropLeft 1 v else v) [ pattern "^Q?[1-9][0-9]{0,8}$" ] |