Apply tag colors from settings

This commit is contained in:
Eike Kettner
2020-06-08 00:54:47 +02:00
parent 1cd65b7b7c
commit 1dd84c11bd
39 changed files with 375 additions and 341 deletions

View File

@ -9,6 +9,7 @@ module Comp.AddressForm exposing
import Api.Model.Address exposing (Address)
import Comp.Dropdown
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
@ -105,8 +106,8 @@ update msg model =
( { model | country = m1 }, Cmd.map CountryMsg c1 )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div
[ class "field"
@ -146,6 +147,6 @@ view model =
]
, div [ class "field" ]
[ label [] [ text "Country" ]
, Html.map CountryMsg (Comp.Dropdown.view model.country)
, Html.map CountryMsg (Comp.Dropdown.view settings model.country)
]
]

View File

@ -11,6 +11,7 @@ import Api.Model.CollectiveSettings exposing (CollectiveSettings)
import Comp.Dropdown
import Data.Flags exposing (Flags)
import Data.Language exposing (Language)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck)
@ -90,12 +91,12 @@ update _ msg model =
( nextModel, Cmd.none, Just (getSettings nextModel) )
view : Flags -> Model -> Html Msg
view flags model =
view : Flags -> UiSettings -> Model -> Html Msg
view flags settings model =
div [ class "ui form" ]
[ div [ class "field" ]
[ label [] [ text "Document Language" ]
, Html.map LangDropdownMsg (Comp.Dropdown.view model.langModel)
, Html.map LangDropdownMsg (Comp.Dropdown.view settings model.langModel)
, span [ class "small-info" ]
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
]

View File

@ -10,6 +10,7 @@ module Comp.ContactField exposing
import Api.Model.Contact exposing (Contact)
import Comp.Dropdown
import Data.ContactType exposing (ContactType)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
@ -96,12 +97,12 @@ update msg model =
( { m1 | value = contact.value, items = newItems }, c1 )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div []
[ div [ class "fields" ]
[ div [ class "four wide field" ]
[ Html.map TypeMsg (Comp.Dropdown.view model.kind)
[ Html.map TypeMsg (Comp.Dropdown.view settings model.kind)
]
, div [ class "twelve wide field" ]
[ div [ class "ui action input" ]

View File

@ -12,6 +12,7 @@ module Comp.Dropdown exposing
, view
)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
@ -52,7 +53,7 @@ type alias Model a =
, makeOption : a -> Option
, menuOpen : Bool
, filterString : String
, labelColor : a -> String
, labelColor : a -> UiSettings -> String
, searchable : Int -> Bool
, placeholder : String
}
@ -62,7 +63,7 @@ makeModel :
{ multiple : Bool
, searchable : Int -> Bool
, makeOption : a -> Option
, labelColor : a -> String
, labelColor : a -> UiSettings -> String
, placeholder : String
}
-> Model a
@ -89,7 +90,7 @@ makeSingle opts =
{ multiple = False
, searchable = \n -> n > 8
, makeOption = opts.makeOption
, labelColor = \_ -> ""
, labelColor = \_ -> \_ -> ""
, placeholder = opts.placeholder
}
@ -119,7 +120,7 @@ makeSingleList opts =
makeMultiple :
{ makeOption : a -> Option
, labelColor : a -> String
, labelColor : a -> UiSettings -> String
}
-> Model a
makeMultiple opts =
@ -363,10 +364,10 @@ update msg model =
-- View
view : Model a -> Html (Msg a)
view model =
view : UiSettings -> Model a -> Html (Msg a)
view settings model =
if model.multiple then
viewMultiple model
viewMultiple settings model
else
viewSingle model
@ -422,15 +423,15 @@ viewSingle model =
)
viewMultiple : Model a -> Html (Msg a)
viewMultiple model =
viewMultiple : UiSettings -> Model a -> Html (Msg a)
viewMultiple settings model =
let
renderSelectMultiple : Item a -> Html (Msg a)
renderSelectMultiple item =
div
[ classList
[ ( "ui label", True )
, ( model.labelColor item.value, True )
, ( model.labelColor item.value settings, True )
]
, style "display" "inline-block !important"
, onClick (RemoveItem item)

View File

@ -14,6 +14,7 @@ import Comp.Dropdown
import Comp.IntField
import Comp.PasswordInput
import Data.SSLType exposing (SSLType)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onInput)
@ -165,8 +166,8 @@ update msg model =
( { model | ignoreCertificates = not model.ignoreCertificates }, Cmd.none )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div
[ classList
[ ( "ui form", True )
@ -258,7 +259,7 @@ view model =
, div [ class "two fields" ]
[ div [ class "field" ]
[ label [] [ text "SSL" ]
, Html.map SSLTypeMsg (Comp.Dropdown.view model.sslType)
, Html.map SSLTypeMsg (Comp.Dropdown.view settings model.sslType)
]
]
]

View File

@ -15,6 +15,7 @@ import Comp.EmailSettingsForm
import Comp.EmailSettingsTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
@ -199,14 +200,14 @@ update flags msg model =
( { model | loading = False }, Cmd.none )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
case model.viewMode of
Table ->
viewTable model
Form ->
viewForm model
viewForm settings model
viewTable : Model -> Html Msg
@ -243,11 +244,11 @@ viewTable model =
]
viewForm : Model -> Html Msg
viewForm model =
viewForm : UiSettings -> Model -> Html Msg
viewForm settings model =
div [ class "ui segment" ]
[ Html.map YesNoMsg (Comp.YesNoDimmer.view model.deleteConfirm)
, Html.map FormMsg (Comp.EmailSettingsForm.view model.formModel)
, Html.map FormMsg (Comp.EmailSettingsForm.view settings model.formModel)
, div
[ classList
[ ( "ui error message", True )

View File

@ -14,6 +14,7 @@ import Comp.Dropdown
import Comp.IntField
import Comp.PasswordInput
import Data.SSLType exposing (SSLType)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onInput)
@ -149,8 +150,8 @@ update msg model =
( { model | ignoreCertificates = not model.ignoreCertificates }, Cmd.none )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div
[ classList
[ ( "ui form", True )
@ -220,7 +221,7 @@ view model =
, div [ class "two fields" ]
[ div [ class "field" ]
[ label [] [ text "SSL" ]
, Html.map SSLTypeMsg (Comp.Dropdown.view model.sslType)
, Html.map SSLTypeMsg (Comp.Dropdown.view settings model.sslType)
]
]
]

View File

@ -15,6 +15,7 @@ import Comp.ImapSettingsForm
import Comp.ImapSettingsTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
@ -199,14 +200,14 @@ update flags msg model =
( { model | loading = False }, Cmd.none )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
case model.viewMode of
Table ->
viewTable model
Form ->
viewForm model
viewForm settings model
viewTable : Model -> Html Msg
@ -243,11 +244,11 @@ viewTable model =
]
viewForm : Model -> Html Msg
viewForm model =
viewForm : UiSettings -> Model -> Html Msg
viewForm settings model =
div [ class "ui segment" ]
[ Html.map YesNoMsg (Comp.YesNoDimmer.view model.deleteConfirm)
, Html.map FormMsg (Comp.ImapSettingsForm.view model.formModel)
, Html.map FormMsg (Comp.ImapSettingsForm.view settings model.formModel)
, div
[ classList
[ ( "ui error message", True )

View File

@ -15,6 +15,7 @@ import Data.Direction
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.Items
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -97,26 +98,26 @@ update _ msg model =
--- View
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui container" ]
(List.map viewGroup model.results.groups)
(List.map (viewGroup settings) model.results.groups)
viewGroup : ItemLightGroup -> Html Msg
viewGroup group =
viewGroup : UiSettings -> ItemLightGroup -> Html Msg
viewGroup settings group =
div [ class "item-group" ]
[ div [ class "ui horizontal divider header item-list" ]
[ i [ class "calendar alternate outline icon" ] []
, text group.name
]
, div [ class "ui stackable three cards" ]
(List.map viewItem group.items)
(List.map (viewItem settings) group.items)
]
viewItem : ItemLight -> Html Msg
viewItem item =
viewItem : UiSettings -> ItemLight -> Html Msg
viewItem settings item =
let
dirIcon =
i [ class (Data.Direction.iconFromMaybe item.direction) ] []
@ -193,7 +194,7 @@ viewItem item =
div
[ classList
[ ( "ui basic label", True )
, ( "blue", tag.category /= Nothing )
, ( Data.UiSettings.tagColorString tag settings, True )
]
]
[ text tag.name ]

View File

@ -34,6 +34,7 @@ import Comp.YesNoDimmer
import Data.Direction exposing (Direction)
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import DatePicker exposing (DatePicker)
import Dict exposing (Dict)
import File exposing (File)
@ -52,6 +53,7 @@ import Util.List
import Util.Maybe
import Util.Size
import Util.String
import Util.Tag
import Util.Time
@ -119,16 +121,7 @@ emptyModel =
, visibleAttach = 0
, menuOpen = False
, tagModel =
Comp.Dropdown.makeMultiple
{ makeOption = \tag -> { value = tag.id, text = tag.name }
, labelColor =
\tag ->
if Util.Maybe.nonEmpty tag.category then
"basic blue"
else
""
}
Util.Tag.makeDropdownModel
, directionModel =
Comp.Dropdown.makeSingleList
{ makeOption =
@ -1215,10 +1208,10 @@ actionInputDatePicker =
{ ds | containerClassList = [ ( "ui action input", True ) ] }
view : { prev : Maybe String, next : Maybe String } -> Model -> Html Msg
view inav model =
view : { prev : Maybe String, next : Maybe String } -> UiSettings -> Model -> Html Msg
view inav settings model =
div []
[ renderItemInfo model
[ renderItemInfo settings model
, div
[ classList
[ ( "ui ablue-comp menu", True )
@ -1307,7 +1300,7 @@ view inav model =
[ Icons.addFilesIcon
]
]
, renderMailForm model
, renderMailForm settings model
, renderAddFilesForm model
, renderNotes model
, div [ class "ui grid" ]
@ -1319,7 +1312,7 @@ view inav model =
]
]
(if model.menuOpen then
renderEditMenu model
renderEditMenu settings model
else
[]
@ -1655,8 +1648,8 @@ renderAttachmentsTabBody model =
++ mailTab
renderItemInfo : Model -> Html Msg
renderItemInfo model =
renderItemInfo : UiSettings -> Model -> Html Msg
renderItemInfo settings model =
let
date =
div
@ -1749,12 +1742,12 @@ renderItemInfo model =
]
]
]
:: renderTags model
:: renderTags settings model
)
renderTags : Model -> List (Html Msg)
renderTags model =
renderTags : UiSettings -> Model -> List (Html Msg)
renderTags settings model =
case model.item.tags of
[] ->
[]
@ -1766,7 +1759,7 @@ renderTags model =
div
[ classList
[ ( "ui tag label", True )
, ( "blue", Util.Maybe.nonEmpty t.category )
, ( Data.UiSettings.tagColorString t settings, True )
]
]
[ text t.name
@ -1776,10 +1769,10 @@ renderTags model =
]
renderEditMenu : Model -> List (Html Msg)
renderEditMenu model =
renderEditMenu : UiSettings -> Model -> List (Html Msg)
renderEditMenu settings model =
[ renderEditButtons model
, renderEditForm model
, renderEditForm settings model
]
@ -1813,8 +1806,8 @@ renderEditButtons model =
]
renderEditForm : Model -> Html Msg
renderEditForm model =
renderEditForm : UiSettings -> Model -> Html Msg
renderEditForm settings model =
div [ class "ui attached segment" ]
[ div [ class "ui form" ]
[ div [ class "field" ]
@ -1822,7 +1815,7 @@ renderEditForm model =
[ i [ class "tags icon" ] []
, text "Tags"
]
, Html.map TagDropdownMsg (Comp.Dropdown.view model.tagModel)
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
]
, div [ class " field" ]
[ label [] [ text "Name" ]
@ -1838,7 +1831,7 @@ renderEditForm model =
]
, div [ class "field" ]
[ label [] [ text "Direction" ]
, Html.map DirDropdownMsg (Comp.Dropdown.view model.directionModel)
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
]
, div [ class " field" ]
[ label [] [ text "Date" ]
@ -1875,12 +1868,12 @@ renderEditForm model =
]
, div [ class "field" ]
[ label [] [ text "Organization" ]
, Html.map OrgDropdownMsg (Comp.Dropdown.view model.corrOrgModel)
, Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel)
, renderOrgSuggestions model
]
, div [ class "field" ]
[ label [] [ text "Person" ]
, Html.map CorrPersonMsg (Comp.Dropdown.view model.corrPersonModel)
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
, renderCorrPersonSuggestions model
]
, h4 [ class "ui dividing header" ]
@ -1889,12 +1882,12 @@ renderEditForm model =
]
, div [ class "field" ]
[ label [] [ text "Person" ]
, Html.map ConcPersonMsg (Comp.Dropdown.view model.concPersonModel)
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
, renderConcPersonSuggestions model
]
, div [ class "field" ]
[ label [] [ text "Equipment" ]
, Html.map ConcEquipMsg (Comp.Dropdown.view model.concEquipModel)
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
, renderConcEquipSuggestions model
]
]
@ -1970,8 +1963,8 @@ renderDueDateSuggestions model =
SetDueDateSuggestion
renderMailForm : Model -> Html Msg
renderMailForm model =
renderMailForm : UiSettings -> Model -> Html Msg
renderMailForm settings model =
div
[ classList
[ ( "ui bottom attached segment", True )
@ -1991,7 +1984,7 @@ renderMailForm model =
[ text "Sending "
]
]
, Html.map ItemMailMsg (Comp.ItemMail.view model.itemMail)
, Html.map ItemMailMsg (Comp.ItemMail.view settings model.itemMail)
, div
[ classList
[ ( "ui message", True )

View File

@ -15,6 +15,7 @@ import Api.Model.SimpleMail exposing (SimpleMail)
import Comp.Dropdown
import Comp.EmailInput
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
@ -173,8 +174,8 @@ isValid model =
== Nothing
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div
[ classList
[ ( "ui form", True )
@ -183,7 +184,7 @@ view model =
]
[ div [ class "field" ]
[ label [] [ text "Send via" ]
, Html.map ConnMsg (Comp.Dropdown.view model.connectionModel)
, Html.map ConnMsg (Comp.Dropdown.view settings model.connectionModel)
]
, div [ class "ui error message" ]
[ Maybe.withDefault "" model.formError |> text

View File

@ -18,6 +18,7 @@ import Comp.EmailInput
import Comp.IntField
import Data.CalEvent exposing (CalEvent)
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Data.Validated exposing (Validated(..))
import Html exposing (..)
import Html.Attributes exposing (..)
@ -73,8 +74,8 @@ initCmd flags =
]
init : Flags -> ( Model, Cmd Msg )
init flags =
init : Flags -> UiSettings -> ( Model, Cmd Msg )
init flags settings =
let
initialSchedule =
Data.Validated.Unknown Data.CalEvent.everyMonth
@ -415,8 +416,8 @@ isFormSuccess model =
|> Maybe.withDefault False
view : String -> Model -> Html Msg
view extraClasses model =
view : String -> UiSettings -> Model -> Html Msg
view extraClasses settings model =
div
[ classList
[ ( "ui form", True )
@ -451,7 +452,7 @@ view extraClasses model =
]
, div [ class "required field" ]
[ label [] [ text "Send via" ]
, Html.map ConnMsg (Comp.Dropdown.view model.connectionModel)
, Html.map ConnMsg (Comp.Dropdown.view settings model.connectionModel)
, span [ class "small-info" ]
[ text "The SMTP connection to use when sending notification mails."
]
@ -468,14 +469,14 @@ view extraClasses model =
]
, div [ class "field" ]
[ label [] [ text "Tags Include (and)" ]
, Html.map TagIncMsg (Comp.Dropdown.view model.tagInclModel)
, Html.map TagIncMsg (Comp.Dropdown.view settings model.tagInclModel)
, span [ class "small-info" ]
[ text "Items must have all the tags specified here."
]
]
, div [ class "field" ]
[ label [] [ text "Tags Exclude (or)" ]
, Html.map TagExcMsg (Comp.Dropdown.view model.tagExclModel)
, Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel)
, span [ class "small-info" ]
[ text "Items must not have any tag specified here."
]

View File

@ -12,6 +12,7 @@ import Api.Model.Organization exposing (Organization)
import Comp.AddressForm
import Comp.ContactField
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
@ -106,8 +107,8 @@ update flags msg model =
)
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div
[ classList
@ -127,11 +128,11 @@ view model =
, h3 [ class "ui dividing header" ]
[ text "Address"
]
, Html.map AddressMsg (Comp.AddressForm.view model.addressModel)
, Html.map AddressMsg (Comp.AddressForm.view settings model.addressModel)
, h3 [ class "ui dividing header" ]
[ text "Contacts"
]
, Html.map ContactMsg (Comp.ContactField.view model.contactModel)
, Html.map ContactMsg (Comp.ContactField.view settings model.contactModel)
, h3 [ class "ui dividing header" ]
[ text "Notes"
]

View File

@ -14,6 +14,7 @@ import Comp.OrgForm
import Comp.OrgTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
@ -197,13 +198,13 @@ update flags msg model =
( m, Api.getOrganizations flags str OrgResp )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
if model.viewMode == Table then
viewTable model
else
viewForm model
viewForm settings model
viewTable : Model -> Html Msg
@ -248,8 +249,8 @@ viewTable model =
]
viewForm : Model -> Html Msg
viewForm model =
viewForm : UiSettings -> Model -> Html Msg
viewForm settings model =
let
newOrg =
model.formModel.org.id == ""
@ -269,7 +270,7 @@ viewForm model =
, text model.formModel.org.id
]
]
, Html.map FormMsg (Comp.OrgForm.view model.formModel)
, Html.map FormMsg (Comp.OrgForm.view settings model.formModel)
, div
[ classList
[ ( "ui error message", True )

View File

@ -12,6 +12,7 @@ import Api.Model.Person exposing (Person)
import Comp.AddressForm
import Comp.ContactField
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onInput)
@ -120,8 +121,8 @@ update flags msg model =
( { model | concerning = not model.concerning }, Cmd.none )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div
[ classList
@ -152,11 +153,11 @@ view model =
, h3 [ class "ui dividing header" ]
[ text "Address"
]
, Html.map AddressMsg (Comp.AddressForm.view model.addressModel)
, Html.map AddressMsg (Comp.AddressForm.view settings model.addressModel)
, h3 [ class "ui dividing header" ]
[ text "Contacts"
]
, Html.map ContactMsg (Comp.ContactField.view model.contactModel)
, Html.map ContactMsg (Comp.ContactField.view settings model.contactModel)
, h3 [ class "ui dividing header" ]
[ text "Notes"
]

View File

@ -14,6 +14,7 @@ import Comp.PersonForm
import Comp.PersonTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
@ -197,13 +198,13 @@ update flags msg model =
( m, Api.getPersons flags str PersonResp )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
if model.viewMode == Table then
viewTable model
else
viewForm model
viewForm settings model
viewTable : Model -> Html Msg
@ -248,8 +249,8 @@ viewTable model =
]
viewForm : Model -> Html Msg
viewForm model =
viewForm : UiSettings -> Model -> Html Msg
viewForm settings model =
let
newPerson =
model.formModel.org.id == ""
@ -263,13 +264,13 @@ viewForm model =
else
h3 [ class "ui dividing header" ]
[ text ("Edit org: " ++ model.formModel.org.name)
[ text ("Edit person: " ++ model.formModel.org.name)
, div [ class "sub header" ]
[ text "Id: "
, text model.formModel.org.id
]
]
, Html.map FormMsg (Comp.PersonForm.view model.formModel)
, Html.map FormMsg (Comp.PersonForm.view settings model.formModel)
, div
[ classList
[ ( "ui error message", True )

View File

@ -20,6 +20,7 @@ import Comp.YesNoDimmer
import Data.CalEvent exposing (CalEvent)
import Data.Direction exposing (Direction(..))
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Data.Validated exposing (Validated(..))
import Html exposing (..)
import Html.Attributes exposing (..)
@ -419,8 +420,8 @@ isFormSuccess model =
|> Maybe.withDefault False
view : String -> Model -> Html Msg
view extraClasses model =
view : String -> UiSettings -> Model -> Html Msg
view extraClasses settings model =
div
[ classList
[ ( "ui form", True )
@ -456,7 +457,7 @@ view extraClasses model =
]
, div [ class "required field" ]
[ label [] [ text "Mailbox" ]
, Html.map ConnMsg (Comp.Dropdown.view model.connectionModel)
, Html.map ConnMsg (Comp.Dropdown.view settings model.connectionModel)
, span [ class "small-info" ]
[ text "The IMAP connection to use when sending notification mails."
]

View File

@ -13,6 +13,7 @@ import Api.Model.ScanMailboxSettingsList exposing (ScanMailboxSettingsList)
import Comp.ScanMailboxForm
import Comp.ScanMailboxList
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -198,8 +199,8 @@ update flags msg model =
--- View
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div []
[ div [ class "ui menu" ]
[ a
@ -224,17 +225,17 @@ view model =
|> text
]
, case model.detailModel of
Just settings ->
viewForm settings
Just msett ->
viewForm settings msett
Nothing ->
viewList model
]
viewForm : Comp.ScanMailboxForm.Model -> Html Msg
viewForm model =
Html.map DetailMsg (Comp.ScanMailboxForm.view "segment" model)
viewForm : UiSettings -> Comp.ScanMailboxForm.Model -> Html Msg
viewForm settings model =
Html.map DetailMsg (Comp.ScanMailboxForm.view "segment" settings model)
viewList : Model -> Html Msg

View File

@ -2,8 +2,8 @@ module Comp.SearchMenu exposing
( Model
, Msg(..)
, NextState
, emptyModel
, getItemSearch
, init
, update
, view
)
@ -20,6 +20,7 @@ import Comp.DatePicker
import Comp.Dropdown exposing (isDropdownChangeMsg)
import Data.Direction exposing (Direction)
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import DatePicker exposing (DatePicker)
import Html exposing (..)
import Html.Attributes exposing (..)
@ -55,8 +56,8 @@ type alias Model =
}
emptyModel : Model
emptyModel =
init : Model
init =
{ tagInclModel = Util.Tag.makeDropdownModel
, tagExclModel = Util.Tag.makeDropdownModel
, directionModel =
@ -75,7 +76,7 @@ emptyModel =
{ multiple = False
, searchable = \n -> n > 5
, makeOption = \e -> { value = e.id, text = e.name }
, labelColor = \_ -> ""
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an organization"
}
, corrPersonModel =
@ -93,7 +94,7 @@ emptyModel =
{ multiple = False
, searchable = \n -> n > 5
, makeOption = \e -> { value = e.id, text = e.name }
, labelColor = \_ -> ""
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an equipment"
}
, inboxCheckbox = False
@ -184,8 +185,8 @@ noChange p =
NextState p False
update : Flags -> Msg -> Model -> NextState
update flags msg model =
update : Flags -> UiSettings -> Msg -> Model -> NextState
update flags settings msg model =
case msg of
Init ->
let
@ -193,25 +194,24 @@ update flags msg model =
Comp.DatePicker.init
( mdp, cdp ) =
case model.datePickerInitialized of
True ->
( model, Cmd.none )
if model.datePickerInitialized then
( model, Cmd.none )
False ->
( { model
| untilDateModel = dp
, fromDateModel = dp
, untilDueDateModel = dp
, fromDueDateModel = dp
, datePickerInitialized = True
}
, Cmd.batch
[ Cmd.map UntilDateMsg dpc
, Cmd.map FromDateMsg dpc
, Cmd.map UntilDueDateMsg dpc
, Cmd.map FromDueDateMsg dpc
]
)
else
( { model
| untilDateModel = dp
, fromDateModel = dp
, untilDueDateModel = dp
, fromDueDateModel = dp
, datePickerInitialized = True
}
, Cmd.batch
[ Cmd.map UntilDateMsg dpc
, Cmd.map FromDateMsg dpc
, Cmd.map UntilDueDateMsg dpc
, Cmd.map FromDueDateMsg dpc
]
)
in
noChange
( mdp
@ -227,7 +227,7 @@ update flags msg model =
ResetForm ->
let
next =
update flags Init emptyModel
update flags settings Init init
in
{ next | stateChange = True }
@ -238,8 +238,8 @@ update flags msg model =
in
noChange <|
Util.Update.andThen1
[ update flags (TagIncMsg tagList) >> .modelCmd
, update flags (TagExcMsg tagList) >> .modelCmd
[ update flags settings (TagIncMsg tagList) >> .modelCmd
, update flags settings (TagExcMsg tagList) >> .modelCmd
]
model
@ -251,7 +251,7 @@ update flags msg model =
opts =
Comp.Dropdown.SetOptions equips.items
in
update flags (ConcEquipmentMsg opts) model
update flags settings (ConcEquipmentMsg opts) model
GetEquipResp (Err _) ->
noChange ( model, Cmd.none )
@ -261,7 +261,7 @@ update flags msg model =
opts =
Comp.Dropdown.SetOptions orgs.items
in
update flags (OrgMsg opts) model
update flags settings (OrgMsg opts) model
GetOrgResp (Err _) ->
noChange ( model, Cmd.none )
@ -273,8 +273,8 @@ update flags msg model =
in
noChange <|
Util.Update.andThen1
[ update flags (CorrPersonMsg opts) >> .modelCmd
, update flags (ConcPersonMsg opts) >> .modelCmd
[ update flags settings (CorrPersonMsg opts) >> .modelCmd
, update flags settings (ConcPersonMsg opts) >> .modelCmd
]
model
@ -461,8 +461,8 @@ update flags msg model =
-- View
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div [ class "inline field" ]
[ div [ class "ui checkbox" ]
@ -493,18 +493,18 @@ view model =
]
, div [ class "field" ]
[ label [] [ text "Direction" ]
, Html.map DirectionMsg (Comp.Dropdown.view model.directionModel)
, Html.map DirectionMsg (Comp.Dropdown.view settings model.directionModel)
]
, h3 [ class "ui header" ]
[ text "Tags"
]
, div [ class "field" ]
[ label [] [ text "Include (and)" ]
, Html.map TagIncMsg (Comp.Dropdown.view model.tagInclModel)
, Html.map TagIncMsg (Comp.Dropdown.view settings model.tagInclModel)
]
, div [ class "field" ]
[ label [] [ text "Exclude (or)" ]
, Html.map TagExcMsg (Comp.Dropdown.view model.tagExclModel)
, Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel)
]
, h3 [ class "ui header" ]
[ case getDirection model of
@ -519,22 +519,22 @@ view model =
]
, div [ class "field" ]
[ label [] [ text "Organization" ]
, Html.map OrgMsg (Comp.Dropdown.view model.orgModel)
, Html.map OrgMsg (Comp.Dropdown.view settings model.orgModel)
]
, div [ class "field" ]
[ label [] [ text "Person" ]
, Html.map CorrPersonMsg (Comp.Dropdown.view model.corrPersonModel)
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
]
, h3 [ class "ui header" ]
[ text "Concerned"
]
, div [ class "field" ]
[ label [] [ text "Person" ]
, Html.map ConcPersonMsg (Comp.Dropdown.view model.concPersonModel)
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
]
, div [ class "field" ]
[ label [] [ text "Equipment" ]
, Html.map ConcEquipmentMsg (Comp.Dropdown.view model.concEquipmentModel)
, Html.map ConcEquipmentMsg (Comp.Dropdown.view settings model.concEquipmentModel)
]
, h3 [ class "ui header" ]
[ text "Date"

View File

@ -21,23 +21,23 @@ import Util.List
type alias Model =
{ defaults : UiSettings
, input : StoredUiSettings
{ itemSearchPageSize : Maybe Int
, searchPageSizeModel : Comp.IntField.Model
, tagColors : Dict String String
, tagColorModel : Comp.MappingForm.Model
}
init : Flags -> UiSettings -> ( Model, Cmd Msg )
init flags defaults =
( { defaults = defaults
, input = Data.UiSettings.toStoredUiSettings defaults
init flags settings =
( { itemSearchPageSize = Just settings.itemSearchPageSize
, searchPageSizeModel =
Comp.IntField.init
(Just 10)
(Just 500)
False
"Page size"
, tagColors = settings.tagCategoryColors
, tagColorModel =
Comp.MappingForm.init
[]
@ -47,42 +47,32 @@ init flags defaults =
)
changeInput : (StoredUiSettings -> StoredUiSettings) -> Model -> StoredUiSettings
changeInput change model =
change model.input
type Msg
= SearchPageSizeMsg Comp.IntField.Msg
| TagColorMsg Comp.MappingForm.Msg
| GetTagsResp (Result Http.Error TagList)
getSettings : Model -> UiSettings
getSettings model =
Data.UiSettings.merge model.input model.defaults
--- Update
update : Msg -> Model -> ( Model, Maybe UiSettings )
update msg model =
update : UiSettings -> Msg -> Model -> ( Model, Maybe UiSettings )
update sett msg model =
case msg of
SearchPageSizeMsg lm ->
let
( m, n ) =
Comp.IntField.update lm model.searchPageSizeModel
nextSettings =
Maybe.map (\sz -> { sett | itemSearchPageSize = sz }) n
model_ =
{ model
| searchPageSizeModel = m
, input = changeInput (\s -> { s | itemSearchPageSize = n }) model
, itemSearchPageSize = n
}
nextSettings =
Maybe.map (\_ -> getSettings model_) n
in
( model_, nextSettings )
@ -91,23 +81,16 @@ update msg model =
( m_, d_ ) =
Comp.MappingForm.update lm model.tagColorModel
newData =
case d_ of
Just data ->
Dict.toList data
Nothing ->
model.input.tagCategoryColors
nextSettings =
Maybe.map (\tc -> { sett | tagCategoryColors = tc }) d_
model_ =
{ model
| tagColorModel = m_
, input = changeInput (\s -> { s | tagCategoryColors = newData }) model
, tagColors = Maybe.withDefault model.tagColors d_
}
in
( model_
, Maybe.map (\_ -> getSettings model_) d_
)
( model_, nextSettings )
GetTagsResp (Ok tl) ->
let
@ -143,8 +126,8 @@ tagColorViewOpts =
}
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div [ class "ui dividing header" ]
[ text "Item Search"
@ -152,7 +135,7 @@ view model =
, Html.map SearchPageSizeMsg
(Comp.IntField.viewWithInfo
"Maximum results in one page when searching items."
model.input.itemSearchPageSize
model.itemSearchPageSize
"field"
model.searchPageSizeModel
)
@ -161,7 +144,7 @@ view model =
]
, Html.map TagColorMsg
(Comp.MappingForm.view
(Dict.fromList model.input.tagCategoryColors)
model.tagColors
tagColorViewOpts
model.tagColorModel
)

View File

@ -1,6 +1,6 @@
module Comp.UiSettingsManage exposing
( Model
, Msg
, Msg(..)
, init
, update
, view
@ -27,13 +27,14 @@ type Msg
= UiSettingsFormMsg Comp.UiSettingsForm.Msg
| Submit
| SettingsSaved
| UpdateSettings
init : Flags -> UiSettings -> ( Model, Cmd Msg )
init flags defaults =
init flags settings =
let
( fm, fc ) =
Comp.UiSettingsForm.init flags defaults
Comp.UiSettingsForm.init flags settings
in
( { formModel = fm
, settings = Nothing
@ -47,13 +48,13 @@ init flags defaults =
--- update
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
update flags msg model =
update : Flags -> UiSettings -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
update flags settings msg model =
case msg of
UiSettingsFormMsg lm ->
let
( m_, sett ) =
Comp.UiSettingsForm.update lm model.formModel
Comp.UiSettingsForm.update settings lm model.formModel
in
( { model
| formModel = m_
@ -89,6 +90,16 @@ update flags msg model =
, Sub.none
)
UpdateSettings ->
let
( fm, fc ) =
Comp.UiSettingsForm.init flags settings
in
( { model | formModel = fm }
, Cmd.map UiSettingsFormMsg fc
, Sub.none
)
--- View
@ -104,10 +115,10 @@ isSuccess model =
Maybe.map .success model.message == Just True
view : String -> Model -> Html Msg
view classes model =
view : UiSettings -> String -> Model -> Html Msg
view settings classes model =
div [ class classes ]
[ Html.map UiSettingsFormMsg (Comp.UiSettingsForm.view model.formModel)
[ Html.map UiSettingsFormMsg (Comp.UiSettingsForm.view settings model.formModel)
, div [ class "ui divider" ] []
, button
[ class "ui primary button"

View File

@ -12,6 +12,7 @@ module Comp.UserForm exposing
import Api.Model.User exposing (User)
import Comp.Dropdown
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Data.UserState exposing (UserState)
import Html exposing (..)
import Html.Attributes exposing (..)
@ -152,8 +153,8 @@ update _ msg model =
)
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "ui form" ]
[ div
[ classList
@ -182,7 +183,7 @@ view model =
]
, div [ class "field" ]
[ label [] [ text "State" ]
, Html.map StateMsg (Comp.Dropdown.view model.state)
, Html.map StateMsg (Comp.Dropdown.view settings model.state)
]
, div
[ classList

View File

@ -14,6 +14,7 @@ import Comp.UserForm
import Comp.UserTable
import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onSubmit)
@ -194,13 +195,13 @@ update flags msg model =
( { model | deleteConfirm = cm }, cmd )
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
if model.viewMode == Table then
viewTable model
else
viewForm model
viewForm settings model
viewTable : Model -> Html Msg
@ -222,8 +223,8 @@ viewTable model =
]
viewForm : Model -> Html Msg
viewForm model =
viewForm : UiSettings -> Model -> Html Msg
viewForm settings model =
let
newUser =
Comp.UserForm.isNewUser model.formModel
@ -239,7 +240,7 @@ viewForm model =
h3 [ class "ui dividing header" ]
[ text ("Edit user: " ++ model.formModel.user.login)
]
, Html.map FormMsg (Comp.UserForm.view model.formModel)
, Html.map FormMsg (Comp.UserForm.view settings model.formModel)
, div
[ classList
[ ( "ui error message", True )