diff options
author | Yorhel <git@yorhel.nl> | 2021-09-26 11:52:59 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-09-26 11:53:06 +0200 |
commit | 381a3932bbeb4e8f4fa2f2f0715a83ae69713ae5 (patch) | |
tree | c3cdeb06103aba817377a2f144df0cdc8d7d1201 /elm | |
parent | cee8da8d20540393c1a4e9c92c08ddc288244afd (diff) |
Display icons in ulist label selector
But don't display them on the ulist itself yet, since that may be
confusing when the widget is added to that listing. Ugh, what a mess.
Diffstat (limited to 'elm')
-rw-r--r-- | elm/Lib/Html.elm | 11 | ||||
-rw-r--r-- | elm/UList/LabelEdit.elm | 13 | ||||
-rw-r--r-- | elm/UList/Widget.elm | 7 |
3 files changed, 23 insertions, 8 deletions
diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm index 3f13dbee..08648d55 100644 --- a/elm/Lib/Html.elm +++ b/elm/Lib/Html.elm @@ -210,3 +210,14 @@ platformIcon l = img [ class "platicon", src <| Ffi.urlStatic ++ "/f/plat/" ++ l releaseTypeIcon : String -> Html m releaseTypeIcon t = abbr [ class ("icons rt"++t), title (Maybe.withDefault "" <| lookup t T.releaseTypes) ] [ text " " ] + +-- Special values: -1 = "add to list", not 1-6 = unknown +-- (Because why use the type system to encode special values?) +ulistIcon : Int -> String -> Html m +ulistIcon n lbl = + let fn = if n == -1 then "add" + else if n >= 1 && n <= 6 then "l" ++ String.fromInt n + else "unknown" + in img [ src (Ffi.urlStatic ++ "/f/list-" ++ fn ++ ".svg") + , class ("liststatus_icon "++fn), title lbl + ] [] diff --git a/elm/UList/LabelEdit.elm b/elm/UList/LabelEdit.elm index f6a60d3b..d1bdc865 100644 --- a/elm/UList/LabelEdit.elm +++ b/elm/UList/LabelEdit.elm @@ -84,21 +84,26 @@ update msg model = view : Model -> String -> Html Msg view model txt = let - str = String.join ", " <| List.filterMap (\l -> if l.id /= 7 && Set.member l.id model.sel then Just l.label else Nothing) model.labels + lbl = List.intersperse (text ", ") <| List.filterMap (\l -> + if l.id /= 7 && Set.member l.id model.sel + then Just <| span [] + [ if l.id <= 6 && txt /= "-" then ulistIcon l.id l.label else text "" + , text (" " ++ l.label) ] + else Nothing) model.labels item l = li [ ] [ linkRadio (Set.member l.id model.tsel) (Toggle l.id True) [ text l.label , text " " - , span [ class "spinner", classList [("invisible", Dict.get l.id model.state /= Just Api.Loading)] ] [] , case Dict.get l.id model.state of + Just Api.Loading -> span [ class "spinner" ] [] Just (Api.Error _) -> b [ class "standout" ] [ text "error" ] -- Need something better - _ -> text "" + _ -> if l.id <= 6 then ulistIcon l.id l.label else text "" ] ] in DD.view model.dd (if List.any (\s -> s == Api.Loading) <| Dict.values model.state then Api.Loading else Api.Normal) - (text <| if str == "" then txt else str) + (if List.isEmpty lbl then text txt else span [] lbl) (\_ -> [ ul [] <| List.map item <| List.filter (\l -> l.id /= 7) model.labels ]) diff --git a/elm/UList/Widget.elm b/elm/UList/Widget.elm index ec4375a5..0b25fd24 100644 --- a/elm/UList/Widget.elm +++ b/elm/UList/Widget.elm @@ -248,15 +248,14 @@ view : Model -> Html Msg view model = let icon () = - let fn = if not model.onlist then "add" + let fn = if not model.onlist then -1 else List.range 1 6 |> List.filter (\n -> Set.member n model.labels.tsel) |> List.maximum - |> Maybe.map (\n -> "l" ++ String.fromInt n) - |> Maybe.withDefault "unknown" + |> Maybe.withDefault 0 lbl = if not model.onlist then "Add to list" else String.join ", " <| List.filterMap (\l -> if Set.member l.id model.labels.tsel && l.id /= 7 then Just l.label else Nothing) model.labels.labels - in img [ src (Ffi.urlStatic ++ "/f/list-" ++ fn ++ ".svg"), class ("ulist-widget-icon liststatus_icon "++fn), title lbl, onClickN (Open True) ] [] + in span [ onClickN (Open True), class "ulist-widget-icon" ] [ ulistIcon fn lbl ] rel r = case Dict.get r.rid model.relNfo of |