Refactor Dropdown

This commit is contained in:
Eike Kettner
2021-04-02 15:54:02 +02:00
parent b9c98c6578
commit 8d15d97857
26 changed files with 493 additions and 504 deletions

View File

@ -51,9 +51,7 @@ emptyModel =
, city = "" , city = ""
, country = , country =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = \c -> { value = c.code, text = c.label, additional = "" } { options = countries
, placeholder = "Select Country"
, options = countries
, selected = Nothing , selected = Nothing
} }
} }
@ -114,6 +112,14 @@ update msg model =
view2 : UiSettings -> Model -> Html Msg view2 : UiSettings -> Model -> Html Msg
view2 settings model = view2 settings model =
let
countryCfg =
{ makeOption = \c -> { text = c.label, additional = "" }
, placeholder = "Select Country"
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
[ div [ div
[ class "mb-2" [ class "mb-2"
@ -178,7 +184,7 @@ view2 settings model =
] ]
, Html.map CountryMsg , Html.map CountryMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle countryCfg
settings settings
model.country model.country
) )

View File

@ -64,16 +64,10 @@ init flags sett =
, itemCount = Just sett.itemCount , itemCount = Just sett.itemCount
, categoryListModel = , categoryListModel =
let let
mkOption s =
{ value = s, text = s, additional = "" }
minit = minit =
Comp.Dropdown.makeModel Comp.Dropdown.makeModel
{ multiple = True { multiple = True
, searchable = \n -> n > 0 , searchable = \n -> n > 0
, makeOption = mkOption
, labelColor = \_ -> \_ -> "grey "
, placeholder = "Choose categories "
} }
lm = lm =
@ -192,6 +186,13 @@ view2 texts settings model =
model.categoryListType model.categoryListType
(Data.ListType.label model.categoryListType) (Data.ListType.label model.categoryListType)
Nothing Nothing
categoryCfg =
{ makeOption = \s -> { text = s, additional = "" }
, labelColor = \_ -> \_ -> "grey "
, placeholder = "Choose categories "
, style = DS.mainStyle
}
in in
div [] div []
[ Markdown.toHtml [ class "px-2 py-2 opacity-75" ] [ Markdown.toHtml [ class "px-2 py-2 opacity-75" ]
@ -213,7 +214,7 @@ view2 texts settings model =
] ]
, Html.map CategoryListMsg , Html.map CategoryListMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle categoryCfg
settings settings
model.categoryListModel model.categoryListModel
) )

View File

