From d41ddd9729757c1c78c87e62572bfc79eba07266 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 12 Jun 2020 23:12:49 +0200 Subject: [PATCH] Fix bug in dropdown The menu for a multi-dropdown should only show entries that are not already selected (there is no use case to select the same item more than once). --- modules/webapp/src/main/elm/Comp/Dropdown.elm | 6 +++++- modules/webapp/src/main/elm/Comp/ItemDetail.elm | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/webapp/src/main/elm/Comp/Dropdown.elm b/modules/webapp/src/main/elm/Comp/Dropdown.elm index 97e8c775..212d28c1 100644 --- a/modules/webapp/src/main/elm/Comp/Dropdown.elm +++ b/modules/webapp/src/main/elm/Comp/Dropdown.elm @@ -12,6 +12,9 @@ module Comp.Dropdown exposing , view ) +{-| This needs to be rewritten from scratch! +-} + import Data.UiSettings exposing (UiSettings) import Html exposing (..) import Html.Attributes exposing (..) @@ -41,7 +44,8 @@ makeItem model val = { value = val , option = model.makeOption val , visible = True - , selected = False + , selected = + List.any (\i -> i.value == val) model.selected , active = False } diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail.elm b/modules/webapp/src/main/elm/Comp/ItemDetail.elm index 9a65d7af..ffe5c8d2 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail.elm @@ -276,6 +276,7 @@ saveTags flags model = let tags = Comp.Dropdown.getSelected model.tagModel + |> Util.List.distinct |> List.map (\t -> IdName t.id t.name) |> ReferenceList in