mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Add pdf-preview checkbox to ui settings
This commit is contained in:
parent
1dd84c11bd
commit
e8c3edfd23
@ -84,7 +84,7 @@ type alias Model =
|
|||||||
, sentMailsOpen : Bool
|
, sentMailsOpen : Bool
|
||||||
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
||||||
, attachMetaOpen : Bool
|
, attachMetaOpen : Bool
|
||||||
, pdfNativeView : Bool
|
, pdfNativeView : Maybe Bool
|
||||||
, deleteAttachConfirm : Comp.YesNoDimmer.Model
|
, deleteAttachConfirm : Comp.YesNoDimmer.Model
|
||||||
, addFilesOpen : Bool
|
, addFilesOpen : Bool
|
||||||
, addFilesModel : Comp.Dropzone.Model
|
, addFilesModel : Comp.Dropzone.Model
|
||||||
@ -170,7 +170,7 @@ emptyModel =
|
|||||||
, sentMailsOpen = False
|
, sentMailsOpen = False
|
||||||
, attachMeta = Dict.empty
|
, attachMeta = Dict.empty
|
||||||
, attachMetaOpen = False
|
, attachMetaOpen = False
|
||||||
, pdfNativeView = False
|
, pdfNativeView = Nothing
|
||||||
, deleteAttachConfirm = Comp.YesNoDimmer.emptyModel
|
, deleteAttachConfirm = Comp.YesNoDimmer.emptyModel
|
||||||
, addFilesOpen = False
|
, addFilesOpen = False
|
||||||
, addFilesModel = Comp.Dropzone.init Comp.Dropzone.defaultSettings
|
, addFilesModel = Comp.Dropzone.init Comp.Dropzone.defaultSettings
|
||||||
@ -231,7 +231,7 @@ type Msg
|
|||||||
| SentMailsResp (Result Http.Error SentMails)
|
| SentMailsResp (Result Http.Error SentMails)
|
||||||
| AttachMetaClick String
|
| AttachMetaClick String
|
||||||
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
||||||
| TogglePdfNativeView
|
| TogglePdfNativeView Bool
|
||||||
| RequestDeleteAttachment String
|
| RequestDeleteAttachment String
|
||||||
| DeleteAttachConfirm String Comp.YesNoDimmer.Msg
|
| DeleteAttachConfirm String Comp.YesNoDimmer.Msg
|
||||||
| DeleteAttachResp (Result Http.Error BasicResult)
|
| DeleteAttachResp (Result Http.Error BasicResult)
|
||||||
@ -1027,9 +1027,17 @@ update key flags next msg model =
|
|||||||
Nothing ->
|
Nothing ->
|
||||||
noSub ( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
TogglePdfNativeView ->
|
TogglePdfNativeView default ->
|
||||||
noSub
|
noSub
|
||||||
( { model | pdfNativeView = not model.pdfNativeView }
|
( { model
|
||||||
|
| pdfNativeView =
|
||||||
|
case model.pdfNativeView of
|
||||||
|
Just flag ->
|
||||||
|
Just (not flag)
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
Just (not default)
|
||||||
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1328,7 +1336,7 @@ view inav settings model =
|
|||||||
List.concat
|
List.concat
|
||||||
[ [ renderAttachmentsTabMenu model
|
[ [ renderAttachmentsTabMenu model
|
||||||
]
|
]
|
||||||
, renderAttachmentsTabBody model
|
, renderAttachmentsTabBody settings model
|
||||||
, renderIdInfo model
|
, renderIdInfo model
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -1481,8 +1489,8 @@ renderAttachmentsTabMenu model =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
renderAttachmentView : Model -> Int -> Attachment -> Html Msg
|
renderAttachmentView : UiSettings -> Model -> Int -> Attachment -> Html Msg
|
||||||
renderAttachmentView model pos attach =
|
renderAttachmentView settings model pos attach =
|
||||||
let
|
let
|
||||||
fileUrl =
|
fileUrl =
|
||||||
"/api/v1/sec/attachment/" ++ attach.id
|
"/api/v1/sec/attachment/" ++ attach.id
|
||||||
@ -1513,8 +1521,8 @@ renderAttachmentView model pos attach =
|
|||||||
[ div [ class "ui slider checkbox" ]
|
[ div [ class "ui slider checkbox" ]
|
||||||
[ input
|
[ input
|
||||||
[ type_ "checkbox"
|
[ type_ "checkbox"
|
||||||
, onCheck (\_ -> TogglePdfNativeView)
|
, onCheck (\_ -> TogglePdfNativeView settings.nativePdfPreview)
|
||||||
, checked model.pdfNativeView
|
, checked (Maybe.withDefault settings.nativePdfPreview model.pdfNativeView)
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
, label [] [ text "Native view" ]
|
, label [] [ text "Native view" ]
|
||||||
@ -1593,7 +1601,7 @@ renderAttachmentView model pos attach =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
[ iframe
|
[ iframe
|
||||||
[ if model.pdfNativeView then
|
[ if Maybe.withDefault settings.nativePdfPreview model.pdfNativeView then
|
||||||
src fileUrl
|
src fileUrl
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -1623,8 +1631,8 @@ isAttachMetaOpen model id =
|
|||||||
model.attachMetaOpen && (Dict.get id model.attachMeta /= Nothing)
|
model.attachMetaOpen && (Dict.get id model.attachMeta /= Nothing)
|
||||||
|
|
||||||
|
|
||||||
renderAttachmentsTabBody : Model -> List (Html Msg)
|
renderAttachmentsTabBody : UiSettings -> Model -> List (Html Msg)
|
||||||
renderAttachmentsTabBody model =
|
renderAttachmentsTabBody settings model =
|
||||||
let
|
let
|
||||||
mailTab =
|
mailTab =
|
||||||
if Comp.SentMails.isEmpty model.sentMails then
|
if Comp.SentMails.isEmpty model.sentMails then
|
||||||
@ -1644,7 +1652,7 @@ renderAttachmentsTabBody model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
List.indexedMap (renderAttachmentView model) model.item.attachments
|
List.indexedMap (renderAttachmentView settings model) model.item.attachments
|
||||||
++ mailTab
|
++ mailTab
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import Data.UiSettings exposing (StoredUiSettings, UiSettings)
|
|||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
|
import Html.Events exposing (onCheck)
|
||||||
import Http
|
import Http
|
||||||
import Util.List
|
import Util.List
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ type alias Model =
|
|||||||
, searchPageSizeModel : Comp.IntField.Model
|
, searchPageSizeModel : Comp.IntField.Model
|
||||||
, tagColors : Dict String String
|
, tagColors : Dict String String
|
||||||
, tagColorModel : Comp.MappingForm.Model
|
, tagColorModel : Comp.MappingForm.Model
|
||||||
|
, nativePdfPreview : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ init flags settings =
|
|||||||
Comp.MappingForm.init
|
Comp.MappingForm.init
|
||||||
[]
|
[]
|
||||||
Data.Color.allString
|
Data.Color.allString
|
||||||
|
, nativePdfPreview = settings.nativePdfPreview
|
||||||
}
|
}
|
||||||
, Api.getTags flags "" GetTagsResp
|
, Api.getTags flags "" GetTagsResp
|
||||||
)
|
)
|
||||||
@ -51,6 +54,7 @@ type Msg
|
|||||||
= SearchPageSizeMsg Comp.IntField.Msg
|
= SearchPageSizeMsg Comp.IntField.Msg
|
||||||
| TagColorMsg Comp.MappingForm.Msg
|
| TagColorMsg Comp.MappingForm.Msg
|
||||||
| GetTagsResp (Result Http.Error TagList)
|
| GetTagsResp (Result Http.Error TagList)
|
||||||
|
| TogglePdfPreview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -92,6 +96,15 @@ update sett msg model =
|
|||||||
in
|
in
|
||||||
( model_, nextSettings )
|
( model_, nextSettings )
|
||||||
|
|
||||||
|
TogglePdfPreview ->
|
||||||
|
let
|
||||||
|
flag =
|
||||||
|
not model.nativePdfPreview
|
||||||
|
in
|
||||||
|
( { model | nativePdfPreview = flag }
|
||||||
|
, Just { sett | nativePdfPreview = flag }
|
||||||
|
)
|
||||||
|
|
||||||
GetTagsResp (Ok tl) ->
|
GetTagsResp (Ok tl) ->
|
||||||
let
|
let
|
||||||
categories =
|
categories =
|
||||||
@ -139,6 +152,22 @@ view settings model =
|
|||||||
"field"
|
"field"
|
||||||
model.searchPageSizeModel
|
model.searchPageSizeModel
|
||||||
)
|
)
|
||||||
|
, div [ class "ui dividing header" ]
|
||||||
|
[ text "Item Detail"
|
||||||
|
]
|
||||||
|
, div [ class "field" ]
|
||||||
|
[ div [ class "ui checkbox" ]
|
||||||
|
[ input
|
||||||
|
[ type_ "checkbox"
|
||||||
|
, onCheck (\_ -> TogglePdfPreview)
|
||||||
|
, checked model.nativePdfPreview
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
, label []
|
||||||
|
[ text "Browser-native PDF preview"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
, div [ class "ui dividing header" ]
|
, div [ class "ui dividing header" ]
|
||||||
[ text "Tag Category Colors"
|
[ text "Tag Category Colors"
|
||||||
]
|
]
|
||||||
|
@ -25,6 +25,7 @@ force default settings.
|
|||||||
type alias StoredUiSettings =
|
type alias StoredUiSettings =
|
||||||
{ itemSearchPageSize : Maybe Int
|
{ itemSearchPageSize : Maybe Int
|
||||||
, tagCategoryColors : List ( String, String )
|
, tagCategoryColors : List ( String, String )
|
||||||
|
, nativePdfPreview : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ default value, converting the StoredUiSettings into a UiSettings.
|
|||||||
type alias UiSettings =
|
type alias UiSettings =
|
||||||
{ itemSearchPageSize : Int
|
{ itemSearchPageSize : Int
|
||||||
, tagCategoryColors : Dict String String
|
, tagCategoryColors : Dict String String
|
||||||
|
, nativePdfPreview : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ defaults : UiSettings
|
|||||||
defaults =
|
defaults =
|
||||||
{ itemSearchPageSize = 60
|
{ itemSearchPageSize = 60
|
||||||
, tagCategoryColors = Dict.empty
|
, tagCategoryColors = Dict.empty
|
||||||
|
, nativePdfPreview = False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,6 +58,7 @@ merge given fallback =
|
|||||||
, tagCategoryColors =
|
, tagCategoryColors =
|
||||||
Dict.union (Dict.fromList given.tagCategoryColors)
|
Dict.union (Dict.fromList given.tagCategoryColors)
|
||||||
fallback.tagCategoryColors
|
fallback.tagCategoryColors
|
||||||
|
, nativePdfPreview = given.nativePdfPreview
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +71,7 @@ toStoredUiSettings : UiSettings -> StoredUiSettings
|
|||||||
toStoredUiSettings settings =
|
toStoredUiSettings settings =
|
||||||
{ itemSearchPageSize = Just settings.itemSearchPageSize
|
{ itemSearchPageSize = Just settings.itemSearchPageSize
|
||||||
, tagCategoryColors = Dict.toList settings.tagCategoryColors
|
, tagCategoryColors = Dict.toList settings.tagCategoryColors
|
||||||
|
, nativePdfPreview = settings.nativePdfPreview
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user