@ -51,14 +51,7 @@ init flags settings =
in in
( { langModel = ( { langModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.Language.all
\l ->
{ value = Data.Language.toIso3 l
, text = Data.Language.toName l
, additional = ""
}
, placeholder = ""
, options = Data.Language.all
, selected = Just lang , selected = Just lang
} }
, intEnabled = settings.integrationEnabled , intEnabled = settings.integrationEnabled
@ -203,6 +196,18 @@ update flags msg model =
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
view2 flags texts settings model = view2 flags texts settings model =
let
languageCfg =
{ makeOption =
\l ->
{ text = Data.Language.toName l
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div div
[ classList [ classList
[ ( "ui form error success", True ) [ ( "ui form error success", True )
@ -237,7 +242,7 @@ view2 flags texts settings model =
] ]
, Html.map LangDropdownMsg , Html.map LangDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle languageCfg
settings settings
model.langModel model.langModel
) )

View File

@ -2,6 +2,7 @@ module Comp.Dropdown exposing
( Model ( Model
, Msg(..) , Msg(..)
, Option , Option
, ViewSettings
, getSelected , getSelected
, isDropdownChangeMsg , isDropdownChangeMsg
, makeModel , makeModel
@ -10,16 +11,13 @@ module Comp.Dropdown exposing
, makeSingleList , makeSingleList
, mkOption , mkOption
, notSelected , notSelected
, orgDropdown , orgFormViewSettings
, setMkOption , setMkOption
, update , update
, view2 , view2
, viewSingle2 , viewSingle2
) )
{-| This needs to be rewritten from scratch!
-}
import Api.Model.IdName exposing (IdName) import Api.Model.IdName exposing (IdName)
import Data.DropdownStyle as DS import Data.DropdownStyle as DS
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
@ -31,32 +29,8 @@ import Util.Html exposing (onKeyUp)
import Util.List import Util.List
orgDropdown : Model IdName
orgDropdown =
makeModel
{ multiple = False
, searchable = \n -> n > 0
, makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an organization"
}
type alias Option =
{ value : String
, text : String
, additional : String
}
mkOption : String -> String -> Option
mkOption value text =
Option value text ""
type alias Item a = type alias Item a =
{ value : a { value : a
, option : Option
, visible : Bool , visible : Bool
, selected : Bool , selected : Bool
, active : Bool , active : Bool
@ -66,7 +40,6 @@ type alias Item a =
makeItem : Model a -> a -> Item a makeItem : Model a -> a -> Item a
makeItem model val = makeItem model val =
{ value = val { value = val
, option = model.makeOption val
, visible = True , visible = True
, selected = , selected =
List.any (\i -> i.value == val) model.selected List.any (\i -> i.value == val) model.selected
@ -78,26 +51,15 @@ type alias Model a =
{ multiple : Bool { multiple : Bool
, selected : List (Item a) , selected : List (Item a)
, available : List (Item a) , available : List (Item a)
, makeOption : a -> Option
, menuOpen : Bool , menuOpen : Bool
, filterString : String , filterString : String
, labelColor : a -> UiSettings -> String
, searchable : Int -> Bool , searchable : Int -> Bool
, placeholder : String
} }
setMkOption : (a -> Option) -> Model a -> Model a
setMkOption mkopt model =
{ model | makeOption = mkopt }
makeModel : makeModel :
{ multiple : Bool { multiple : Bool
, searchable : Int -> Bool , searchable : Int -> Bool
, makeOption : a -> Option
, labelColor : a -> UiSettings -> String
, placeholder : String
} }
-> Model a -> Model a
makeModel input = makeModel input =
@ -105,45 +67,28 @@ makeModel input =
, searchable = input.searchable , searchable = input.searchable
, selected = [] , selected = []
, available = [] , available = []
, makeOption = input.makeOption
, menuOpen = False , menuOpen = False
, filterString = "" , filterString = ""
, labelColor = input.labelColor
, placeholder = input.placeholder
} }
makeSingle : makeSingle : Model a
{ makeOption : a -> Option makeSingle =
, placeholder : String
}
-> Model a
makeSingle opts =
makeModel makeModel
{ multiple = False { multiple = False
, searchable = \n -> n > 0 , searchable = \n -> n > 0
, makeOption = opts.makeOption
, labelColor = \_ -> \_ -> ""
, placeholder =
if opts.placeholder == "" then
"Select"
else
opts.placeholder
} }
makeSingleList : makeSingleList :
{ makeOption : a -> Option { options : List a
, placeholder : String
, options : List a
, selected : Maybe a , selected : Maybe a
} }
-> Model a -> Model a
makeSingleList opts = makeSingleList opts =
let let
m = m =
makeSingle { makeOption = opts.makeOption, placeholder = opts.placeholder } makeSingle
m2 = m2 =
{ m | available = List.map (makeItem m) opts.options } { m | available = List.map (makeItem m) opts.options }
@ -156,18 +101,11 @@ makeSingleList opts =
m3 m3
makeMultiple : makeMultiple : Model a
{ makeOption : a -> Option makeMultiple =
, labelColor : a -> UiSettings -> String
}
-> Model a
makeMultiple opts =
makeModel makeModel
{ multiple = True { multiple = True
, searchable = \n -> n > 0 , searchable = \n -> n > 0
, makeOption = opts.makeOption
, labelColor = opts.labelColor
, placeholder = ""
} }
@ -186,9 +124,8 @@ type Msg a
| SetSelection (List a) | SetSelection (List a)
| ToggleMenu | ToggleMenu
| AddItem (Item a) | AddItem (Item a)
| RemoveItem (Item a)
| RemoveItem2 (Item a) | RemoveItem2 (Item a)
| Filter String | Filter (a -> String) String
| ShowMenu Bool | ShowMenu Bool
| KeyPress Int | KeyPress Int
@ -215,17 +152,17 @@ deselectItem : Model a -> Item a -> Model a
deselectItem model item = deselectItem model item =
let let
value = value =
item.option.value item.value
sel = sel =
if model.multiple then if model.multiple then
List.filter (\e -> e.option.value /= value) model.selected List.filter (\e -> e.value /= value) model.selected
else else
[] []
show e = show e =
if e.option.value == value then if e.value == value then
{ e | selected = False } { e | selected = False }
else else
@ -241,7 +178,7 @@ selectItem : Model a -> Item a -> Model a
selectItem model item = selectItem model item =
let let
value = value =
item.option.value item.value
sel = sel =
if model.multiple then if model.multiple then
@ -251,7 +188,7 @@ selectItem model item =
[ item ] [ item ]
hide e = hide e =
if e.option.value == value then if e.value == value then
{ e | selected = True } { e | selected = True }
else if model.multiple then else if model.multiple then
@ -266,13 +203,13 @@ selectItem model item =
{ model | selected = sel, available = avail } { model | selected = sel, available = avail }
filterOptions : String -> List (Item a) -> List (Item a) filterOptions : String -> (a -> String) -> List (Item a) -> List (Item a)
filterOptions str list = filterOptions str mkText list =
List.map (\e -> { e | visible = Simple.Fuzzy.match str e.option.text, active = False }) list List.map (\e -> { e | visible = Simple.Fuzzy.match str (mkText e.value), active = False }) list
applyFilter : String -> Model a -> Model a applyFilter : String -> (a -> String) -> Model a -> Model a
applyFilter str model = applyFilter str mkText model =
let let
selected = selected =
if str /= "" && not model.multiple then if str /= "" && not model.multiple then
@ -281,7 +218,12 @@ applyFilter str model =
else else
model.selected model.selected
in in
{ model | filterString = str, available = filterOptions str model.available, selected = selected } { model | filterString = str, available = filterOptions str mkText model.available, selected = selected }
clearFilter : Model a -> Model a
clearFilter model =
{ model | filterString = "" }
makeNextActive : (Int -> Int) -> Model a -> Model a makeNextActive : (Int -> Int) -> Model a -> Model a
@ -299,7 +241,7 @@ makeNextActive nextEl model =
|> Maybe.andThen (Util.List.get opts) |> Maybe.andThen (Util.List.get opts)
merge item1 item2 = merge item1 item2 =
{ item2 | active = item1.option.value == item2.option.value } { item2 | active = item1.value == item2.value }
updateModel item = updateModel item =
{ model | available = List.map (merge item) model.available, menuOpen = True } { model | available = List.map (merge item) model.available, menuOpen = True }
@ -325,7 +267,7 @@ selectActive model =
in in
case current of case current of
Just item -> Just item ->
selectItem model item |> applyFilter "" selectItem model item |> clearFilter
Nothing -> Nothing ->
model model
@ -337,9 +279,6 @@ isDropdownChangeMsg cm =
AddItem _ -> AddItem _ ->
True True
RemoveItem _ ->
True
RemoveItem2 _ -> RemoveItem2 _ ->
True True
@ -375,34 +314,23 @@ update msg model =
AddItem e -> AddItem e ->
let let
m = m =
selectItem model e |> applyFilter "" selectItem model e |> clearFilter
in in
( { m | menuOpen = False }, Cmd.none ) ( { m | menuOpen = False }, Cmd.none )
RemoveItem e ->
let
m =
deselectItem model e |> applyFilter ""
in
( -- Setting to True, because parent click sets it to False… ugly
{ m | menuOpen = True }
, Cmd.none
)
RemoveItem2 e -> RemoveItem2 e ->
let let
m = m =
deselectItem model e |> applyFilter "" deselectItem model e |> clearFilter
in in
( -- Hack above only needed with semanticui ( m
m
, Cmd.none , Cmd.none
) )
Filter str -> Filter f str ->
let let
m = m =
applyFilter str model applyFilter str f model
in in
( { m | menuOpen = True }, Cmd.none ) ( { m | menuOpen = True }, Cmd.none )
@ -438,7 +366,7 @@ update msg model =
[ e ] -> [ e ] ->
let let
( m_, c_ ) = ( m_, c_ ) =
update (RemoveItem e) model update (RemoveItem2 e) model
in in
( { m_ | menuOpen = False }, c_ ) ( { m_ | menuOpen = False }, c_ )
@ -463,32 +391,65 @@ update msg model =
-- View2 -- View2
view2 : DS.DropdownStyle -> UiSettings -> Model a -> Html (Msg a) type alias Option =
view2 style settings model = { text : String
, additional : String
}
mkOption : String -> Option
mkOption text =
Option text ""
type alias ViewSettings a =
{ makeOption : a -> Option
, placeholder : String
, labelColor : a -> UiSettings -> String
, style : DS.DropdownStyle
}
orgFormViewSettings : DS.DropdownStyle -> ViewSettings IdName
orgFormViewSettings ds =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an organization"
, style = ds
}
setMkOption : (a -> Option) -> ViewSettings a -> ViewSettings a
setMkOption mkopt model =
{ model | makeOption = mkopt }
view2 : ViewSettings a -> UiSettings -> Model a -> Html (Msg a)
view2 cfg settings model =
if model.multiple then if model.multiple then
viewMultiple2 style settings model viewMultiple2 cfg settings model
else else
viewSingle2 style model viewSingle2 cfg model
viewSingle2 : DS.DropdownStyle -> Model a -> Html (Msg a) viewSingle2 : ViewSettings a -> Model a -> Html (Msg a)
viewSingle2 style model = viewSingle2 cfg model =
let let
renderItem item = renderItem item =
a a
[ href "#" [ href "#"
, class style.item , class cfg.style.item
, classList , classList
[ ( style.itemActive, item.active ) [ ( cfg.style.itemActive, item.active )
, ( "font-semibold", item.selected ) , ( "font-semibold", item.selected )
] ]
, onClick (AddItem item) , onClick (AddItem item)
, onKeyUp KeyPress , onKeyUp KeyPress
] ]
[ text item.option.text [ text <| (.value >> cfg.makeOption >> .text) item
, span [ class "text-gray-400 float-right" ] , span [ class "text-gray-400 float-right" ]
[ text item.option.additional [ text <| (.value >> cfg.makeOption >> .additional) item
] ]
] ]
@ -500,7 +461,7 @@ viewSingle2 style model =
, onKeyUp KeyPress , onKeyUp KeyPress
] ]
[ div [ div
[ class style.link [ class cfg.style.link
] ]
[ a [ a
[ class "flex-grow" [ class "flex-grow"
@ -514,8 +475,8 @@ viewSingle2 style model =
, onClick ToggleMenu , onClick ToggleMenu
, href "#" , href "#"
] ]
[ Maybe.map (.option >> .text) sel [ Maybe.map (.value >> cfg.makeOption >> .text) sel
|> Maybe.withDefault model.placeholder |> Maybe.withDefault cfg.placeholder
|> text |> text
] ]
, a , a
@ -532,11 +493,11 @@ viewSingle2 style model =
] ]
, input , input
[ type_ "text" [ type_ "text"
, placeholder model.placeholder , placeholder cfg.placeholder
, onInput Filter , onInput (Filter (cfg.makeOption >> .text))
, value model.filterString , value model.filterString
, class "inline-block border-0 px-0 w-full py-0 focus:ring-0 " , class "inline-block border-0 px-0 w-full py-0 focus:ring-0 "
, class style.input , class cfg.style.input
, classList [ ( "hidden", not (model.menuOpen && isSearchable model) ) ] , classList [ ( "hidden", not (model.menuOpen && isSearchable model) ) ]
] ]
[] []
@ -550,43 +511,43 @@ viewSingle2 style model =
] ]
] ]
, div , div
[ class style.menu [ class cfg.style.menu
, classList [ ( "hidden", not model.menuOpen ) ] , classList [ ( "hidden", not model.menuOpen ) ]
] ]
(getOptions model |> List.map renderItem) (getOptions model |> List.map renderItem)
] ]
viewMultiple2 : DS.DropdownStyle -> UiSettings -> Model a -> Html (Msg a) viewMultiple2 : ViewSettings a -> UiSettings -> Model a -> Html (Msg a)
viewMultiple2 style settings model = viewMultiple2 cfg settings model =
let let
renderItem item = renderItem item =
a a
[ href "#" [ href "#"
, class style.item , class cfg.style.item
, classList , classList
[ ( style.itemActive, item.active ) [ ( cfg.style.itemActive, item.active )
, ( "font-semibold", item.selected ) , ( "font-semibold", item.selected )
] ]
, onClick (AddItem item) , onClick (AddItem item)
, onKeyUp KeyPress , onKeyUp KeyPress
] ]
[ text item.option.text [ text <| (.value >> cfg.makeOption >> .text) item
, span [ class "text-gray-400 float-right" ] , span [ class "text-gray-400 float-right" ]
[ text item.option.additional [ text <| (.value >> cfg.makeOption >> .additional) item
] ]
] ]
renderSelectMultiple : Item a -> Html (Msg a) renderSelectMultiple : Item a -> Html (Msg a)
renderSelectMultiple item = renderSelectMultiple item =
a a
[ class (model.labelColor item.value settings) [ class (cfg.labelColor item.value settings)
, class "label font-medium inline-flex relative items-center hover:shadow-md mt-1 mr-1" , class "label font-medium inline-flex relative items-center hover:shadow-md mt-1 mr-1"
, onClick (RemoveItem item) , onClick (RemoveItem2 item)
, href "#" , href "#"
] ]
[ span [ class "pl-4" ] [ span [ class "pl-4" ]
[ text item.option.text [ text <| (.value >> cfg.makeOption >> .text) item
] ]
, span [ class "opacity-75 absolute left-2 my-auto" ] , span [ class "opacity-75 absolute left-2 my-auto" ]
[ i [ class "fa fa-times" ] [] [ i [ class "fa fa-times" ] []
@ -598,7 +559,7 @@ viewMultiple2 style settings model =
, onKeyUp KeyPress , onKeyUp KeyPress
] ]
[ div [ div
[ class style.link [ class cfg.style.link
, class "flex inline-flex flex-wrap items-center" , class "flex inline-flex flex-wrap items-center"
] ]
[ div [ div
@ -609,10 +570,10 @@ viewMultiple2 style settings model =
, input , input
[ type_ "text" [ type_ "text"
, placeholder "Search" , placeholder "Search"
, onInput Filter , onInput (Filter (cfg.makeOption >> .text))
, value model.filterString , value model.filterString
, class "inline-flex w-16 border-0 px-0 focus:ring-0 h-6" , class "inline-flex w-16 border-0 px-0 focus:ring-0 h-6"
, class style.input , class cfg.style.input
] ]
[] []
, a , a
@ -629,7 +590,7 @@ viewMultiple2 style settings model =
] ]
] ]
, div , div
[ class style.menu [ class cfg.style.menu
, classList [ ( "hidden", not model.menuOpen ) ] , classList [ ( "hidden", not model.menuOpen ) ]
] ]
(getOptions model |> List.map renderItem) (getOptions model |> List.map renderItem)

View File

@ -55,14 +55,7 @@ emptyModel =
, replyTo = Nothing , replyTo = Nothing
, sslType = , sslType =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.SSLType.all
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
, selected = Just Data.SSLType.None , selected = Just Data.SSLType.None
} }
, ignoreCertificates = False , ignoreCertificates = False
@ -83,14 +76,7 @@ init ems =
, replyTo = ems.replyTo , replyTo = ems.replyTo
, sslType = , sslType =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.SSLType.all
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
, selected = , selected =
Data.SSLType.fromString ems.sslType Data.SSLType.fromString ems.sslType
|> Maybe.withDefault Data.SSLType.None |> Maybe.withDefault Data.SSLType.None
@ -186,6 +172,18 @@ update msg model =
view2 : UiSettings -> Model -> Html Msg view2 : UiSettings -> Model -> Html Msg
view2 settings model = view2 settings model =
let
sslCfg =
{ makeOption =
\s ->
{ text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div [ class "grid grid-cols-4 gap-y-4 gap-x-2" ] div [ class "grid grid-cols-4 gap-y-4 gap-x-2" ]
[ div [ class "col-span-4" ] [ div [ class "col-span-4" ]
[ label [ label
@ -291,7 +289,7 @@ view2 settings model =
] ]
, Html.map SSLTypeMsg , Html.map SSLTypeMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle sslCfg
settings settings
model.sslType model.sslType
) )

View File

@ -52,14 +52,7 @@ emptyModel =
, password = Nothing , password = Nothing
, sslType = , sslType =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.SSLType.all
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
, selected = Just Data.SSLType.None , selected = Just Data.SSLType.None
} }
, ignoreCertificates = False , ignoreCertificates = False
@ -79,14 +72,7 @@ init ems =
, password = ems.imapPassword , password = ems.imapPassword
, sslType = , sslType =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.SSLType.all
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
, selected = , selected =
Data.SSLType.fromString ems.sslType Data.SSLType.fromString ems.sslType
|> Maybe.withDefault Data.SSLType.None |> Maybe.withDefault Data.SSLType.None
@ -178,6 +164,18 @@ update msg model =
view2 : UiSettings -> Model -> Html Msg view2 : UiSettings -> Model -> Html Msg
view2 settings model = view2 settings model =
let
sslCfg =
{ makeOption =
\s ->
{ text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div div
[ class "grid grid-cols-4 gap-y-4 gap-x-2" ] [ class "grid grid-cols-4 gap-y-4 gap-x-2" ]
[ div [ class "col-span-4" ] [ div [ class "col-span-4" ]
@ -251,7 +249,7 @@ view2 settings model =
] ]
, Html.map SSLTypeMsg , Html.map SSLTypeMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle sslCfg
settings settings
model.sslType model.sslType
) )

