summaryrefslogtreecommitdiff
path: root/elm/Lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-05-14 13:07:09 +0200
committerYorhel <git@yorhel.nl>2020-05-14 13:07:09 +0200
commit425de032656e2fd848696f078db261432bc0912e (patch)
tree85d1dba69f7a8cac75eb36c05ebe4729964d9dc0 /elm/Lib
parenta6814eea0cfe2a0bf9db9779e94c3dd398361522 (diff)
Chars::Edit: Add traits editing
Diffstat (limited to 'elm/Lib')
-rw-r--r--elm/Lib/Api.elm1
-rw-r--r--elm/Lib/Autocomplete.elm36
2 files changed, 29 insertions, 8 deletions
diff --git a/elm/Lib/Api.elm b/elm/Lib/Api.elm
index 5dfda6d8..5ba82325 100644
--- a/elm/Lib/Api.elm
+++ b/elm/Lib/Api.elm
@@ -48,6 +48,7 @@ showResponse res =
Releases _ -> unexp
BoardResult _ -> unexp
TagResult _ -> unexp
+ TraitResult _ -> unexp
VNResult _ -> unexp
ProducerResult _ -> unexp
CharResult _ -> unexp
diff --git a/elm/Lib/Autocomplete.elm b/elm/Lib/Autocomplete.elm
index 1b8f2edc..738f6008 100644
--- a/elm/Lib/Autocomplete.elm
+++ b/elm/Lib/Autocomplete.elm
@@ -6,6 +6,7 @@ module Lib.Autocomplete exposing
, Msg
, boardSource
, tagSource
+ , traitSource
, vnSource
, producerSource
, charSource
@@ -31,6 +32,7 @@ import Gen.Types exposing (boardTypes)
import Gen.Api as GApi
import Gen.Boards as GB
import Gen.Tags as GT
+import Gen.Traits as GTR
import Gen.VN as GV
import Gen.Producers as GP
import Gen.Chars as GC
@@ -81,21 +83,39 @@ boardSource =
}
+tagtraitStatus i =
+ case (i.searchable, i.applicable, i.state) of
+ (_, _, 0) -> b [ class "grayedout" ] [ text " (awaiting approval)" ]
+ (_, _, 1) -> b [ class "grayedout" ] [ text " (deleted)" ] -- (not returned by the API for now)
+ (False, False, _) -> b [ class "grayedout" ] [ text " (meta)" ]
+ (True, False, _) -> b [ class "grayedout" ] [ text " (not applicable)" ]
+ (False, True, _) -> b [ class "grayedout" ] [ text " (not searchable)" ]
+ _ -> text ""
+
+
tagSource : SourceConfig m GApi.ApiTagResult
tagSource =
{ source = Endpoint (\s -> GT.send { search = s })
<| \x -> case x of
GApi.TagResult e -> Just e
_ -> Nothing
+ , view = \i -> [ text i.name, tagtraitStatus i ]
+ , key = \i -> String.fromInt i.id
+ }
+
+
+traitSource : SourceConfig m GApi.ApiTraitResult
+traitSource =
+ { source = Endpoint (\s -> GTR.send { search = s })
+ <| \x -> case x of
+ GApi.TraitResult e -> Just e
+ _ -> Nothing
, view = \i ->
- [ text i.name
- , case (i.searchable, i.applicable, i.state) of
- (_, _, 0) -> b [ class "grayedout" ] [ text " (awaiting approval)" ]
- (_, _, 1) -> b [ class "grayedout" ] [ text " (deleted)" ] -- (not returned by the API for now)
- (False, False, _) -> b [ class "grayedout" ] [ text " (meta)" ]
- (True, False, _) -> b [ class "grayedout" ] [ text " (not applicable)" ]
- (False, True, _) -> b [ class "grayedout" ] [ text " (not searchable)" ]
- _ -> text ""
+ [ case i.group_name of
+ Nothing -> text ""
+ Just g -> b [ class "grayedout" ] [ text <| g ++ " / " ]
+ , text i.name
+ , tagtraitStatus i
]
, key = \i -> String.fromInt i.id
}