Search by tag category via web ui

This commit is contained in:
Eike Kettner
2020-08-06 22:23:35 +02:00
parent 070c2b5e5f
commit a6a6e334d5
3 changed files with 69 additions and 4 deletions

View File

@ -1,8 +1,13 @@
module Util.Tag exposing (makeDropdownModel)
module Util.Tag exposing
( getCategories
, makeCatDropdownModel
, makeDropdownModel
)
import Api.Model.Tag exposing (Tag)
import Comp.Dropdown
import Data.UiSettings
import Util.List
makeDropdownModel : Comp.Dropdown.Model Tag
@ -17,3 +22,20 @@ makeDropdownModel =
"basic " ++ Data.UiSettings.tagColorString tag settings
, placeholder = "Choose a tag"
}
makeCatDropdownModel : Comp.Dropdown.Model String
makeCatDropdownModel =
Comp.Dropdown.makeModel
{ multiple = True
, searchable = \n -> n > 5
, makeOption = \cat -> { value = cat, text = cat, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose a tag category"
}
getCategories : List Tag -> List String
getCategories tags =
List.filterMap .category tags
|> Util.List.distinct