mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
Store tag category colors in ui settings
This commit is contained in:
@ -139,6 +139,7 @@ view data opts model =
|
||||
[ i [ class "add icon" ] []
|
||||
]
|
||||
]
|
||||
, renderFormData opts data
|
||||
, span
|
||||
[ classList
|
||||
[ ( "small-info", True )
|
||||
@ -148,7 +149,6 @@ view data opts model =
|
||||
[ Maybe.withDefault "" opts.description
|
||||
|> text
|
||||
]
|
||||
, renderFormData opts data
|
||||
]
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@ type alias Model =
|
||||
, input : StoredUiSettings
|
||||
, searchPageSizeModel : Comp.IntField.Model
|
||||
, tagColorModel : Comp.MappingForm.Model
|
||||
, tagColors : Dict String String
|
||||
}
|
||||
|
||||
|
||||
@ -38,12 +37,11 @@ init flags defaults =
|
||||
(Just 10)
|
||||
(Just 500)
|
||||
False
|
||||
"Item search page"
|
||||
"Page size"
|
||||
, tagColorModel =
|
||||
Comp.MappingForm.init
|
||||
[]
|
||||
Data.Color.allString
|
||||
, tagColors = Dict.empty
|
||||
}
|
||||
, Api.getTags flags "" GetTagsResp
|
||||
)
|
||||
@ -92,12 +90,23 @@ update msg model =
|
||||
let
|
||||
( m_, d_ ) =
|
||||
Comp.MappingForm.update lm model.tagColorModel
|
||||
|
||||
newData =
|
||||
case d_ of
|
||||
Just data ->
|
||||
Dict.toList data
|
||||
|
||||
Nothing ->
|
||||
model.input.tagCategoryColors
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| tagColorModel = m_
|
||||
, input = changeInput (\s -> { s | tagCategoryColors = newData }) model
|
||||
}
|
||||
in
|
||||
( { model
|
||||
| tagColorModel = m_
|
||||
, tagColors = Maybe.withDefault model.tagColors d_
|
||||
}
|
||||
, Nothing
|
||||
( model_
|
||||
, Maybe.map (\_ -> getSettings model_) d_
|
||||
)
|
||||
|
||||
GetTagsResp (Ok tl) ->
|
||||
@ -111,7 +120,6 @@ update msg model =
|
||||
Comp.MappingForm.init
|
||||
categories
|
||||
Data.Color.allString
|
||||
, tagColors = Dict.empty
|
||||
}
|
||||
, Nothing
|
||||
)
|
||||
@ -138,16 +146,22 @@ tagColorViewOpts =
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div [ class "ui form" ]
|
||||
[ Html.map SearchPageSizeMsg
|
||||
[ div [ class "ui dividing header" ]
|
||||
[ text "Item Search"
|
||||
]
|
||||
, Html.map SearchPageSizeMsg
|
||||
(Comp.IntField.viewWithInfo
|
||||
"Maximum results in one page when searching items."
|
||||
model.input.itemSearchPageSize
|
||||
"field"
|
||||
model.searchPageSizeModel
|
||||
)
|
||||
, div [ class "ui dividing header" ]
|
||||
[ text "Tag Category Colors"
|
||||
]
|
||||
, Html.map TagColorMsg
|
||||
(Comp.MappingForm.view
|
||||
model.tagColors
|
||||
(Dict.fromList model.input.tagCategoryColors)
|
||||
tagColorViewOpts
|
||||
model.tagColorModel
|
||||
)
|
||||
|
@ -58,7 +58,12 @@ update flags msg model =
|
||||
( { model
|
||||
| formModel = m_
|
||||
, settings = sett
|
||||
, message = Nothing
|
||||
, message =
|
||||
if sett /= Nothing then
|
||||
Nothing
|
||||
|
||||
else
|
||||
model.message
|
||||
}
|
||||
, Cmd.none
|
||||
, Sub.none
|
||||
|
Reference in New Issue
Block a user