summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-16 15:48:59 +0200
committerYorhel <git@yorhel.nl>2019-10-16 15:49:03 +0200
commitb7ed0a4f7b93707aee0c06b343685569e21fbab7 (patch)
tree9575dbea055346b031dd7401ab485aac0d9c2ea8 /elm
parent678f511619708ba893cb2414eead90cdae685708 (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')
-rw-r--r--elm/Lib/Html.elm8
-rw-r--r--elm/StaffEdit/Main.elm6
2 files changed, 8 insertions, 6 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}$" ]
diff --git a/elm/StaffEdit/Main.elm b/elm/StaffEdit/Main.elm
index f9d1f3da..909cfd82 100644
--- a/elm/StaffEdit/Main.elm
+++ b/elm/StaffEdit/Main.elm
@@ -33,7 +33,7 @@ type alias Model =
, gender : String
, lang : String
, l_site : String
- , l_wikidata : Int
+ , l_wikidata : Maybe Int
, l_twitter : String
, l_anidb : Maybe Int
, l_pixiv : Int
@@ -71,7 +71,7 @@ new =
, gender = "unknown"
, lang = "ja"
, l_site = ""
- , l_wikidata = 0
+ , l_wikidata = Nothing
, l_twitter = ""
, l_anidb = Nothing
, l_pixiv = 0
@@ -110,7 +110,7 @@ type Msg
| Lang String
| Gender String
| Website String
- | LWikidata Int
+ | LWikidata (Maybe Int)
| LTwitter String
| LAnidb String
| LPixiv String