Add lamassu-admin-elm to this repo (#185)
This commit is contained in:
parent
5ee7e40872
commit
f4fc9d6328
134 changed files with 28171 additions and 83 deletions
55
lamassu-admin-elm/src/SelectizeHelper.elm
Normal file
55
lamassu-admin-elm/src/SelectizeHelper.elm
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
module SelectizeHelper exposing (LocalConfig, buildConfig)
|
||||
|
||||
import Selectize exposing (..)
|
||||
import Css.Selectize
|
||||
import Css.Classes exposing (CssClasses)
|
||||
|
||||
|
||||
type alias LocalConfig msg idType itemType =
|
||||
{ toMsg : State -> msg
|
||||
, onAdd : idType -> State -> msg
|
||||
, onRemove : State -> msg
|
||||
, onFocus : State -> msg
|
||||
, onBlur : State -> msg
|
||||
, toId : itemType -> idType
|
||||
, enabled : Bool
|
||||
}
|
||||
|
||||
|
||||
type alias SpecificConfig itemType =
|
||||
{ selectedDisplay : itemType -> String
|
||||
, optionDisplay : itemType -> String
|
||||
, maxItems : Int
|
||||
, match : String -> List itemType -> List itemType
|
||||
, customCssClass: CssClasses
|
||||
}
|
||||
|
||||
|
||||
buildConfig :
|
||||
LocalConfig msg idType itemType
|
||||
-> SpecificConfig itemType
|
||||
-> Config msg idType itemType
|
||||
buildConfig localConfig specificConfig =
|
||||
{ maxItems = specificConfig.maxItems
|
||||
, boxLength = 5
|
||||
, toMsg = localConfig.toMsg
|
||||
, onAdd = localConfig.onAdd
|
||||
, onRemove = localConfig.onRemove
|
||||
, onFocus = localConfig.onFocus
|
||||
, onBlur = localConfig.onBlur
|
||||
, toId = localConfig.toId
|
||||
, enabled = localConfig.enabled
|
||||
, selectedDisplay = specificConfig.selectedDisplay
|
||||
, optionDisplay = specificConfig.optionDisplay
|
||||
, match = specificConfig.match
|
||||
, htmlOptions =
|
||||
{ instructionsForBlank = "Start typing for options"
|
||||
, noMatches = "No matches"
|
||||
, atMaxLength = "Type backspace to edit"
|
||||
, typeForMore = "Type for more options"
|
||||
, noOptions = "No options"
|
||||
, notAvailable = "N/A"
|
||||
, classes = Css.Selectize.classes
|
||||
, customCssClass = specificConfig.customCssClass
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue