From ccc121634fec7d7aa3a36564eeab2330e543e970 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 28 Feb 2020 12:53:44 +0100 Subject: v2rw/RelEdit: Add producers relation editing Lots of copy-pasting going on here. Meh. Also added a couple of overdue server-side validations. --- elm/Lib/Api.elm | 1 + elm/Lib/Autocomplete.elm | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'elm/Lib') diff --git a/elm/Lib/Api.elm b/elm/Lib/Api.elm index a7dd18d8..d8cb1315 100644 --- a/elm/Lib/Api.elm +++ b/elm/Lib/Api.elm @@ -46,6 +46,7 @@ showResponse res = BoardResult _ -> unexp TagResult _ -> unexp VNResult _ -> unexp + ProducerResult _ -> unexp expectResponse : (Response -> msg) -> Http.Expect msg diff --git a/elm/Lib/Autocomplete.elm b/elm/Lib/Autocomplete.elm index fa18efc4..0dd0e9fc 100644 --- a/elm/Lib/Autocomplete.elm +++ b/elm/Lib/Autocomplete.elm @@ -7,6 +7,7 @@ module Lib.Autocomplete exposing , boardSource , tagSource , vnSource + , producerSource , init , clear , update @@ -30,6 +31,7 @@ import Gen.Api as GApi import Gen.Boards as GB import Gen.Tags as GT import Gen.VN as GV +import Gen.Producers as GP type alias Config m a = @@ -110,6 +112,19 @@ vnSource = } +producerSource : SourceConfig m GApi.ApiProducerResult +producerSource = + { source = Endpoint (\s -> GP.send { search = s }) + <| \x -> case x of + GApi.ProducerResult e -> Just e + _ -> Nothing + , view = \i -> + [ b [ class "grayedout" ] [ text <| "p" ++ String.fromInt i.id ++ ": " ] + , text i.name ] + , key = \i -> String.fromInt i.id + } + + type alias Model a = { visible : Bool , value : String -- cgit v1.2.3