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

@ -44,18 +44,19 @@ type alias Model =
, itemDetailModel : Page.ItemDetail.Data.Model
, navMenuOpen : Bool
, subs : Sub Msg
, uiSettings : UiSettings
}
init : Key -> Url -> Flags -> ( Model, Cmd Msg )
init key url flags =
init : Key -> Url -> Flags -> UiSettings -> ( Model, Cmd Msg )
init key url flags settings =
let
page =
Page.fromUrl url
|> Maybe.withDefault (defaultPage flags)
( um, uc ) =
Page.UserSettings.Data.emptyModel flags
Page.UserSettings.Data.init flags settings
in
( { flags = flags
, key = key
@ -73,6 +74,7 @@ init key url flags =
, itemDetailModel = Page.ItemDetail.Data.emptyModel
, navMenuOpen = False
, subs = Sub.none
, uiSettings = settings
}
, Cmd.map UserSettingsMsg uc
)

View File

@ -176,10 +176,9 @@ updateWithSub msg model =
GetUiSettings settings ->
Util.Update.andThen1
[ updateUserSettings (Page.UserSettings.Data.GetUiSettings settings)
, updateHome (Page.Home.Data.GetUiSettings settings)
[ updateUserSettings Page.UserSettings.Data.UpdateSettings
]
model
{ model | uiSettings = settings }
|> noSub
@ -253,7 +252,7 @@ updateUserSettings : Page.UserSettings.Data.Msg -> Model -> ( Model, Cmd Msg )
updateUserSettings lmsg model =
let
( lm, lc, ls ) =
Page.UserSettings.Update.update model.flags lmsg model.userSettingsModel
Page.UserSettings.Update.update model.flags model.uiSettings lmsg model.userSettingsModel
in
( { model
| userSettingsModel = lm
@ -302,7 +301,7 @@ updateHome : Page.Home.Data.Msg -> Model -> ( Model, Cmd Msg )
updateHome lmsg model =
let
( lm, lc ) =
Page.Home.Update.update model.key model.flags lmsg model.homeModel
Page.Home.Update.update model.key model.flags model.uiSettings lmsg model.homeModel
in
( { model | homeModel = lm }
, Cmd.map HomeMsg lc

View File

@ -121,7 +121,7 @@ viewItemDetail id model =
inav =
Page.Home.Data.itemNav id model.homeModel
in
Html.map ItemDetailMsg (Page.ItemDetail.View.view inav model.itemDetailModel)
Html.map ItemDetailMsg (Page.ItemDetail.View.view inav model.uiSettings model.itemDetailModel)
viewNewInvite : Model -> Html Msg
@ -146,17 +146,21 @@ viewQueue model =
viewUserSettings : Model -> Html Msg
viewUserSettings model =
Html.map UserSettingsMsg (Page.UserSettings.View.view model.userSettingsModel)
Html.map UserSettingsMsg (Page.UserSettings.View.view model.uiSettings model.userSettingsModel)
viewCollectiveSettings : Model -> Html Msg
viewCollectiveSettings model =
Html.map CollSettingsMsg (Page.CollectiveSettings.View.view model.flags model.collSettingsModel)
Html.map CollSettingsMsg
(Page.CollectiveSettings.View.view model.flags
model.uiSettings
model.collSettingsModel
)
viewManageData : Model -> Html Msg
viewManageData model =
Html.map ManageDataMsg (Page.ManageData.View.view model.manageDataModel)
Html.map ManageDataMsg (Page.ManageData.View.view model.uiSettings model.manageDataModel)
viewLogin : Model -> Html Msg
@ -166,7 +170,7 @@ viewLogin model =
viewHome : Model -> Html Msg
viewHome model =
Html.map HomeMsg (Page.Home.View.view model.homeModel)
Html.map HomeMsg (Page.Home.View.view model.uiSettings model.homeModel)
menuEntry : Model -> Page -> List (Html Msg) -> Html Msg

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 )

View File

@ -37,6 +37,7 @@ all =
, Pink
, Brown
, Grey
, Black
]

View File

@ -4,9 +4,13 @@ module Data.UiSettings exposing
, defaults
, merge
, mergeDefaults
, tagColor
, tagColorString
, toStoredUiSettings
)
import Api.Model.Tag exposing (Tag)
import Data.Color exposing (Color)
import Dict exposing (Dict)
@ -66,6 +70,27 @@ toStoredUiSettings settings =
}
tagColor : Tag -> UiSettings -> Maybe Color
tagColor tag settings =
let
readColor c =
Dict.get c settings.tagCategoryColors
|> Maybe.andThen Data.Color.fromString
in
Maybe.andThen readColor tag.category
tagColorString : Tag -> UiSettings -> String
tagColorString tag settings =
tagColor tag settings
|> Maybe.map Data.Color.toString
|> Maybe.withDefault ""
--- Helpers
choose : Maybe a -> a -> a
choose m1 m2 =
Maybe.withDefault m2 m1