View File

@ -14,8 +14,10 @@ import Comp.ItemDetail.Model
) )
import Comp.KeyInput import Comp.KeyInput
import Comp.Tabs as TB import Comp.Tabs as TB
import Data.Direction
import Data.DropdownStyle import Data.DropdownStyle
import Data.Fields import Data.Fields
import Data.Flags exposing (Flags)
import Data.Icons as Icons import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Dict import Dict
@ -27,11 +29,13 @@ import Page exposing (Page(..))
import Set exposing (Set) import Set exposing (Set)
import Styles as S import Styles as S
import Util.Folder import Util.Folder
import Util.Person
import Util.Tag
import Util.Time import Util.Time
view2 : UiSettings -> Model -> Html Msg view2 : Flags -> UiSettings -> Model -> Html Msg
view2 settings model = view2 flags settings model =
let let
keyAttr = keyAttr =
if settings.itemDetailShortcuts then if settings.itemDetailShortcuts then
@ -44,7 +48,7 @@ view2 settings model =
TB.searchMenuStyle TB.searchMenuStyle
tabs = tabs =
formTabs settings model formTabs flags settings model
allTabNames = allTabNames =
List.map .title tabs List.map .title tabs
@ -57,8 +61,8 @@ view2 settings model =
] ]
formTabs : UiSettings -> Model -> List (TB.Tab Msg) formTabs : Flags -> UiSettings -> Model -> List (TB.Tab Msg)
formTabs settings model = formTabs flags settings model =
let let
dds = dds =
Data.DropdownStyle.sidebarStyle Data.DropdownStyle.sidebarStyle
@ -106,6 +110,38 @@ formTabs settings model =
else else
span [ class "invisible hidden" ] [] span [ class "invisible hidden" ] []
directionCfg =
{ makeOption =
\entry ->
{ text = Data.Direction.toString entry
, additional = ""
}
, placeholder = "Choose a direction"
, labelColor = \_ -> \_ -> ""
, style = dds
}
folderCfg =
{ makeOption = Util.Folder.mkFolderOption flags model.allFolders
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = dds
}
idNameCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Select"
, style = dds
}
personCfg =
{ makeOption = \p -> Util.Person.mkPersonOption p model.allPersons
, labelColor = \_ -> \_ -> ""
, placeholder = "Select"
, style = dds
}
in in
[ { title = "Name" [ { title = "Name"
, titleRight = [] , titleRight = []
@ -163,7 +199,11 @@ formTabs settings model =
, info = Nothing , info = Nothing
, body = , body =
[ div [ class "mb-4 flex flex-col" ] [ div [ class "mb-4 flex flex-col" ]
[ Html.map TagDropdownMsg (Comp.Dropdown.view2 dds settings model.tagModel) [ Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings dds)
settings
model.tagModel
)
, div [ class "flex flex-row items-center justify-end" ] , div [ class "flex flex-row items-center justify-end" ]
[ a [ a
[ class S.secondaryButton [ class S.secondaryButton
@ -184,7 +224,7 @@ formTabs settings model =
[ div [ class "mb-4" ] [ div [ class "mb-4" ]
[ Html.map FolderDropdownMsg [ Html.map FolderDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
dds folderCfg
settings settings
model.folderModel model.folderModel
) )
@ -254,7 +294,12 @@ item visible. This message will disappear then.
, addIconLink "Add new organization" StartCorrOrgModal , addIconLink "Add new organization" StartCorrOrgModal
, editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal , editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal
] ]
, Html.map OrgDropdownMsg (Comp.Dropdown.view2 dds settings model.corrOrgModel) , Html.map OrgDropdownMsg
(Comp.Dropdown.view2
(Comp.Dropdown.orgFormViewSettings dds)
settings
model.corrOrgModel
)
, renderOrgSuggestions model , renderOrgSuggestions model
] ]
, optional [ Data.Fields.CorrPerson ] <| , optional [ Data.Fields.CorrPerson ] <|
@ -267,7 +312,11 @@ item visible. This message will disappear then.
model.corrPersonModel model.corrPersonModel
(StartEditPersonModal model.corrPersonModel) (StartEditPersonModal model.corrPersonModel)
] ]
, Html.map CorrPersonMsg (Comp.Dropdown.view2 dds settings model.corrPersonModel) , Html.map CorrPersonMsg
(Comp.Dropdown.view2 personCfg
settings
model.corrPersonModel
)
, renderCorrPersonSuggestions model , renderCorrPersonSuggestions model
, div , div
[ classList [ classList
@ -298,7 +347,7 @@ item visible. This message will disappear then.
] ]
, Html.map ConcPersonMsg , Html.map ConcPersonMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
dds personCfg
settings settings
model.concPersonModel model.concPersonModel
) )
@ -316,7 +365,7 @@ item visible. This message will disappear then.
] ]
, Html.map ConcEquipMsg , Html.map ConcEquipMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
dds idNameCfg
settings settings
model.concEquipModel model.concEquipModel
) )
@ -331,7 +380,7 @@ item visible. This message will disappear then.
[ div [ class "mb-4" ] [ div [ class "mb-4" ]
[ Html.map DirDropdownMsg [ Html.map DirDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
dds directionCfg
settings settings
model.directionModel model.directionModel
) )

View File

@ -39,7 +39,6 @@ import Comp.KeyInput
import Comp.LinkTarget exposing (LinkTarget) import Comp.LinkTarget exposing (LinkTarget)
import Comp.MarkdownInput import Comp.MarkdownInput
import Comp.SentMails import Comp.SentMails
import Comp.YesNoDimmer
import Data.Direction exposing (Direction) import Data.Direction exposing (Direction)
import Data.Fields exposing (Field) import Data.Fields exposing (Field)
import DatePicker exposing (DatePicker) import DatePicker exposing (DatePicker)
@ -136,45 +135,17 @@ emptyModel =
, visibleAttach = 0 , visibleAttach = 0
, attachMenuOpen = False , attachMenuOpen = False
, menuOpen = False , menuOpen = False
, tagModel = , tagModel = Util.Tag.makeDropdownModel
Util.Tag.makeDropdownModel2
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.Direction.all
\entry ->
{ value = Data.Direction.toString entry
, text = Data.Direction.toString entry
, additional = ""
}
, options = Data.Direction.all
, placeholder = "Choose a direction"
, selected = Nothing , selected = Nothing
} }
, corrOrgModel = , corrOrgModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle , corrPersonModel = Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" } , concPersonModel = Comp.Dropdown.makeSingle
, placeholder = "" , concEquipModel = Comp.Dropdown.makeSingle
} , folderModel = Comp.Dropdown.makeSingle
, corrPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concEquipModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, folderModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, allFolders = [] , allFolders = []
, nameModel = "" , nameModel = ""
, nameState = SaveSuccess , nameState = SaveSuccess

