Allow to set item notes below or above the files

This commit is contained in:
Eike Kettner
2020-08-05 21:23:42 +02:00
parent 0453494cc6
commit baa25d0f2f
4 changed files with 117 additions and 29 deletions

View File

@ -1,9 +1,12 @@
module Data.UiSettings exposing
( StoredUiSettings
( Pos(..)
, StoredUiSettings
, UiSettings
, defaults
, merge
, mergeDefaults
, posFromString
, posToString
, tagColor
, tagColorString
, toStoredUiSettings
@ -27,6 +30,7 @@ type alias StoredUiSettings =
, tagCategoryColors : List ( String, String )
, nativePdfPreview : Bool
, itemSearchNoteLength : Maybe Int
, itemDetailNotesPosition : Maybe String
}
@ -42,15 +46,45 @@ type alias UiSettings =
, tagCategoryColors : Dict String Color
, nativePdfPreview : Bool
, itemSearchNoteLength : Int
, itemDetailNotesPosition : Pos
}
type Pos
= Top
| Bottom
posToString : Pos -> String
posToString pos =
case pos of
Top ->
"top"
Bottom ->
"bottom"
posFromString : String -> Maybe Pos
posFromString str =
case str of
"top" ->
Just Top
"bottom" ->
Just Bottom
_ ->
Nothing
defaults : UiSettings
defaults =
{ itemSearchPageSize = 60
, tagCategoryColors = Dict.empty
, nativePdfPreview = False
, itemSearchNoteLength = 0
, itemDetailNotesPosition = Top
}
@ -69,6 +103,9 @@ merge given fallback =
, nativePdfPreview = given.nativePdfPreview
, itemSearchNoteLength =
choose given.itemSearchNoteLength fallback.itemSearchNoteLength
, itemDetailNotesPosition =
choose (Maybe.andThen posFromString given.itemDetailNotesPosition)
fallback.itemDetailNotesPosition
}
@ -85,6 +122,7 @@ toStoredUiSettings settings =
|> Dict.toList
, nativePdfPreview = settings.nativePdfPreview
, itemSearchNoteLength = Just settings.itemSearchNoteLength
, itemDetailNotesPosition = Just (posToString settings.itemDetailNotesPosition)
}