mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Extract tag dropdown into a separate component
This commit is contained in:
@ -9,41 +9,14 @@ module Util.Tag exposing
|
||||
( catSettings
|
||||
, getCategories
|
||||
, makeCatDropdownModel
|
||||
, makeDropdownModel
|
||||
, tagSettings
|
||||
)
|
||||
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
import Comp.Dropdown
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.UiSettings
|
||||
import Util.List
|
||||
|
||||
|
||||
makeDropdownModel : Comp.Dropdown.Model Tag
|
||||
makeDropdownModel =
|
||||
let
|
||||
init =
|
||||
Comp.Dropdown.makeModel
|
||||
{ multiple = True
|
||||
, searchable = \n -> n > 0
|
||||
}
|
||||
in
|
||||
{ init | searchWithAdditional = True }
|
||||
|
||||
|
||||
tagSettings : String -> DS.DropdownStyle -> Comp.Dropdown.ViewSettings Tag
|
||||
tagSettings placeholder ds =
|
||||
{ makeOption = \tag -> { text = tag.name, additional = Maybe.withDefault "" tag.category }
|
||||
, labelColor =
|
||||
\tag ->
|
||||
\settings ->
|
||||
Data.UiSettings.tagColorString2 tag settings
|
||||
, placeholder = placeholder
|
||||
, style = ds
|
||||
}
|
||||
|
||||
|
||||
makeCatDropdownModel : Comp.Dropdown.Model String
|
||||
makeCatDropdownModel =
|
||||
Comp.Dropdown.makeModel
|
||||
|
Reference in New Issue
Block a user