View File

@ -48,6 +48,7 @@ import Time
import Util.Folder exposing (mkFolderOption) import Util.Folder exposing (mkFolderOption)
import Util.List import Util.List
import Util.Maybe import Util.Maybe
import Util.Person
import Util.Tag import Util.Tag
@ -117,45 +118,17 @@ type Msg
init : Model init : Model
init = init =
{ tagModel = { tagModel = Util.Tag.makeDropdownModel
Util.Tag.makeDropdownModel2
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.Direction.all
\entry ->
{ value = Data.Direction.toString entry
, text = Data.Direction.toString entry
, additional = ""
}
, options = Data.Direction.all
, placeholder = "Choose a direction"
, selected = Nothing , selected = Nothing
} }
, corrOrgModel = , corrOrgModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle , corrPersonModel = Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" } , concPersonModel = Comp.Dropdown.makeSingle
, placeholder = "" , concEquipModel = Comp.Dropdown.makeSingle
} , folderModel = Comp.Dropdown.makeSingle
, corrPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concEquipModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, folderModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, allFolders = [] , allFolders = []
, nameModel = "" , nameModel = ""
, nameSaveThrottle = Throttle.create 1 , nameSaveThrottle = Throttle.create 1
@ -310,13 +283,7 @@ update flags msg model =
GetFolderResp (Ok fs) -> GetFolderResp (Ok fs) ->
let let
model_ = model_ =
{ model { model | allFolders = fs.items }
| allFolders = fs.items
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
}
mkIdName fitem = mkIdName fitem =
IdName fitem.id fitem.name IdName fitem.id fitem.name
@ -635,13 +602,13 @@ defaultViewConfig =
--- View2 --- View2
view2 : ViewConfig -> UiSettings -> Model -> Html Msg view2 : Flags -> ViewConfig -> UiSettings -> Model -> Html Msg
view2 = view2 =
renderEditForm2 renderEditForm2
renderEditForm2 : ViewConfig -> UiSettings -> Model -> Html Msg renderEditForm2 : Flags -> ViewConfig -> UiSettings -> Model -> Html Msg
renderEditForm2 cfg settings model = renderEditForm2 flags cfg settings model =
let let
fieldVisible field = fieldVisible field =
Data.UiSettings.fieldVisible settings field Data.UiSettings.fieldVisible settings field
@ -700,6 +667,31 @@ renderEditForm2 cfg settings model =
tabStyle = tabStyle =
TB.searchMenuStyle TB.searchMenuStyle
folderCfg =
{ makeOption = Util.Folder.mkFolderOption flags model.allFolders
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = dds
}
idNameCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Select"
, style = dds
}
directionCfg =
{ makeOption =
\entry ->
{ text = Data.Direction.toString entry
, additional = ""
}
, placeholder = "Choose a direction"
, labelColor = \_ -> \_ -> ""
, style = dds
}
in in
div [ class cfg.menuClass, class "mt-2" ] div [ class cfg.menuClass, class "mt-2" ]
[ TB.akkordion [ TB.akkordion
@ -747,7 +739,11 @@ renderEditForm2 cfg settings model =
[ tagModeIcon [ tagModeIcon
] ]
] ]
, Html.map TagDropdownMsg (Comp.Dropdown.view2 dds settings model.tagModel) , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings dds)
settings
model.tagModel
)
, Markdown.toHtml [ class "opacity-50 text-sm" ] tagModeMsg , Markdown.toHtml [ class "opacity-50 text-sm" ] tagModeMsg
] ]
] ]
@ -756,7 +752,7 @@ renderEditForm2 cfg settings model =
, titleRight = [] , titleRight = []
, info = Nothing , info = Nothing
, body = , body =
[ Html.map FolderDropdownMsg (Comp.Dropdown.view2 dds settings model.folderModel) [ Html.map FolderDropdownMsg (Comp.Dropdown.view2 folderCfg settings model.folderModel)
, div , div
[ classList [ classList
[ ( S.message, True ) [ ( S.message, True )
@ -835,7 +831,7 @@ item visible. This message will disappear then.
[ text "Organization" [ text "Organization"
] ]
] ]
, Html.map OrgDropdownMsg (Comp.Dropdown.view2 dds settings model.corrOrgModel) , Html.map OrgDropdownMsg (Comp.Dropdown.view2 idNameCfg settings model.corrOrgModel)
] ]
, optional [ Data.Fields.CorrPerson ] <| , optional [ Data.Fields.CorrPerson ] <|
div [ class "mb-4" ] div [ class "mb-4" ]
@ -845,7 +841,7 @@ item visible. This message will disappear then.
[ text "Person" [ text "Person"
] ]
] ]
, Html.map CorrPersonMsg (Comp.Dropdown.view2 dds settings model.corrPersonModel) , Html.map CorrPersonMsg (Comp.Dropdown.view2 idNameCfg settings model.corrPersonModel)
] ]
] ]
} }
@ -860,7 +856,7 @@ item visible. This message will disappear then.
, span [ class "ml-2" ] , span [ class "ml-2" ]
[ text "Person" ] [ text "Person" ]
] ]
, Html.map ConcPersonMsg (Comp.Dropdown.view2 dds settings model.concPersonModel) , Html.map ConcPersonMsg (Comp.Dropdown.view2 idNameCfg settings model.concPersonModel)
] ]
, optional [ Data.Fields.ConcEquip ] <| , optional [ Data.Fields.ConcEquip ] <|
div [ class "mb-4" ] div [ class "mb-4" ]
@ -869,7 +865,11 @@ item visible. This message will disappear then.
, span [ class "ml-2" ] , span [ class "ml-2" ]
[ text "Equipment" ] [ text "Equipment" ]
] ]
, Html.map ConcEquipMsg (Comp.Dropdown.view2 dds settings model.concEquipModel) , Html.map ConcEquipMsg
(Comp.Dropdown.view2 idNameCfg
settings
model.concEquipModel
)
] ]
] ]
} }
@ -877,7 +877,7 @@ item visible. This message will disappear then.
, titleRight = [] , titleRight = []
, info = Nothing , info = Nothing
, body = , body =
[ Html.map DirDropdownMsg (Comp.Dropdown.view2 dds settings model.directionModel) [ Html.map DirDropdownMsg (Comp.Dropdown.view2 directionCfg settings model.directionModel)
] ]
} }
, { title = "Name" , { title = "Name"

View File

@ -62,7 +62,6 @@ import Set exposing (Set)
import Throttle import Throttle
import Time import Time
import Util.File exposing (makeFileId) import Util.File exposing (makeFileId)
import Util.Folder exposing (mkFolderOption)
import Util.Http import Util.Http
import Util.List import Util.List
import Util.Maybe import Util.Maybe
@ -576,13 +575,7 @@ update key flags inav settings msg model =
GetFolderResp (Ok fs) -> GetFolderResp (Ok fs) ->
let let
model_ = model_ =
{ model { model | allFolders = fs.items }
| allFolders = fs.items
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
}
mkIdName fitem = mkIdName fitem =
IdName fitem.id fitem.name IdName fitem.id fitem.name
@ -645,23 +638,8 @@ update key flags inav settings msg model =
List.filter personFilter correspondent List.filter personFilter correspondent
|> List.map (\e -> IdName e.id e.name) |> List.map (\e -> IdName e.id e.name)
mkPersonOption idref =
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.id idref.name org
model_ = model_ =
{ model { model | allPersons = personDict }
| corrPersonModel = Comp.Dropdown.setMkOption mkPersonOption model.corrPersonModel
, concPersonModel = Comp.Dropdown.setMkOption mkPersonOption model.concPersonModel
, allPersons = personDict
}
res1 = res1 =
update key update key
@ -1505,7 +1483,7 @@ update key flags inav settings msg model =
ToggleOpenAllAkkordionTabs -> ToggleOpenAllAkkordionTabs ->
let let
allNames = allNames =
Comp.ItemDetail.EditForm.formTabs settings model Comp.ItemDetail.EditForm.formTabs flags settings model
|> List.map .title |> List.map .title
|> Set.fromList |> Set.fromList

View File

@ -69,11 +69,7 @@ type FormAction
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ connectionModel = { connectionModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select connection..."
}
, subject = "" , subject = ""
, recipients = [] , recipients = []
, recipientsModel = Comp.EmailInput.init , recipientsModel = Comp.EmailInput.init
@ -160,9 +156,7 @@ update flags msg model =
cm = cm =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = \a -> { value = a, text = a, additional = "" } { options = names
, placeholder = "Select Connection..."
, options = names
, selected = List.head names , selected = List.head names
} }
in in
@ -229,6 +223,13 @@ view2 settings model =
let let
dds = dds =
Data.DropdownStyle.mainStyle Data.DropdownStyle.mainStyle
connectionCfg =
{ makeOption = \a -> { text = a, additional = "" }
, placeholder = "Select connection..."
, labelColor = \_ -> \_ -> ""
, style = dds
}
in in
div div
[ class "flex flex-col" [ class "flex flex-col"
@ -238,7 +239,7 @@ view2 settings model =
[ text "Send via" [ text "Send via"
, B.inputRequired , B.inputRequired
] ]
, Html.map ConnMsg (Comp.Dropdown.view2 dds settings model.connectionModel) , Html.map ConnMsg (Comp.Dropdown.view2 connectionCfg settings model.connectionModel)
] ]
, div , div
[ class S.errorMessage [ class S.errorMessage

View File

@ -144,13 +144,9 @@ init flags =
Comp.CalEventInput.initDefault Comp.CalEventInput.initDefault
in in
( { settings = Api.Model.NotificationSettings.empty ( { settings = Api.Model.NotificationSettings.empty
, connectionModel = , connectionModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle , tagInclModel = Util.Tag.makeDropdownModel
{ makeOption = \a -> { value = a, text = a, additional = "" } , tagExclModel = Util.Tag.makeDropdownModel
, placeholder = "Select connection..."
}
, tagInclModel = Util.Tag.makeDropdownModel2
, tagExclModel = Util.Tag.makeDropdownModel2
, recipients = [] , recipients = []
, recipientsModel = Comp.EmailInput.init , recipientsModel = Comp.EmailInput.init
, remindDays = Just 1 , remindDays = Just 1
@ -298,9 +294,7 @@ update flags msg model =
cm = cm =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = \a -> { value = a, text = a, additional = "" } { options = names
, placeholder = "Select Connection..."
, options = names
, selected = List.head names , selected = List.head names
} }
in in
@ -493,6 +487,13 @@ view2 extraClasses settings model =
, title = "Start this task now" , title = "Start this task now"
, icon = Just "fa fa-play" , icon = Just "fa fa-play"
} }
connectionCfg =
{ makeOption = \a -> { text = a, additional = "" }
, placeholder = "Select connection..."
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in in
div div
[ class "flex flex-col md:relative" [ class "flex flex-col md:relative"
@ -579,7 +580,7 @@ view2 extraClasses settings model =
] ]
, Html.map ConnMsg , Html.map ConnMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle connectionCfg
settings settings
model.connectionModel model.connectionModel
) )
@ -609,7 +610,7 @@ view2 extraClasses settings model =
[ text "Tags Include (and)" ] [ text "Tags Include (and)" ]
, Html.map TagIncMsg , Html.map TagIncMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle (Util.Tag.tagSettings DS.mainStyle)
settings settings
model.tagInclModel model.tagInclModel
) )
@ -622,7 +623,7 @@ view2 extraClasses settings model =
[ text "Tags Exclude (or)" ] [ text "Tags Exclude (or)" ]
, Html.map TagExcMsg , Html.map TagExcMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle (Util.Tag.tagSettings DS.mainStyle)
settings settings
model.tagExclModel model.tagExclModel
) )