View File

@ -7,6 +7,7 @@ import App.View exposing (..)
import Browser exposing (Document)
import Browser.Navigation exposing (Key)
import Data.Flags exposing (Flags)
import Data.UiSettings
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
@ -39,7 +40,7 @@ init : Flags -> Url -> Key -> ( Model, Cmd Msg )
init flags url key =
let
( im, ic ) =
App.Data.init key url flags
App.Data.init key url flags Data.UiSettings.defaults
page =
checkPage flags im.page

View File

@ -5,6 +5,7 @@ import Comp.CollectiveSettingsForm
import Comp.SourceManage
import Comp.UserManage
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -14,8 +15,8 @@ import Util.Maybe
import Util.Size
view : Flags -> Model -> Html Msg
view flags model =
view : Flags -> UiSettings -> Model -> Html Msg
view flags settings model =
div [ class "collectivesetting-page ui padded grid" ]
[ div [ class "sixteen wide mobile four wide tablet four wide computer column" ]
[ h4 [ class "ui top attached ablue-comp header" ]
@ -61,13 +62,13 @@ view flags model =
viewSources flags model
Just UserTab ->
viewUsers model
viewUsers settings model
Just InsightsTab ->
viewInsights model
Just SettingsTab ->
viewSettings flags model
viewSettings flags settings model
Nothing ->
[]
@ -164,26 +165,26 @@ viewSources flags model =
]
viewUsers : Model -> List (Html Msg)
viewUsers model =
viewUsers : UiSettings -> Model -> List (Html Msg)
viewUsers settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui user icon" ] []
, div [ class "content" ]
[ text "Users"
]
]
, Html.map UserMsg (Comp.UserManage.view model.userModel)
, Html.map UserMsg (Comp.UserManage.view settings model.userModel)
]
viewSettings : Flags -> Model -> List (Html Msg)
viewSettings flags model =
viewSettings : Flags -> UiSettings -> Model -> List (Html Msg)
viewSettings flags settings model =
[ h2 [ class "ui header" ]
[ i [ class "cog icon" ] []
, text "Settings"
]
, div [ class "ui segment" ]
[ Html.map SettingsFormMsg (Comp.CollectiveSettingsForm.view flags model.settingsModel)
[ Html.map SettingsFormMsg (Comp.CollectiveSettingsForm.view flags settings model.settingsModel)
]
, div
[ classList

View File

@ -27,13 +27,12 @@ type alias Model =
, searchOffset : Int
, moreAvailable : Bool
, moreInProgress : Bool
, uiSettings : UiSettings
}
init : Flags -> Model
init _ =
{ searchMenuModel = Comp.SearchMenu.emptyModel
{ searchMenuModel = Comp.SearchMenu.init
, itemListModel = Comp.ItemCardList.init
, searchInProgress = False
, viewMode = Listing
@ -41,7 +40,6 @@ init _ =
, searchOffset = 0
, moreAvailable = True
, moreInProgress = False
, uiSettings = Data.UiSettings.defaults
}
@ -55,7 +53,6 @@ type Msg
| DoSearch
| ToggleSearchMenu
| LoadMore
| GetUiSettings UiSettings
type ViewMode
@ -77,15 +74,15 @@ itemNav id model =
}
doSearchCmd : Flags -> Int -> Model -> Cmd Msg
doSearchCmd flags offset model =
doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
doSearchCmd flags settings offset model =
let
smask =
Comp.SearchMenu.getItemSearch model.searchMenuModel
mask =
{ smask
| limit = model.uiSettings.itemSearchPageSize
| limit = settings.itemSearchPageSize
, offset = offset
}
in
@ -96,10 +93,10 @@ doSearchCmd flags offset model =
Api.itemSearch flags mask ItemSearchAddResp
resultsBelowLimit : Model -> Bool
resultsBelowLimit model =
resultsBelowLimit : UiSettings -> Model -> Bool
resultsBelowLimit settings model =
let
len =
Data.Items.length model.itemListModel.results
in
len < model.uiSettings.itemSearchPageSize
len < settings.itemSearchPageSize

View File

@ -4,17 +4,18 @@ import Browser.Navigation as Nav
import Comp.ItemCardList
import Comp.SearchMenu
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Page exposing (Page(..))
import Page.Home.Data exposing (..)
import Util.Update
update : Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg )
update key flags msg model =
update : Nav.Key -> Flags -> UiSettings -> Msg -> Model -> ( Model, Cmd Msg )
update key flags settings msg model =
case msg of
Init ->
Util.Update.andThen1
[ update key flags (SearchMenuMsg Comp.SearchMenu.Init)
[ update key flags settings (SearchMenuMsg Comp.SearchMenu.Init)
]
model
@ -23,19 +24,19 @@ update key flags msg model =
nm =
{ model | searchOffset = 0 }
in
update key flags (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
update key flags settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
SearchMenuMsg m ->
let
nextState =
Comp.SearchMenu.update flags m model.searchMenuModel
Comp.SearchMenu.update flags settings m model.searchMenuModel
newModel =
{ model | searchMenuModel = Tuple.first nextState.modelCmd }
( m2, c2 ) =
if nextState.stateChange then
doSearch flags newModel
doSearch flags settings newModel
else
( newModel, Cmd.none )
@ -62,7 +63,7 @@ update key flags msg model =
ItemSearchResp (Ok list) ->
let
noff =
model.uiSettings.itemSearchPageSize
settings.itemSearchPageSize
m =
{ model
@ -72,12 +73,12 @@ update key flags msg model =
, moreAvailable = list.groups /= []
}
in
update key flags (ItemCardListMsg (Comp.ItemCardList.SetResults list)) m
update key flags settings (ItemCardListMsg (Comp.ItemCardList.SetResults list)) m
ItemSearchAddResp (Ok list) ->
let
noff =
model.searchOffset + model.uiSettings.itemSearchPageSize
model.searchOffset + settings.itemSearchPageSize
m =
{ model
@ -88,7 +89,7 @@ update key flags msg model =
, moreAvailable = list.groups /= []
}
in
update key flags (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
update key flags settings (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
ItemSearchAddResp (Err _) ->
( { model
@ -109,7 +110,7 @@ update key flags msg model =
nm =
{ model | searchOffset = 0 }
in
doSearch flags nm
doSearch flags settings nm
ToggleSearchMenu ->
( { model | menuCollapsed = not model.menuCollapsed }
@ -118,24 +119,17 @@ update key flags msg model =
LoadMore ->
if model.moreAvailable then
doSearchMore flags model
doSearchMore flags settings model
else
( model, Cmd.none )
GetUiSettings settings ->
let
m_ =
{ model | uiSettings = settings }
in
doSearch flags m_
doSearch : Flags -> Model -> ( Model, Cmd Msg )
doSearch flags model =
doSearch : Flags -> UiSettings -> Model -> ( Model, Cmd Msg )
doSearch flags settings model =
let
cmd =
doSearchCmd flags 0 model
doSearchCmd flags settings 0 model
in
( { model
| searchInProgress = True
@ -146,11 +140,11 @@ doSearch flags model =
)
doSearchMore : Flags -> Model -> ( Model, Cmd Msg )
doSearchMore flags model =
doSearchMore : Flags -> UiSettings -> Model -> ( Model, Cmd Msg )
doSearchMore flags settings model =
let
cmd =
doSearchCmd flags model.searchOffset model
doSearchCmd flags settings model.searchOffset model
in
( { model | moreInProgress = True, viewMode = Listing }
, cmd

View File

@ -2,6 +2,7 @@ module Page.Home.View exposing (view)
import Comp.ItemCardList
import Comp.SearchMenu
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -9,8 +10,8 @@ import Page exposing (Page(..))
import Page.Home.Data exposing (..)
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "home-page ui padded grid" ]
[ div
[ classList
@ -52,7 +53,7 @@ view model =
]
]
, div [ class "ui attached fluid segment" ]
[ Html.map SearchMenuMsg (Comp.SearchMenu.view model.searchMenuModel)
[ Html.map SearchMenuMsg (Comp.SearchMenu.view settings model.searchMenuModel)
]
]
, div
@ -86,7 +87,7 @@ view model =
else
Html.map ItemCardListMsg
(Comp.ItemCardList.view model.itemListModel)
(Comp.ItemCardList.view settings model.itemListModel)
Detail ->
div [] []
@ -101,7 +102,7 @@ view model =
[ classList
[ ( "ui basic tiny button", True )
, ( "disabled", not model.moreAvailable )
, ( "hidden invisible", resultsBelowLimit model )
, ( "hidden invisible", resultsBelowLimit settings model )
]
, disabled (not model.moreAvailable || model.moreInProgress || model.searchInProgress)
, title "Load more items"

View File

@ -1,6 +1,7 @@
module Page.ItemDetail.View exposing (view)
import Comp.ItemDetail
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Page.ItemDetail.Data exposing (Model, Msg(..))
@ -12,8 +13,8 @@ type alias ItemNav =
}
view : ItemNav -> Model -> Html Msg
view inav model =
view : ItemNav -> UiSettings -> Model -> Html Msg
view inav settings model =
div [ class "ui fluid container item-detail-page" ]
[ Html.map ItemDetailMsg (Comp.ItemDetail.view inav model.detail)
[ Html.map ItemDetailMsg (Comp.ItemDetail.view inav settings model.detail)
]

View File

@ -4,6 +4,7 @@ import Comp.EquipmentManage
import Comp.OrgManage
import Comp.PersonManage
import Comp.TagManage
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -11,8 +12,8 @@ import Page.ManageData.Data exposing (..)
import Util.Html exposing (classActive)
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "managedata-page ui padded grid" ]
[ div [ class "sixteen wide mobile four wide tablet four wide computer column" ]
[ h4 [ class "ui top attached ablue-comp header" ]
@ -61,10 +62,10 @@ view model =
viewEquip model
Just OrgTab ->
viewOrg model
viewOrg settings model
Just PersonTab ->
viewPerson model
viewPerson settings model
Nothing ->
[]
@ -97,25 +98,25 @@ viewEquip model =
]
viewOrg : Model -> List (Html Msg)
viewOrg model =
viewOrg : UiSettings -> Model -> List (Html Msg)
viewOrg settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui factory icon" ] []
, div [ class "content" ]
[ text "Organizations"
]
]
, Html.map OrgManageMsg (Comp.OrgManage.view model.orgManageModel)
, Html.map OrgManageMsg (Comp.OrgManage.view settings model.orgManageModel)
]
viewPerson : Model -> List (Html Msg)
viewPerson model =
viewPerson : UiSettings -> Model -> List (Html Msg)
viewPerson settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui user icon" ] []
, div [ class "content" ]
[ text "Person"
]
]
, Html.map PersonManageMsg (Comp.PersonManage.view model.personManageModel)
, Html.map PersonManageMsg (Comp.PersonManage.view settings model.personManageModel)
]

View File

@ -2,7 +2,7 @@ module Page.UserSettings.Data exposing
( Model
, Msg(..)
, Tab(..)
, emptyModel
, init
)
import Comp.ChangePasswordForm
@ -26,17 +26,17 @@ type alias Model =
}
emptyModel : Flags -> ( Model, Cmd Msg )
emptyModel flags =
init : Flags -> UiSettings -> ( Model, Cmd Msg )
init flags settings =
let
( um, uc ) =
Comp.UiSettingsManage.init flags Data.UiSettings.defaults
Comp.UiSettingsManage.init flags settings
in
( { currentTab = Nothing
, changePassModel = Comp.ChangePasswordForm.emptyModel
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
, imapSettingsModel = Comp.ImapSettingsManage.emptyModel
, notificationModel = Tuple.first (Comp.NotificationForm.init flags)
, notificationModel = Tuple.first (Comp.NotificationForm.init flags settings)
, scanMailboxModel = Tuple.first (Comp.ScanMailboxManage.init flags)
, uiSettingsModel = um
}
@ -60,5 +60,5 @@ type Msg
| NotificationMsg Comp.NotificationForm.Msg
| ImapSettingsMsg Comp.ImapSettingsManage.Msg
| ScanMailboxMsg Comp.ScanMailboxManage.Msg
| GetUiSettings UiSettings
| UiSettingsMsg Comp.UiSettingsManage.Msg
| UpdateSettings

View File

@ -7,11 +7,12 @@ import Comp.NotificationForm
import Comp.ScanMailboxManage
import Comp.UiSettingsManage
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Page.UserSettings.Data exposing (..)
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
SetTab t ->
let
@ -40,7 +41,7 @@ update flags msg model =
let
initCmd =
Cmd.map NotificationMsg
(Tuple.second (Comp.NotificationForm.init flags))
(Tuple.second (Comp.NotificationForm.init flags settings))
in
( m, initCmd, Sub.none )
@ -96,22 +97,18 @@ update flags msg model =
, Sub.none
)
GetUiSettings settings ->
let
( um, uc ) =
Comp.UiSettingsManage.init flags settings
in
( { model | uiSettingsModel = um }
, Cmd.map UiSettingsMsg uc
, Sub.none
)
UiSettingsMsg lm ->
let
( m2, c2, s2 ) =
Comp.UiSettingsManage.update flags lm model.uiSettingsModel
Comp.UiSettingsManage.update flags settings lm model.uiSettingsModel
in
( { model | uiSettingsModel = m2 }
, Cmd.map UiSettingsMsg c2
, Sub.map UiSettingsMsg s2
)
UpdateSettings ->
update flags
settings
(UiSettingsMsg Comp.UiSettingsManage.UpdateSettings)
model

View File

@ -6,6 +6,7 @@ import Comp.ImapSettingsManage
import Comp.NotificationForm
import Comp.ScanMailboxManage
import Comp.UiSettingsManage
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
@ -13,8 +14,8 @@ import Page.UserSettings.Data exposing (..)
import Util.Html exposing (classActive)
view : Model -> Html Msg
view model =
view : UiSettings -> Model -> Html Msg
view settings model =
div [ class "usersetting-page ui padded grid" ]
[ div [ class "sixteen wide mobile four wide tablet four wide computer column" ]
[ h4 [ class "ui top attached ablue-comp header" ]
@ -38,19 +39,19 @@ view model =
viewChangePassword model
Just EmailSettingsTab ->
viewEmailSettings model
viewEmailSettings settings model
Just NotificationTab ->
viewNotificationForm model
viewNotificationForm settings model
Just ImapSettingsTab ->
viewImapSettings model
viewImapSettings settings model
Just ScanMailboxTab ->
viewScanMailboxManage model
viewScanMailboxManage settings model
Just UiSettingsTab ->
viewUiSettings model
viewUiSettings settings model
Nothing ->
[]
@ -71,8 +72,8 @@ makeTab model tab header icon =
]
viewUiSettings : Model -> List (Html Msg)
viewUiSettings model =
viewUiSettings : UiSettings -> Model -> List (Html Msg)
viewUiSettings settings model =
[ h2 [ class "ui header" ]
[ i [ class "cog icon" ] []
, text "UI Settings"
@ -81,31 +82,36 @@ viewUiSettings model =
[ text "These settings only affect the web ui. They are stored in the browser, "
, text "so they are separated between browsers and devices."
]
, Html.map UiSettingsMsg (Comp.UiSettingsManage.view "ui segment" model.uiSettingsModel)
, Html.map UiSettingsMsg
(Comp.UiSettingsManage.view
settings
"ui segment"
model.uiSettingsModel
)
]
viewEmailSettings : Model -> List (Html Msg)
viewEmailSettings model =
viewEmailSettings : UiSettings -> Model -> List (Html Msg)
viewEmailSettings settings model =
[ h2 [ class "ui header" ]
[ i [ class "mail icon" ] []
, div [ class "content" ]
[ text "E-Mail Settings (Smtp)"
]
]
, Html.map EmailSettingsMsg (Comp.EmailSettingsManage.view model.emailSettingsModel)
, Html.map EmailSettingsMsg (Comp.EmailSettingsManage.view settings model.emailSettingsModel)
]
viewImapSettings : Model -> List (Html Msg)
viewImapSettings model =
viewImapSettings : UiSettings -> Model -> List (Html Msg)
viewImapSettings settings model =
[ h2 [ class "ui header" ]
[ i [ class "mail icon" ] []
, div [ class "content" ]
[ text "E-Mail Settings (Imap)"
]
]
, Html.map ImapSettingsMsg (Comp.ImapSettingsManage.view model.imapSettingsModel)
, Html.map ImapSettingsMsg (Comp.ImapSettingsManage.view settings model.imapSettingsModel)
]
@ -121,8 +127,8 @@ viewChangePassword model =
]
viewNotificationForm : Model -> List (Html Msg)
viewNotificationForm model =
viewNotificationForm : UiSettings -> Model -> List (Html Msg)
viewNotificationForm settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui bullhorn icon" ] []
, div [ class "content" ]
@ -141,12 +147,12 @@ viewNotificationForm model =
, text " days and sends this list via e-mail."
]
, Html.map NotificationMsg
(Comp.NotificationForm.view "segment" model.notificationModel)
(Comp.NotificationForm.view "segment" settings model.notificationModel)
]
viewScanMailboxManage : Model -> List (Html Msg)
viewScanMailboxManage model =
viewScanMailboxManage : UiSettings -> Model -> List (Html Msg)
viewScanMailboxManage settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui envelope open outline icon" ] []
, div [ class "content" ]
@ -171,6 +177,7 @@ viewScanMailboxManage model =
]
, Html.map ScanMailboxMsg
(Comp.ScanMailboxManage.view
settings
model.scanMailboxModel
)
]

View File

@ -2,7 +2,7 @@ module Util.Tag exposing (makeDropdownModel)
import Api.Model.Tag exposing (Tag)
import Comp.Dropdown
import Util.Maybe
import Data.UiSettings
makeDropdownModel : Comp.Dropdown.Model Tag
@ -13,10 +13,7 @@ makeDropdownModel =
, makeOption = \tag -> { value = tag.id, text = tag.name }
, labelColor =
\tag ->
if Util.Maybe.nonEmpty tag.category then
"basic blue"
else
""
\settings ->
"basic " ++ Data.UiSettings.tagColorString tag settings
, placeholder = "Choose a tag"
}