diff options
author | Yorhel <git@yorhel.nl> | 2022-09-26 18:29:02 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2022-09-28 09:35:55 +0200 |
commit | 3ec6f29b4e11d29afd0f72a5dd1ef42fb4f22485 (patch) | |
tree | 0e7edbf6d61f37566f98b25487013625db9df792 /elm | |
parent | 506d4cf432794f521d706d430f78ac47fb394a8b (diff) |
Releases::Edit: Auto-fill VN titles when adding language to release
Diffstat (limited to 'elm')
-rw-r--r-- | elm/ReleaseEdit.elm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/elm/ReleaseEdit.elm b/elm/ReleaseEdit.elm index b994e5ed..ce841e99 100644 --- a/elm/ReleaseEdit.elm +++ b/elm/ReleaseEdit.elm @@ -37,6 +37,7 @@ main = Browser.element type alias Model = { state : Api.State , titles : List GRE.RecvTitles + , vntitles : List GRE.RecvVntitles , olang : String , official : Bool , patch : Bool @@ -82,6 +83,7 @@ init : GRE.Recv -> Model init d = { state = Api.Normal , titles = d.titles + , vntitles = d.vntitles , olang = d.olang , official = d.official , patch = d.patch @@ -232,8 +234,11 @@ update msg model = case msg of Noop -> (model, Cmd.none) TitleAdd s -> - ({ model | titles = model.titles ++ [{ lang = s, title = Nothing, latin = Nothing, mtl = False }], olang = if List.isEmpty model.titles then s else model.olang } - , Task.attempt (always Noop) (Dom.focus ("title_" ++ s))) + let def = List.filter (\e -> e.lang == s) model.vntitles |> List.head + title = Maybe.map (\e -> e.title) def + latin = Maybe.andThen (\e -> e.latin) def + in ({ model | titles = model.titles ++ [{ lang = s, title = title, latin = latin, mtl = False }], olang = if List.isEmpty model.titles then s else model.olang } + , Task.attempt (always Noop) (Dom.focus ("title_" ++ s))) TitleDel i -> ({ model | titles = delidx i model.titles }, Cmd.none) TitleLang i s -> ({ model | titles = modidx i (\e -> { e | lang = s }) model.titles }, Cmd.none) TitleTitle i s -> ({ model | titles = modidx i (\e -> { e | title = if s == "" then Nothing else Just s }) model.titles }, Cmd.none) |