View File

@ -49,7 +49,7 @@ emptyModel =
Comp.FixedDropdown.initMap Comp.FixedDropdown.initMap
Data.PersonUse.label Data.PersonUse.label
Data.PersonUse.all Data.PersonUse.all
, orgModel = Comp.Dropdown.orgDropdown , orgModel = Comp.Dropdown.makeSingle
} }
@ -242,7 +242,7 @@ view2 mobile settings model =
] ]
, Html.map OrgDropdownMsg , Html.map OrgDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle (Comp.Dropdown.orgFormViewSettings DS.mainStyle)
settings settings
model.orgModel model.orgModel
) )

View File

@ -191,11 +191,7 @@ init flags =
Comp.CalEventInput.initDefault Comp.CalEventInput.initDefault
in in
( { settings = Api.Model.ScanMailboxSettings.empty ( { settings = Api.Model.ScanMailboxSettings.empty
, connectionModel = , connectionModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select connection..."
}
, enabled = False , enabled = False
, deleteMail = False , deleteMail = False
, receivedHours = Nothing , receivedHours = Nothing
@ -209,11 +205,7 @@ init flags =
, formMsg = Nothing , formMsg = Nothing
, loading = 3 , loading = 3
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, folderModel = , folderModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, allFolders = [] , allFolders = []
, itemFolderId = Nothing , itemFolderId = Nothing
, tagModel = Util.Tag.makeDropdownModel , tagModel = Util.Tag.makeDropdownModel
@ -370,9 +362,7 @@ update flags msg model =
cm = cm =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = \a -> { value = a, text = a, additional = "" } { options = names
, placeholder = "Select Connection..."
, options = names
, selected = , selected =
Util.Maybe.or Util.Maybe.or
[ List.head (Comp.Dropdown.getSelected model.connectionModel) [ List.head (Comp.Dropdown.getSelected model.connectionModel)
@ -522,10 +512,6 @@ update flags msg model =
{ model { model
| allFolders = fs.items | allFolders = fs.items
, loading = model.loading - 1 , loading = model.loading - 1
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
} }
mkIdName fitem = mkIdName fitem =
@ -729,8 +715,8 @@ isFolderMember model =
Util.Folder.isFolderMember model.allFolders selected Util.Folder.isFolderMember model.allFolders selected
view2 : String -> UiSettings -> Model -> Html Msg view2 : Flags -> String -> UiSettings -> Model -> Html Msg
view2 extraClasses settings model = view2 flags extraClasses settings model =
let let
dimmerSettings = dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this scan mailbox task?" Comp.YesNoDimmer.defaultSettings2 "Really delete this scan mailbox task?"
@ -799,7 +785,7 @@ view2 extraClasses settings model =
, Comp.Tabs.akkordion , Comp.Tabs.akkordion
Comp.Tabs.defaultStyle Comp.Tabs.defaultStyle
tabActive tabActive
(formTabs settings model) (formTabs flags settings model)
, Html.map YesNoDeleteMsg , Html.map YesNoDeleteMsg
(Comp.YesNoDimmer.viewN (Comp.YesNoDimmer.viewN
True True
@ -832,8 +818,8 @@ tabTitle tab =
"Schedule" "Schedule"
formTabs : UiSettings -> Model -> List (Comp.Tabs.Tab Msg) formTabs : Flags -> UiSettings -> Model -> List (Comp.Tabs.Tab Msg)
formTabs settings model = formTabs flags settings model =
[ { title = tabTitle TabGeneral [ { title = tabTitle TabGeneral
, titleRight = [] , titleRight = []
, info = Nothing , info = Nothing
@ -857,7 +843,7 @@ formTabs settings model =
, { title = tabTitle TabMetadata , { title = tabTitle TabMetadata
, titleRight = [] , titleRight = []
, info = Just "Define metadata that should be attached to all items created by this task." , info = Just "Define metadata that should be attached to all items created by this task."
, body = viewMetadata2 settings model , body = viewMetadata2 flags settings model
} }
, { title = tabTitle TabSchedule , { title = tabTitle TabSchedule
, titleRight = [] , titleRight = []
@ -869,6 +855,14 @@ formTabs settings model =
viewGeneral2 : UiSettings -> Model -> List (Html Msg) viewGeneral2 : UiSettings -> Model -> List (Html Msg)
viewGeneral2 settings model = viewGeneral2 settings model =
let
connectionCfg =
{ makeOption = \a -> { text = a, additional = "" }
, placeholder = "Select connection..."
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
[ MB.viewItem <| [ MB.viewItem <|
MB.Checkbox MB.Checkbox
{ id = "scanmail-enabled" { id = "scanmail-enabled"
@ -899,7 +893,7 @@ viewGeneral2 settings model =
] ]
, Html.map ConnMsg , Html.map ConnMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle connectionCfg
settings settings
model.connectionModel model.connectionModel
) )
@ -1054,8 +1048,16 @@ viewPostProcessing2 model =
] ]
viewMetadata2 : UiSettings -> Model -> List (Html Msg) viewMetadata2 : Flags -> UiSettings -> Model -> List (Html Msg)
viewMetadata2 settings model = viewMetadata2 flags settings model =
let
folderCfg =
{ makeOption = Util.Folder.mkFolderOption flags model.allFolders
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
[ div [ class "mb-4" ] [ div [ class "mb-4" ]
[ label [ class S.inputLabel ] [ label [ class S.inputLabel ]
[ text "Item direction" [ text "Item direction"
@ -1105,7 +1107,7 @@ viewMetadata2 settings model =
] ]
, Html.map FolderDropdownMsg , Html.map FolderDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle folderCfg
settings settings
model.folderModel model.folderModel
) )
@ -1131,7 +1133,7 @@ disappear then.
[ text "Tags" ] [ text "Tags" ]
, Html.map TagDropdownMsg , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle (Util.Tag.tagSettings DS.mainStyle)
settings settings
model.tagModel model.tagModel
) )

View File

@ -17,7 +17,6 @@ import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Http import Http
import Styles as S import Styles as S
import Util.Http import Util.Http
@ -213,8 +212,8 @@ update flags msg model =
--- View2 --- View2
view2 : UiSettings -> Model -> Html Msg view2 : Flags -> UiSettings -> Model -> Html Msg
view2 settings model = view2 flags settings model =
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
(div (div
[ classList [ classList
@ -229,7 +228,7 @@ view2 settings model =
] ]
:: (case model.detailModel of :: (case model.detailModel of
Just msett -> Just msett ->
viewForm2 settings msett viewForm2 flags settings msett
Nothing -> Nothing ->
viewList2 model viewList2 model
@ -237,10 +236,10 @@ view2 settings model =
) )
viewForm2 : UiSettings -> Comp.ScanMailboxForm.Model -> List (Html Msg) viewForm2 : Flags -> UiSettings -> Comp.ScanMailboxForm.Model -> List (Html Msg)
viewForm2 settings model = viewForm2 flags settings model =
[ Html.map DetailMsg [ Html.map DetailMsg
(Comp.ScanMailboxForm.view2 "" settings model) (Comp.ScanMailboxForm.view2 flags "" settings model)
] ]

View File

@ -95,36 +95,13 @@ init flags =
, tagSelection = Comp.TagSelect.emptySelection , tagSelection = Comp.TagSelect.emptySelection
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.Direction.all
\entry ->
{ value = Data.Direction.toString entry
, text = Data.Direction.toString entry
, additional = ""
}
, options = Data.Direction.all
, placeholder = "Choose a direction"
, selected = Nothing , selected = Nothing
} }
, orgModel = , orgModel = Comp.Dropdown.makeSingle
Comp.Dropdown.orgDropdown , corrPersonModel = Comp.Dropdown.makeSingle
, corrPersonModel = , concPersonModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle , concEquipmentModel = Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = "Choose a person"
}
, concPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = "Choose a person"
}
, concEquipmentModel =
Comp.Dropdown.makeModel
{ multiple = False
, searchable = \n -> n > 0
, makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an equipment"
}
, folderList = Comp.FolderSelect.init Nothing [] , folderList = Comp.FolderSelect.init Nothing []
, selectedFolder = Nothing , selectedFolder = Nothing
, inboxCheckbox = False , inboxCheckbox = False
@ -1022,6 +999,38 @@ searchTabs ddd flags settings model =
tagSelectWM = tagSelectWM =
Comp.TagSelect.makeWorkModel model.tagSelection model.tagSelectModel Comp.TagSelect.makeWorkModel model.tagSelection model.tagSelectModel
directionCfg =
{ makeOption =
\entry ->
{ text = Data.Direction.toString entry
, additional = ""
}
, placeholder = "Choose a direction"
, labelColor = \_ -> \_ -> ""
, style = DS.sidebarStyle
}
corrPersonCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, placeholder = "Choose a person"
, labelColor = \_ -> \_ -> ""
, style = DS.sidebarStyle
}
concPersonCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, placeholder = "Choose a person"
, labelColor = \_ -> \_ -> ""
, style = DS.sidebarStyle
}
concEquipCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an equipment"
, style = DS.sidebarStyle
}
in in
[ { title = "Inbox" [ { title = "Inbox"
, info = Nothing , info = Nothing
@ -1129,7 +1138,7 @@ searchTabs ddd flags settings model =
[ text "Organization" ] [ text "Organization" ]
, Html.map OrgMsg , Html.map OrgMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.sidebarStyle (Comp.Dropdown.orgFormViewSettings DS.sidebarStyle)
settings settings
model.orgModel model.orgModel
) )
@ -1141,7 +1150,7 @@ searchTabs ddd flags settings model =
[ label [ class S.inputLabel ] [ text "Person" ] [ label [ class S.inputLabel ] [ text "Person" ]
, Html.map CorrPersonMsg , Html.map CorrPersonMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.sidebarStyle corrPersonCfg
settings settings
model.corrPersonModel model.corrPersonModel
) )
@ -1159,7 +1168,7 @@ searchTabs ddd flags settings model =
[ label [ class S.inputLabel ] [ text "Person" ] [ label [ class S.inputLabel ] [ text "Person" ]
, Html.map ConcPersonMsg , Html.map ConcPersonMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.sidebarStyle concPersonCfg
settings settings
model.concPersonModel model.concPersonModel
) )
@ -1171,7 +1180,7 @@ searchTabs ddd flags settings model =
[ label [ class S.inputLabel ] [ text "Equipment" ] [ label [ class S.inputLabel ] [ text "Equipment" ]
, Html.map ConcEquipmentMsg , Html.map ConcEquipmentMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.sidebarStyle concEquipCfg
settings settings
model.concEquipmentModel model.concEquipmentModel
) )
@ -1295,7 +1304,7 @@ searchTabs ddd flags settings model =
, body = , body =
[ Html.map DirectionMsg [ Html.map DirectionMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.sidebarStyle directionCfg
settings settings
model.directionModel model.directionModel
) )

View File

@ -64,25 +64,14 @@ emptyModel =
Data.Priority.all Data.Priority.all
, priority = Data.Priority.Low , priority = Data.Priority.Low
, enabled = False , enabled = False
, folderModel = , folderModel = Comp.Dropdown.makeSingle
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, allFolders = [] , allFolders = []
, folderId = Nothing , folderId = Nothing
, tagModel = Util.Tag.makeDropdownModel2 , tagModel = Util.Tag.makeDropdownModel
, fileFilter = Nothing , fileFilter = Nothing
, languageModel = , languageModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.Language.all
\a ->
{ value = Data.Language.toName a
, text = Data.Language.toName a
, additional = ""
}
, placeholder = "Select"
, options = Data.Language.all
, selected = Nothing , selected = Nothing
} }
, language = Nothing , language = Nothing
@ -237,13 +226,7 @@ update flags msg model =
GetFolderResp (Ok fs) -> GetFolderResp (Ok fs) ->
let let
model_ = model_ =
{ model { model | allFolders = fs.items }
| allFolders = fs.items
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
}
mkIdName fitem = mkIdName fitem =
IdName fitem.id fitem.name IdName fitem.id fitem.name
@ -331,13 +314,34 @@ update flags msg model =
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
view2 _ texts settings model = view2 flags texts settings model =
let let
priorityItem = priorityItem =
Comp.FixedDropdown.Item Comp.FixedDropdown.Item
model.priority model.priority
(Data.Priority.toName model.priority) (Data.Priority.toName model.priority)
Nothing Nothing
folderCfg =
{ makeOption = mkFolderOption flags model.allFolders
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
tagCfg =
Util.Tag.tagSettings DS.mainStyle
languageCfg =
{ makeOption =
\a ->
{ text = Data.Language.toName a
, additional = ""
}
, placeholder = "Select"
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in in
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
[ div [ class "mb-4" ] [ div [ class "mb-4" ]
@ -424,7 +428,7 @@ view2 _ texts settings model =
] ]
, Html.map FolderDropdownMsg , Html.map FolderDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle folderCfg
settings settings
model.folderModel model.folderModel
) )
@ -446,7 +450,7 @@ view2 _ texts settings model =
] ]
, Html.map TagDropdownMsg , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle tagCfg
settings settings
model.tagModel model.tagModel
) )
@ -479,7 +483,7 @@ view2 _ texts settings model =
] ]
, Html.map LanguageMsg , Html.map LanguageMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle languageCfg
settings settings
model.languageModel model.languageModel
) )

View File

@ -37,9 +37,7 @@ emptyModel categories =
let let
cm = cm =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = \s -> Comp.Dropdown.mkOption s s { options = categories
, placeholder = "Select or define category..."
, options = categories
, selected = Nothing , selected = Nothing
} }
in in
@ -122,6 +120,14 @@ update _ msg model =
view2 : Model -> Html Msg view2 : Model -> Html Msg
view2 model = view2 model =
let
categoryCfg =
{ makeOption = \s -> Comp.Dropdown.mkOption s
, placeholder = "Select or define category..."
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div div
[ class "flex flex-col" ] [ class "flex flex-col" ]
[ div [ class "mb-4" ] [ div [ class "mb-4" ]
@ -155,7 +161,7 @@ view2 model =
] ]
, Html.map CatMsg , Html.map CatMsg
(Comp.Dropdown.viewSingle2 (Comp.Dropdown.viewSingle2
DS.mainStyle categoryCfg
model.catDropdown model.catDropdown
) )
] ]

