summaryrefslogtreecommitdiff
path: root/elm/Lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-02-28 12:53:44 +0100
committerYorhel <git@yorhel.nl>2020-02-28 12:55:40 +0100
commitccc121634fec7d7aa3a36564eeab2330e543e970 (patch)
treee427f45ceeda01c55260950e2844b22548735586 /elm/Lib
parent03106135b8d4f0c2c0387991133cc3205957d68b (diff)
v2rw/RelEdit: Add producers relation editing
Lots of copy-pasting going on here. Meh. Also added a couple of overdue server-side validations.
Diffstat (limited to 'elm/Lib')
-rw-r--r--elm/Lib/Api.elm1
-rw-r--r--elm/Lib/Autocomplete.elm15
2 files changed, 16 insertions, 0 deletions
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