mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Refactor FixedDropdown
This commit is contained in:
parent
8d15d97857
commit
9a23ba9afb
@ -81,7 +81,7 @@ init flags sett =
|
||||
Data.ListType.fromString sett.listType
|
||||
|> Maybe.withDefault Data.ListType.Whitelist
|
||||
, categoryListTypeModel =
|
||||
Comp.FixedDropdown.initMap Data.ListType.label Data.ListType.all
|
||||
Comp.FixedDropdown.init Data.ListType.all
|
||||
}
|
||||
, Cmd.batch
|
||||
[ Api.getTags flags "" GetTagsResp
|
||||
@ -181,18 +181,18 @@ update flags msg model =
|
||||
view2 : Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 texts settings model =
|
||||
let
|
||||
catListTypeItem =
|
||||
Comp.FixedDropdown.Item
|
||||
model.categoryListType
|
||||
(Data.ListType.label model.categoryListType)
|
||||
Nothing
|
||||
|
||||
categoryCfg =
|
||||
{ makeOption = \s -> { text = s, additional = "" }
|
||||
, labelColor = \_ -> \_ -> "grey "
|
||||
, placeholder = "Choose categories …"
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
|
||||
catListCfg =
|
||||
{ display = Data.ListType.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div []
|
||||
[ Markdown.toHtml [ class "px-2 py-2 opacity-75" ]
|
||||
@ -201,7 +201,11 @@ view2 texts settings model =
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text texts.blacklistOrWhitelist ]
|
||||
, Html.map CategoryListTypeMsg
|
||||
(Comp.FixedDropdown.view2 (Just catListTypeItem) model.categoryListTypeModel)
|
||||
(Comp.FixedDropdown.viewStyled2 catListCfg
|
||||
False
|
||||
(Just model.categoryListType)
|
||||
model.categoryListTypeModel
|
||||
)
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
|
@ -9,6 +9,7 @@ module Comp.ColorTagger exposing
|
||||
|
||||
import Comp.FixedDropdown
|
||||
import Data.Color exposing (Color)
|
||||
import Data.DropdownStyle as DS
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -37,7 +38,7 @@ type Msg
|
||||
|
||||
init : List String -> List Color -> Model
|
||||
init leftSel colors =
|
||||
{ leftDropdown = Comp.FixedDropdown.initString leftSel
|
||||
{ leftDropdown = Comp.FixedDropdown.init leftSel
|
||||
, colors = colors
|
||||
, leftSelect = Nothing
|
||||
}
|
||||
@ -96,12 +97,21 @@ type alias ViewOpts =
|
||||
|
||||
view2 : FormData -> ViewOpts -> Model -> Html Msg
|
||||
view2 data opts model =
|
||||
let
|
||||
colorLabelCfg =
|
||||
{ display = identity
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text opts.label ]
|
||||
, Html.map LeftMsg
|
||||
(Comp.FixedDropdown.view2
|
||||
(Maybe.map (\s -> Comp.FixedDropdown.Item s s Nothing) model.leftSelect)
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
colorLabelCfg
|
||||
False
|
||||
model.leftSelect
|
||||
model.leftDropdown
|
||||
)
|
||||
, div [ class "field" ]
|
||||
|
@ -11,6 +11,7 @@ import Api.Model.Contact exposing (Contact)
|
||||
import Comp.Basic as B
|
||||
import Comp.FixedDropdown
|
||||
import Data.ContactType exposing (ContactType)
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -30,7 +31,7 @@ emptyModel : Model
|
||||
emptyModel =
|
||||
{ items = []
|
||||
, kind =
|
||||
Comp.FixedDropdown.initMap Data.ContactType.toString Data.ContactType.all
|
||||
Comp.FixedDropdown.init Data.ContactType.all
|
||||
, selectedKind = List.head Data.ContactType.all
|
||||
, value = ""
|
||||
}
|
||||
@ -41,14 +42,6 @@ getContacts model =
|
||||
List.filter (\c -> c.value /= "") model.items
|
||||
|
||||
|
||||
makeDropdownItem : ContactType -> Comp.FixedDropdown.Item ContactType
|
||||
makeDropdownItem ct =
|
||||
{ id = ct
|
||||
, display = Data.ContactType.toString ct
|
||||
, icon = Nothing
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= SetValue String
|
||||
| TypeMsg (Comp.FixedDropdown.Msg ContactType)
|
||||
@ -124,6 +117,13 @@ update msg model =
|
||||
|
||||
view2 : Bool -> UiSettings -> Model -> Html Msg
|
||||
view2 mobile _ model =
|
||||
let
|
||||
kindCfg =
|
||||
{ display = Data.ContactType.toString
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ div
|
||||
[ class "flex flex-col space-y-2"
|
||||
@ -133,8 +133,10 @@ view2 mobile _ model =
|
||||
[ classList [ ( "flex-none md:w-1/6", not mobile ) ]
|
||||
]
|
||||
[ Html.map TypeMsg
|
||||
(Comp.FixedDropdown.view2
|
||||
(Maybe.map makeDropdownItem model.selectedKind)
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
kindCfg
|
||||
False
|
||||
model.selectedKind
|
||||
model.kind
|
||||
)
|
||||
]
|
||||
|
@ -61,8 +61,7 @@ init field =
|
||||
, label = field.label
|
||||
, ftype = Data.CustomFieldType.fromString field.ftype
|
||||
, ftypeModel =
|
||||
Comp.FixedDropdown.initMap Data.CustomFieldType.label
|
||||
Data.CustomFieldType.all
|
||||
Comp.FixedDropdown.init Data.CustomFieldType.all
|
||||
, loading = False
|
||||
, deleteDimmer = Comp.YesNoDimmer.emptyModel
|
||||
}
|
||||
@ -200,11 +199,14 @@ type alias ViewSettings =
|
||||
view2 : ViewSettings -> Model -> List (Html Msg)
|
||||
view2 viewSettings model =
|
||||
let
|
||||
mkItem cft =
|
||||
Comp.FixedDropdown.Item cft (Data.CustomFieldType.label cft) Nothing
|
||||
|
||||
dimmerSettings =
|
||||
Comp.YesNoDimmer.defaultSettings2 "Really delete this custom field?"
|
||||
|
||||
ftypeCfg =
|
||||
{ display = Data.CustomFieldType.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
(if viewSettings.showControls then
|
||||
[ viewButtons2 model ]
|
||||
@ -279,9 +281,9 @@ view2 viewSettings model =
|
||||
]
|
||||
, Html.map FTypeMsg
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
DS.mainStyle
|
||||
ftypeCfg
|
||||
(model.ftype == Nothing)
|
||||
(Maybe.map mkItem model.ftype)
|
||||
model.ftype
|
||||
model.ftypeModel
|
||||
)
|
||||
, div [ class "opacity-75 text-sm" ]
|
||||
|
@ -130,7 +130,7 @@ reset model =
|
||||
mkFieldSelect : List CustomField -> FieldSelect
|
||||
mkFieldSelect fields =
|
||||
{ selected = Nothing
|
||||
, dropdown = Comp.FixedDropdown.init (List.map mkItem fields)
|
||||
, dropdown = Comp.FixedDropdown.init fields
|
||||
}
|
||||
|
||||
|
||||
@ -145,11 +145,6 @@ type alias UpdateResult =
|
||||
}
|
||||
|
||||
|
||||
mkItem : CustomField -> Comp.FixedDropdown.Item CustomField
|
||||
mkItem f =
|
||||
Comp.FixedDropdown.Item f (Maybe.withDefault f.name f.label) Nothing
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> UpdateResult
|
||||
update =
|
||||
update1 False
|
||||
@ -336,7 +331,10 @@ viewMenuBar2 ddstyle viewSettings model =
|
||||
model.fieldSelect
|
||||
|
||||
ddstyleFlex =
|
||||
{ ddstyle | root = ddstyle.root ++ " flex-grow" }
|
||||
{ display = \f -> Maybe.withDefault f.name f.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = { ddstyle | root = ddstyle.root ++ " flex-grow" }
|
||||
}
|
||||
in
|
||||
div
|
||||
[ classList
|
||||
@ -348,7 +346,7 @@ viewMenuBar2 ddstyle viewSettings model =
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
ddstyleFlex
|
||||
False
|
||||
(Maybe.map mkItem selected)
|
||||
selected
|
||||
dropdown
|
||||
)
|
||||
:: (if viewSettings.showAddButton then
|
||||
|
@ -11,6 +11,7 @@ module Comp.EquipmentForm exposing
|
||||
import Api.Model.Equipment exposing (Equipment)
|
||||
import Comp.Basic as B
|
||||
import Comp.FixedDropdown
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.EquipmentUse exposing (EquipmentUse)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
@ -36,9 +37,7 @@ emptyModel =
|
||||
, notes = Nothing
|
||||
, use = Data.EquipmentUse.Concerning
|
||||
, useModel =
|
||||
Comp.FixedDropdown.initMap
|
||||
Data.EquipmentUse.label
|
||||
Data.EquipmentUse.all
|
||||
Comp.FixedDropdown.init Data.EquipmentUse.all
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +101,13 @@ update _ msg model =
|
||||
|
||||
view2 : Model -> Html Msg
|
||||
view2 model =
|
||||
let
|
||||
equipUseCfg =
|
||||
{ display = Data.EquipmentUse.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ div [ class "mb-4" ]
|
||||
[ label
|
||||
@ -132,7 +138,7 @@ view2 model =
|
||||
]
|
||||
[ text "Use" ]
|
||||
, Html.map UseDropdownMsg
|
||||
(Comp.FixedDropdown.view2 (makeUseItem model) model.useModel)
|
||||
(Comp.FixedDropdown.viewStyled2 equipUseCfg False (Just model.use) model.useModel)
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ case model.use of
|
||||
Data.EquipmentUse.Concerning ->
|
||||
@ -156,9 +162,3 @@ view2 model =
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
makeUseItem : Model -> Maybe (Comp.FixedDropdown.Item EquipmentUse)
|
||||
makeUseItem model =
|
||||
Just <|
|
||||
Comp.FixedDropdown.Item model.use (Data.EquipmentUse.label model.use) Nothing
|
||||
|
@ -2,12 +2,9 @@ module Comp.FixedDropdown exposing
|
||||
( Item
|
||||
, Model
|
||||
, Msg
|
||||
, ViewSettings
|
||||
, init
|
||||
, initMap
|
||||
, initString
|
||||
, initTuple
|
||||
, update
|
||||
, view2
|
||||
, viewStyled2
|
||||
)
|
||||
|
||||
@ -22,8 +19,6 @@ import Util.List
|
||||
|
||||
type alias Item a =
|
||||
{ id : a
|
||||
, display : String
|
||||
, icon : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -40,31 +35,17 @@ type Msg a
|
||||
| KeyPress (Maybe KeyCode)
|
||||
|
||||
|
||||
init : List (Item a) -> Model a
|
||||
init options =
|
||||
initItems : List (Item a) -> Model a
|
||||
initItems options =
|
||||
{ options = options
|
||||
, menuOpen = False
|
||||
, selected = Nothing
|
||||
}
|
||||
|
||||
|
||||
initString : List String -> Model String
|
||||
initString strings =
|
||||
init <| List.map (\s -> Item s s Nothing) strings
|
||||
|
||||
|
||||
initMap : (a -> String) -> List a -> Model a
|
||||
initMap elToString els =
|
||||
init <| List.map (\a -> Item a (elToString a) Nothing) els
|
||||
|
||||
|
||||
initTuple : List ( String, a ) -> Model a
|
||||
initTuple tuples =
|
||||
let
|
||||
mkItem ( txt, id ) =
|
||||
Item id txt Nothing
|
||||
in
|
||||
init <| List.map mkItem tuples
|
||||
init : List a -> Model a
|
||||
init els =
|
||||
List.map Item els |> initItems
|
||||
|
||||
|
||||
isSelected : Model a -> Item a -> Bool
|
||||
@ -168,13 +149,20 @@ update msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
viewStyled2 : DS.DropdownStyle -> Bool -> Maybe (Item a) -> Model a -> Html (Msg a)
|
||||
viewStyled2 style error sel model =
|
||||
type alias ViewSettings a =
|
||||
{ display : a -> String
|
||||
, icon : a -> Maybe String
|
||||
, style : DS.DropdownStyle
|
||||
}
|
||||
|
||||
|
||||
viewStyled2 : ViewSettings a -> Bool -> Maybe a -> Model a -> Html (Msg a)
|
||||
viewStyled2 cfg error sel model =
|
||||
let
|
||||
iconItem item =
|
||||
iconItem id =
|
||||
span
|
||||
[ classList [ ( "hidden", item.icon == Nothing ) ]
|
||||
, class (Maybe.withDefault "" item.icon)
|
||||
[ classList [ ( "hidden", cfg.icon id == Nothing ) ]
|
||||
, class (Maybe.withDefault "" (cfg.icon id))
|
||||
, class "mr-2"
|
||||
]
|
||||
[]
|
||||
@ -182,15 +170,15 @@ viewStyled2 style error sel model =
|
||||
renderItem item =
|
||||
a
|
||||
[ href "#"
|
||||
, class style.item
|
||||
, class cfg.style.item
|
||||
, classList
|
||||
[ ( style.itemActive, isSelected model item )
|
||||
, ( "font-semibold", Just item == sel )
|
||||
[ ( cfg.style.itemActive, isSelected model item )
|
||||
, ( "font-semibold", Just item.id == sel )
|
||||
]
|
||||
, onClick (SelectItem2 item)
|
||||
]
|
||||
[ iconItem item
|
||||
, text item.display
|
||||
[ iconItem item.id
|
||||
, text (cfg.display item.id)
|
||||
]
|
||||
|
||||
selIcon =
|
||||
@ -198,11 +186,11 @@ viewStyled2 style error sel model =
|
||||
|> Maybe.withDefault (span [ class "hidden" ] [])
|
||||
in
|
||||
div
|
||||
[ class ("relative " ++ style.root)
|
||||
[ class ("relative " ++ cfg.style.root)
|
||||
, onKeyUpCode KeyPress
|
||||
]
|
||||
[ a
|
||||
[ class style.link
|
||||
[ class cfg.style.link
|
||||
, classList [ ( S.inputErrorBorder, error ) ]
|
||||
, tabindex 0
|
||||
, onClick ToggleMenu
|
||||
@ -215,7 +203,7 @@ viewStyled2 style error sel model =
|
||||
]
|
||||
]
|
||||
[ selIcon
|
||||
, Maybe.map .display sel
|
||||
, Maybe.map cfg.display sel
|
||||
|> Maybe.withDefault "Select…"
|
||||
|> text
|
||||
]
|
||||
@ -226,13 +214,8 @@ viewStyled2 style error sel model =
|
||||
]
|
||||
]
|
||||
, div
|
||||
[ class style.menu
|
||||
[ class cfg.style.menu
|
||||
, classList [ ( "hidden", not model.menuOpen ) ]
|
||||
]
|
||||
(List.map renderItem model.options)
|
||||
]
|
||||
|
||||
|
||||
view2 : Maybe (Item a) -> Model a -> Html (Msg a)
|
||||
view2 =
|
||||
viewStyled2 DS.mainStyle False
|
||||
|
@ -18,6 +18,7 @@ import Comp.Basic as B
|
||||
import Comp.FixedDropdown
|
||||
import Comp.MenuBar as MB
|
||||
import Comp.YesNoDimmer
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -65,8 +66,7 @@ init users folder =
|
||||
, members = folder.members
|
||||
, users = users
|
||||
, memberDropdown =
|
||||
Comp.FixedDropdown.initMap .name
|
||||
(makeOptions users folder)
|
||||
Comp.FixedDropdown.init (makeOptions users folder)
|
||||
, selectedMember = Nothing
|
||||
, loading = False
|
||||
, deleteDimmer = Comp.YesNoDimmer.emptyModel
|
||||
@ -275,11 +275,6 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
makeItem : IdName -> Comp.FixedDropdown.Item IdName
|
||||
makeItem idn =
|
||||
Comp.FixedDropdown.Item idn idn.name Nothing
|
||||
|
||||
|
||||
view2 : Flags -> Model -> Html Msg
|
||||
view2 flags model =
|
||||
let
|
||||
@ -369,6 +364,13 @@ view2 flags model =
|
||||
|
||||
viewMembers2 : Model -> List (Html Msg)
|
||||
viewMembers2 model =
|
||||
let
|
||||
folderCfg =
|
||||
{ display = .name
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
if model.folder.id == "" then
|
||||
[]
|
||||
|
||||
@ -383,8 +385,10 @@ viewMembers2 model =
|
||||
[ div [ class "flex flex-row space-x-2" ]
|
||||
[ div [ class "flex-grow" ]
|
||||
[ Html.map MemberDropdownMsg
|
||||
(Comp.FixedDropdown.view2
|
||||
(Maybe.map makeItem model.selectedMember)
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
folderCfg
|
||||
False
|
||||
model.selectedMember
|
||||
model.memberDropdown
|
||||
)
|
||||
]
|
||||
|
@ -13,6 +13,7 @@ import Comp.AddressForm
|
||||
import Comp.Basic as B
|
||||
import Comp.ContactField
|
||||
import Comp.FixedDropdown
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.OrgUse exposing (OrgUse)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
@ -45,9 +46,7 @@ emptyModel =
|
||||
, shortName = Nothing
|
||||
, use = Data.OrgUse.Correspondent
|
||||
, useModel =
|
||||
Comp.FixedDropdown.initMap
|
||||
Data.OrgUse.label
|
||||
Data.OrgUse.all
|
||||
Comp.FixedDropdown.init Data.OrgUse.all
|
||||
}
|
||||
|
||||
|
||||
@ -147,14 +146,15 @@ update flags msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
makeUseItem : Model -> Maybe (Comp.FixedDropdown.Item OrgUse)
|
||||
makeUseItem model =
|
||||
Just <|
|
||||
Comp.FixedDropdown.Item model.use (Data.OrgUse.label model.use) Nothing
|
||||
|
||||
|
||||
view2 : Bool -> UiSettings -> Model -> Html Msg
|
||||
view2 mobile settings model =
|
||||
let
|
||||
orgUseCfg =
|
||||
{ display = Data.OrgUse.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ div
|
||||
[ class "mb-4" ]
|
||||
@ -203,7 +203,11 @@ view2 mobile settings model =
|
||||
]
|
||||
[ text "Use" ]
|
||||
, Html.map UseDropdownMsg
|
||||
(Comp.FixedDropdown.view2 (makeUseItem model) model.useModel)
|
||||
(Comp.FixedDropdown.viewStyled2 orgUseCfg
|
||||
False
|
||||
(Just model.use)
|
||||
model.useModel
|
||||
)
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ case model.use of
|
||||
Data.OrgUse.Correspondent ->
|
||||
|
@ -46,9 +46,7 @@ emptyModel =
|
||||
, notes = Nothing
|
||||
, use = Data.PersonUse.Both
|
||||
, useModel =
|
||||
Comp.FixedDropdown.initMap
|
||||
Data.PersonUse.label
|
||||
Data.PersonUse.all
|
||||
Comp.FixedDropdown.init Data.PersonUse.all
|
||||
, orgModel = Comp.Dropdown.makeSingle
|
||||
}
|
||||
|
||||
@ -176,18 +174,19 @@ update flags msg model =
|
||||
)
|
||||
|
||||
|
||||
makeUseItem : Model -> Maybe (Comp.FixedDropdown.Item PersonUse)
|
||||
makeUseItem model =
|
||||
Just <|
|
||||
Comp.FixedDropdown.Item model.use (Data.PersonUse.label model.use) Nothing
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : Bool -> UiSettings -> Model -> Html Msg
|
||||
view2 mobile settings model =
|
||||
let
|
||||
personUseCfg =
|
||||
{ display = Data.PersonUse.label
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ div
|
||||
[ class "mb-4"
|
||||
@ -218,7 +217,7 @@ view2 mobile settings model =
|
||||
]
|
||||
[ text "Use of this person" ]
|
||||
, Html.map UseDropdownMsg
|
||||
(Comp.FixedDropdown.view2 (makeUseItem model) model.useModel)
|
||||
(Comp.FixedDropdown.viewStyled2 personUseCfg False (Just model.use) model.useModel)
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ case model.use of
|
||||
Data.PersonUse.Concerning ->
|
||||
|
@ -166,7 +166,7 @@ initWith flags s =
|
||||
, fileFilter = s.fileFilter
|
||||
, subjectFilter = s.subjectFilter
|
||||
, languageModel =
|
||||
Comp.FixedDropdown.init (List.map mkLanguageItem Data.Language.all)
|
||||
Comp.FixedDropdown.init Data.Language.all
|
||||
, language = Maybe.andThen Data.Language.fromString s.language
|
||||
, postHandleAll = Maybe.withDefault False s.postHandleAll
|
||||
, summary = s.summary
|
||||
@ -213,7 +213,7 @@ init flags =
|
||||
, fileFilter = Nothing
|
||||
, subjectFilter = Nothing
|
||||
, languageModel =
|
||||
Comp.FixedDropdown.init (List.map mkLanguageItem Data.Language.all)
|
||||
Comp.FixedDropdown.init Data.Language.all
|
||||
, language = Nothing
|
||||
, postHandleAll = False
|
||||
, summary = Nothing
|
||||
@ -227,11 +227,6 @@ init flags =
|
||||
)
|
||||
|
||||
|
||||
mkLanguageItem : Language -> Comp.FixedDropdown.Item Language
|
||||
mkLanguageItem lang =
|
||||
Comp.FixedDropdown.Item lang (Data.Language.toName lang) Nothing
|
||||
|
||||
|
||||
|
||||
--- Update
|
||||
|
||||
@ -1057,6 +1052,12 @@ viewMetadata2 flags settings model =
|
||||
, labelColor = \_ -> \_ -> ""
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
|
||||
languageCfg =
|
||||
{ display = Data.Language.toName
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyleWith "flex-grow mr-2"
|
||||
}
|
||||
in
|
||||
[ div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
@ -1148,9 +1149,9 @@ disappear then.
|
||||
, div [ class "flex flex-row" ]
|
||||
[ Html.map LanguageMsg
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
(DS.mainStyleWith "flex-grow mr-2")
|
||||
languageCfg
|
||||
False
|
||||
(Maybe.map mkLanguageItem model.language)
|
||||
model.language
|
||||
model.languageModel
|
||||
)
|
||||
, a
|
||||
|
@ -59,9 +59,7 @@ emptyModel =
|
||||
, abbrev = ""
|
||||
, description = Nothing
|
||||
, priorityModel =
|
||||
Comp.FixedDropdown.initMap
|
||||
Data.Priority.toName
|
||||
Data.Priority.all
|
||||
Comp.FixedDropdown.init Data.Priority.all
|
||||
, priority = Data.Priority.Low
|
||||
, enabled = False
|
||||
, folderModel = Comp.Dropdown.makeSingle
|
||||
@ -316,12 +314,6 @@ update flags msg model =
|
||||
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
|
||||
view2 flags texts settings model =
|
||||
let
|
||||
priorityItem =
|
||||
Comp.FixedDropdown.Item
|
||||
model.priority
|
||||
(Data.Priority.toName model.priority)
|
||||
Nothing
|
||||
|
||||
folderCfg =
|
||||
{ makeOption = mkFolderOption flags model.allFolders
|
||||
, placeholder = ""
|
||||
@ -342,6 +334,12 @@ view2 flags texts settings model =
|
||||
, labelColor = \_ -> \_ -> ""
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
|
||||
priorityCfg =
|
||||
{ display = Data.Priority.toName
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
div [ class "flex flex-col" ]
|
||||
[ div [ class "mb-4" ]
|
||||
@ -402,8 +400,10 @@ view2 flags texts settings model =
|
||||
[ text texts.priority
|
||||
]
|
||||
, Html.map PrioDropdownMsg
|
||||
(Comp.FixedDropdown.view2
|
||||
(Just priorityItem)
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
priorityCfg
|
||||
False
|
||||
(Just model.priority)
|
||||
model.priorityModel
|
||||
)
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
|
@ -156,8 +156,7 @@ init flags settings =
|
||||
, powerSearchEnabled = settings.powerSearchEnabled
|
||||
, uiLang = settings.uiLang
|
||||
, uiLangModel =
|
||||
List.map langItem UiLanguage.all
|
||||
|> Comp.FixedDropdown.init
|
||||
Comp.FixedDropdown.init UiLanguage.all
|
||||
, openTabs = Set.empty
|
||||
}
|
||||
, Api.getTags flags "" GetTagsResp
|
||||
@ -187,14 +186,6 @@ type Msg
|
||||
| UiLangMsg (Comp.FixedDropdown.Msg UiLanguage)
|
||||
|
||||
|
||||
langItem : UiLanguage -> Comp.FixedDropdown.Item UiLanguage
|
||||
langItem lang =
|
||||
{ id = lang
|
||||
, display = Messages.get lang |> .label
|
||||
, icon = Just (Messages.get lang |> .flagIcon)
|
||||
}
|
||||
|
||||
|
||||
|
||||
--- Update
|
||||
|
||||
@ -516,6 +507,13 @@ view2 flags settings model =
|
||||
|
||||
settingFormTabs : Flags -> UiSettings -> Model -> List (Comp.Tabs.Tab Msg)
|
||||
settingFormTabs flags _ model =
|
||||
let
|
||||
langCfg =
|
||||
{ display = \lang -> Messages.get lang |> .label
|
||||
, icon = \lang -> Just (Messages.get lang |> .flagIcon)
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
in
|
||||
[ { title = "General"
|
||||
, titleRight = []
|
||||
, info = Nothing
|
||||
@ -532,9 +530,10 @@ settingFormTabs flags _ model =
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ] [ text "UI Language" ]
|
||||
, Html.map UiLangMsg
|
||||
(Comp.FixedDropdown.viewStyled2 DS.mainStyle
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
langCfg
|
||||
False
|
||||
(Just <| langItem model.uiLang)
|
||||
(Just model.uiLang)
|
||||
model.uiLangModel
|
||||
)
|
||||
]
|
||||
|
@ -13,7 +13,6 @@ module Page.Home.Data exposing
|
||||
, itemNav
|
||||
, menuCollapsed
|
||||
, resultsBelowLimit
|
||||
, searchTypeString
|
||||
, selectActive
|
||||
)
|
||||
|
||||
@ -30,7 +29,6 @@ import Comp.ItemDetail.MultiEditMenu exposing (SaveNameState(..))
|
||||
import Comp.LinkTarget exposing (LinkTarget)
|
||||
import Comp.PowerSearchInput
|
||||
import Comp.SearchMenu
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemNav exposing (ItemNav)
|
||||
import Data.ItemQuery as Q
|
||||
@ -110,8 +108,7 @@ init flags viewMode =
|
||||
, moreInProgress = False
|
||||
, throttle = Throttle.create 1
|
||||
, searchTypeDropdown =
|
||||
Comp.FixedDropdown.initMap searchTypeString
|
||||
searchTypeOptions
|
||||
Comp.FixedDropdown.init searchTypeOptions
|
||||
, searchTypeDropdownValue =
|
||||
if Comp.SearchMenu.isFulltextSearch searchMenuModel then
|
||||
ContentOnlySearch
|
||||
@ -226,16 +223,6 @@ type alias SearchParam =
|
||||
}
|
||||
|
||||
|
||||
searchTypeString : SearchType -> String
|
||||
searchTypeString st =
|
||||
case st of
|
||||
BasicSearch ->
|
||||
"Names"
|
||||
|
||||
ContentOnlySearch ->
|
||||
"Contents"
|
||||
|
||||
|
||||
itemNav : String -> Model -> ItemNav
|
||||
itemNav id model =
|
||||
Data.ItemNav.fromList model.itemListModel.results id
|
||||
|
@ -9,7 +9,6 @@ module Page.Upload.Data exposing
|
||||
, isIdle
|
||||
, isLoading
|
||||
, isSuccessAll
|
||||
, mkLanguageItem
|
||||
, uploadAllTracker
|
||||
)
|
||||
|
||||
@ -38,11 +37,6 @@ type alias Model =
|
||||
}
|
||||
|
||||
|
||||
mkLanguageItem : Language -> Comp.FixedDropdown.Item Language
|
||||
mkLanguageItem lang =
|
||||
Comp.FixedDropdown.Item lang (Data.Language.toName lang) Nothing
|
||||
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
{ incoming = True
|
||||
@ -54,8 +48,7 @@ emptyModel =
|
||||
, dropzone = Comp.Dropzone.init []
|
||||
, skipDuplicates = True
|
||||
, languageModel =
|
||||
Comp.FixedDropdown.init
|
||||
(List.map mkLanguageItem Data.Language.all)
|
||||
Comp.FixedDropdown.init Data.Language.all
|
||||
, language = Nothing
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import Comp.FixedDropdown
|
||||
import Comp.Progress
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Language
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Dict
|
||||
import File exposing (File)
|
||||
@ -71,6 +72,13 @@ viewContent texts mid _ _ model =
|
||||
|
||||
renderForm : Texts -> Model -> Html Msg
|
||||
renderForm texts model =
|
||||
let
|
||||
languageCfg =
|
||||
{ display = Data.Language.toName
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyleWith "w-40"
|
||||
}
|
||||
in
|
||||
div [ class "row" ]
|
||||
[ Html.form [ action "#" ]
|
||||
[ div [ class "flex flex-col mb-3" ]
|
||||
@ -128,9 +136,9 @@ renderForm texts model =
|
||||
[ span [ class "mr-2" ] [ text (texts.language ++ ":") ]
|
||||
, Html.map LanguageMsg
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
(DS.mainStyleWith "w-40")
|
||||
languageCfg
|
||||
False
|
||||
(Maybe.map mkLanguageItem model.language)
|
||||
model.language
|
||||
model.languageModel
|
||||
)
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user