View File

@ -41,14 +41,7 @@ emptyModel =
, password = Nothing , password = Nothing
, state = , state =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.UserState.all
\s ->
{ value = Data.UserState.toString s
, text = Data.UserState.toString s
, additional = ""
}
, placeholder = ""
, options = Data.UserState.all
, selected = List.head Data.UserState.all , selected = List.head Data.UserState.all
} }
} }
@ -103,14 +96,7 @@ update _ msg model =
let let
state = state =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ makeOption = { options = Data.UserState.all
\s ->
{ value = Data.UserState.toString s
, text = Data.UserState.toString s
, additional = ""
}
, placeholder = ""
, options = Data.UserState.all
, selected = , selected =
Data.UserState.fromString t.state Data.UserState.fromString t.state
|> Maybe.map (\u -> List.filter ((==) u) Data.UserState.all) |> Maybe.map (\u -> List.filter ((==) u) Data.UserState.all)
@ -169,6 +155,18 @@ update _ msg model =
view2 : Texts -> UiSettings -> Model -> Html Msg view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model = view2 texts settings model =
let
stateCfg =
{ makeOption =
\s ->
{ text = Data.UserState.toString s
, additional = ""
}
, placeholder = ""
, style = DS.mainStyle
, labelColor = \_ -> \_ -> ""
}
in
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
[ div [ div
[ class "mb-4" ] [ class "mb-4" ]
@ -205,7 +203,7 @@ view2 texts settings model =
] ]
, Html.map StateMsg , Html.map StateMsg
(Comp.Dropdown.view2 (Comp.Dropdown.view2
DS.mainStyle stateCfg
settings settings
model.state model.state
) )

View File

@ -7,7 +7,6 @@ module Data.UiSettings exposing
, cardPreviewSize2 , cardPreviewSize2
, catColor , catColor
, catColorFg2 , catColorFg2
, catColorString
, catColorString2 , catColorString2
, defaults , defaults
, fieldHidden , fieldHidden
@ -18,7 +17,6 @@ module Data.UiSettings exposing
, posToString , posToString
, tagColor , tagColor
, tagColorFg2 , tagColorFg2
, tagColorString
, tagColorString2 , tagColorString2
, toStoredUiSettings , toStoredUiSettings
) )
@ -276,13 +274,6 @@ tagColor tag settings =
Maybe.andThen (catColor settings) tag.category Maybe.andThen (catColor settings) tag.category
catColorString : UiSettings -> String -> String
catColorString settings name =
catColor settings name
|> Maybe.map Data.Color.toString
|> Maybe.withDefault ""
catColorString2 : UiSettings -> String -> String catColorString2 : UiSettings -> String -> String
catColorString2 settings name = catColorString2 settings name =
catColor settings name catColor settings name
@ -297,13 +288,6 @@ catColorFg2 settings name =
|> Maybe.withDefault "" |> Maybe.withDefault ""
tagColorString : Tag -> UiSettings -> String
tagColorString tag settings =
tagColor tag settings
|> Maybe.map Data.Color.toString
|> Maybe.withDefault ""
tagColorString2 : Tag -> UiSettings -> String tagColorString2 : Tag -> UiSettings -> String
tagColorString2 tag settings = tagColorString2 tag settings =
tagColor tag settings tagColor tag settings

