mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Refactor Dropdown
This commit is contained in:
@ -37,7 +37,7 @@ mkFolderOption flags allFolders idref =
|
||||
else
|
||||
""
|
||||
in
|
||||
{ value = idref.id, text = idref.name, additional = adds }
|
||||
{ text = idref.name, additional = adds }
|
||||
|
||||
|
||||
isFolderMember : List FolderItem -> Maybe String -> Bool
|
||||
|
20
modules/webapp/src/main/elm/Util/Person.elm
Normal file
20
modules/webapp/src/main/elm/Util/Person.elm
Normal file
@ -0,0 +1,20 @@
|
||||
module Util.Person exposing (mkPersonOption)
|
||||
|
||||
import Api.Model.IdName exposing (IdName)
|
||||
import Api.Model.Person exposing (Person)
|
||||
import Comp.Dropdown
|
||||
import Dict exposing (Dict)
|
||||
import Util.String
|
||||
|
||||
|
||||
mkPersonOption : IdName -> Dict String Person -> Comp.Dropdown.Option
|
||||
mkPersonOption idref personDict =
|
||||
let
|
||||
org =
|
||||
Dict.get idref.id personDict
|
||||
|> Maybe.andThen .organization
|
||||
|> Maybe.map .name
|
||||
|> Maybe.map (Util.String.ellipsis 15)
|
||||
|> Maybe.withDefault ""
|
||||
in
|
||||
Comp.Dropdown.Option idref.name org
|
@ -1,12 +1,14 @@
|
||||
module Util.Tag exposing
|
||||
( getCategories
|
||||
( catSettings
|
||||
, getCategories
|
||||
, makeCatDropdownModel
|
||||
, makeDropdownModel
|
||||
, makeDropdownModel2
|
||||
, tagSettings
|
||||
)
|
||||
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
import Comp.Dropdown
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.UiSettings
|
||||
import Util.List
|
||||
|
||||
@ -16,30 +18,19 @@ makeDropdownModel =
|
||||
Comp.Dropdown.makeModel
|
||||
{ multiple = True
|
||||
, searchable = \n -> n > 0
|
||||
, makeOption = \tag -> { value = tag.id, text = tag.name, additional = "" }
|
||||
, labelColor =
|
||||
\tag ->
|
||||
\settings ->
|
||||
"basic " ++ Data.UiSettings.tagColorString tag settings
|
||||
, placeholder = "Choose a tag…"
|
||||
}
|
||||
|
||||
|
||||
makeDropdownModel2 : Comp.Dropdown.Model Tag
|
||||
makeDropdownModel2 =
|
||||
Comp.Dropdown.makeModel
|
||||
{ multiple = True
|
||||
, searchable = \n -> n > 0
|
||||
, makeOption = \tag -> { value = tag.id, text = tag.name, additional = "" }
|
||||
, labelColor =
|
||||
\tag ->
|
||||
\settings ->
|
||||
Data.UiSettings.tagColorString2 tag settings
|
||||
++ -- legacy colors
|
||||
" basic "
|
||||
++ Data.UiSettings.tagColorString tag settings
|
||||
, placeholder = "Choose a tag…"
|
||||
}
|
||||
tagSettings : DS.DropdownStyle -> Comp.Dropdown.ViewSettings Tag
|
||||
tagSettings ds =
|
||||
{ makeOption = \tag -> { text = tag.name, additional = "" }
|
||||
, labelColor =
|
||||
\tag ->
|
||||
\settings ->
|
||||
Data.UiSettings.tagColorString2 tag settings
|
||||
, placeholder = "Choose a tag…"
|
||||
, style = ds
|
||||
}
|
||||
|
||||
|
||||
makeCatDropdownModel : Comp.Dropdown.Model String
|
||||
@ -47,12 +38,18 @@ makeCatDropdownModel =
|
||||
Comp.Dropdown.makeModel
|
||||
{ multiple = True
|
||||
, searchable = \n -> n > 0
|
||||
, makeOption = \cat -> { value = cat, text = cat, additional = "" }
|
||||
, labelColor = \_ -> \_ -> ""
|
||||
, placeholder = "Choose a tag category…"
|
||||
}
|
||||
|
||||
|
||||
catSettings : DS.DropdownStyle -> Comp.Dropdown.ViewSettings String
|
||||
catSettings ds =
|
||||
{ makeOption = \cat -> { text = cat, additional = "" }
|
||||
, labelColor = \_ -> \_ -> ""
|
||||
, placeholder = "Choose a tag category…"
|
||||
, style = ds
|
||||
}
|
||||
|
||||
|
||||
getCategories : List Tag -> List String
|
||||
getCategories tags =
|
||||
List.filterMap .category tags
|
||||
|
Reference in New Issue
Block a user