View File

@ -47,7 +47,7 @@ view flags settings model =
SelectView svm -> SelectView svm ->
case svm.action of case svm.action of
EditSelected -> EditSelected ->
viewEditMenu svm settings viewEditMenu flags svm settings
_ -> _ ->
viewSearch flags settings model viewSearch flags settings model
@ -83,8 +83,8 @@ viewSearch flags settings model =
] ]
viewEditMenu : SelectViewModel -> UiSettings -> List (Html Msg) viewEditMenu : Flags -> SelectViewModel -> UiSettings -> List (Html Msg)
viewEditMenu svm settings = viewEditMenu flags svm settings =
let let
cfg_ = cfg_ =
Comp.ItemDetail.MultiEditMenu.defaultViewConfig Comp.ItemDetail.MultiEditMenu.defaultViewConfig
@ -127,5 +127,5 @@ viewEditMenu svm settings =
, rootClasses = "mt-2 text-sm" , rootClasses = "mt-2 text-sm"
} }
, Html.map EditMenuMsg , Html.map EditMenuMsg
(Comp.ItemDetail.MultiEditMenu.view2 cfg settings svm.editModel) (Comp.ItemDetail.MultiEditMenu.view2 flags cfg settings svm.editModel)
] ]

View File

@ -17,7 +17,7 @@ import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible _ settings model = viewSidebar texts visible flags settings model =
div div
[ id "sidebar" [ id "sidebar"
, class S.sidebar , class S.sidebar
@ -49,7 +49,7 @@ viewSidebar texts visible _ settings model =
, rootClasses = "text-sm mb-3 " , rootClasses = "text-sm mb-3 "
} }
, Html.map ItemDetailMsg , Html.map ItemDetailMsg
(Comp.ItemDetail.EditForm.view2 settings model.detail) (Comp.ItemDetail.EditForm.view2 flags settings model.detail)
] ]

View File

@ -119,7 +119,7 @@ viewContent flags settings model =
viewImapSettings settings model viewImapSettings settings model
Just ScanMailboxTab -> Just ScanMailboxTab ->
viewScanMailboxManage settings model viewScanMailboxManage flags settings model
Just UiSettingsTab -> Just UiSettingsTab ->
viewUiSettings flags settings model viewUiSettings flags settings model
@ -247,8 +247,8 @@ viewNotificationManage settings model =
] ]
viewScanMailboxManage : UiSettings -> Model -> List (Html Msg) viewScanMailboxManage : Flags -> UiSettings -> Model -> List (Html Msg)
viewScanMailboxManage settings model = viewScanMailboxManage flags settings model =
[ h2 [ h2
[ class S.header1 [ class S.header1
, class "inline-flex items-center" , class "inline-flex items-center"
@ -276,6 +276,7 @@ viewScanMailboxManage settings model =
] ]
, Html.map ScanMailboxMsg , Html.map ScanMailboxMsg
(Comp.ScanMailboxManage.view2 (Comp.ScanMailboxManage.view2
flags
settings settings
model.scanMailboxModel model.scanMailboxModel
) )

View File

@ -37,7 +37,7 @@ mkFolderOption flags allFolders idref =
else else
"" ""
in in
{ value = idref.id, text = idref.name, additional = adds } { text = idref.name, additional = adds }
isFolderMember : List FolderItem -> Maybe String -> Bool isFolderMember : List FolderItem -> Maybe String -> Bool

View 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

View File

@ -1,12 +1,14 @@
module Util.Tag exposing module Util.Tag exposing
( getCategories ( catSettings
, getCategories
, makeCatDropdownModel , makeCatDropdownModel
, makeDropdownModel , makeDropdownModel
, makeDropdownModel2 , tagSettings
) )
import Api.Model.Tag exposing (Tag) import Api.Model.Tag exposing (Tag)
import Comp.Dropdown import Comp.Dropdown
import Data.DropdownStyle as DS
import Data.UiSettings import Data.UiSettings
import Util.List import Util.List
@ -16,29 +18,18 @@ makeDropdownModel =
Comp.Dropdown.makeModel Comp.Dropdown.makeModel
{ multiple = True { multiple = True
, searchable = \n -> n > 0 , 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 tagSettings : DS.DropdownStyle -> Comp.Dropdown.ViewSettings Tag
makeDropdownModel2 = tagSettings ds =
Comp.Dropdown.makeModel { makeOption = \tag -> { text = tag.name, additional = "" }
{ multiple = True
, searchable = \n -> n > 0
, makeOption = \tag -> { value = tag.id, text = tag.name, additional = "" }
, labelColor = , labelColor =
\tag -> \tag ->
\settings -> \settings ->
Data.UiSettings.tagColorString2 tag settings Data.UiSettings.tagColorString2 tag settings
++ -- legacy colors
" basic "
++ Data.UiSettings.tagColorString tag settings
, placeholder = "Choose a tag" , placeholder = "Choose a tag"
, style = ds
} }
@ -47,9 +38,15 @@ makeCatDropdownModel =
Comp.Dropdown.makeModel Comp.Dropdown.makeModel
{ multiple = True { multiple = True
, searchable = \n -> n > 0 , searchable = \n -> n > 0
, makeOption = \cat -> { value = cat, text = cat, additional = "" } }
catSettings : DS.DropdownStyle -> Comp.Dropdown.ViewSettings String
catSettings ds =
{ makeOption = \cat -> { text = cat, additional = "" }
, labelColor = \_ -> \_ -> "" , labelColor = \_ -> \_ -> ""
, placeholder = "Choose a tag category" , placeholder = "Choose a tag category"
, style = ds
} }