mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
@ -22,6 +22,7 @@ import Api.Model.ItemLight exposing (ItemLight)
|
||||
import Comp.LinkTarget exposing (LinkTarget(..))
|
||||
import Data.Direction
|
||||
import Data.Fields
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Icons as Icons
|
||||
import Data.ItemSelection exposing (ItemSelection)
|
||||
import Data.ItemTemplate as IT
|
||||
@ -150,8 +151,8 @@ update ddm msg model =
|
||||
--- View2
|
||||
|
||||
|
||||
view2 : Texts -> ViewConfig -> UiSettings -> Model -> ItemLight -> Html Msg
|
||||
view2 texts cfg settings model item =
|
||||
view2 : Texts -> ViewConfig -> UiSettings -> Flags -> Model -> ItemLight -> Html Msg
|
||||
view2 texts cfg settings flags model item =
|
||||
let
|
||||
isCreated =
|
||||
item.state == "created"
|
||||
@ -221,7 +222,7 @@ view2 texts cfg settings model item =
|
||||
, metaDataContent2 texts settings item
|
||||
, notesContent2 settings item
|
||||
, fulltextResultsContent2 item
|
||||
, previewMenu2 texts settings cfg model item (currentAttachment model item)
|
||||
, previewMenu2 texts settings flags cfg model item (currentAttachment model item)
|
||||
, selectedDimmer
|
||||
]
|
||||
)
|
||||
@ -475,8 +476,8 @@ previewImage2 cfg settings cardAction model item =
|
||||
]
|
||||
|
||||
|
||||
previewMenu2 : Texts -> UiSettings -> ViewConfig -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
|
||||
previewMenu2 texts settings cfg model item mainAttach =
|
||||
previewMenu2 : Texts -> UiSettings -> Flags -> ViewConfig -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
|
||||
previewMenu2 texts settings flags cfg model item mainAttach =
|
||||
let
|
||||
pageCount =
|
||||
Maybe.andThen .pageCount mainAttach
|
||||
@ -489,11 +490,7 @@ previewMenu2 texts settings cfg model item mainAttach =
|
||||
Data.UiSettings.fieldHidden settings f
|
||||
|
||||
mkAttachUrl attach =
|
||||
if settings.nativePdfPreview then
|
||||
cfg.attachUrl attach
|
||||
|
||||
else
|
||||
cfg.attachUrl attach ++ "/view"
|
||||
Data.UiSettings.pdfUrl settings flags (cfg.attachUrl attach)
|
||||
|
||||
attachUrl =
|
||||
Maybe.map mkAttachUrl mainAttach
|
||||
|
@ -169,19 +169,19 @@ type alias ViewConfig =
|
||||
}
|
||||
|
||||
|
||||
view2 : Texts -> ViewConfig -> UiSettings -> Model -> Html Msg
|
||||
view2 texts cfg settings model =
|
||||
view2 : Texts -> ViewConfig -> UiSettings -> Flags -> Model -> Html Msg
|
||||
view2 texts cfg settings flags model =
|
||||
div
|
||||
[ classList
|
||||
[ ( "ds-item-list", True )
|
||||
, ( "ds-multi-select-mode", isMultiSelectMode cfg )
|
||||
]
|
||||
]
|
||||
(List.map (viewGroup2 texts model cfg settings) model.results.groups)
|
||||
(List.map (viewGroup2 texts model cfg settings flags) model.results.groups)
|
||||
|
||||
|
||||
viewGroup2 : Texts -> Model -> ViewConfig -> UiSettings -> ItemLightGroup -> Html Msg
|
||||
viewGroup2 texts model cfg settings group =
|
||||
viewGroup2 : Texts -> Model -> ViewConfig -> UiSettings -> Flags -> ItemLightGroup -> Html Msg
|
||||
viewGroup2 texts model cfg settings flags group =
|
||||
div [ class "ds-item-group" ]
|
||||
[ div
|
||||
[ class "flex py-1 mt-2 mb-2 flex flex-row items-center"
|
||||
@ -206,12 +206,12 @@ viewGroup2 texts model cfg settings group =
|
||||
[]
|
||||
]
|
||||
, div [ class "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-2" ]
|
||||
(List.map (viewItem2 texts model cfg settings) group.items)
|
||||
(List.map (viewItem2 texts model cfg settings flags) group.items)
|
||||
]
|
||||
|
||||
|
||||
viewItem2 : Texts -> Model -> ViewConfig -> UiSettings -> ItemLight -> Html Msg
|
||||
viewItem2 texts model cfg settings item =
|
||||
viewItem2 : Texts -> Model -> ViewConfig -> UiSettings -> Flags -> ItemLight -> Html Msg
|
||||
viewItem2 texts model cfg settings flags item =
|
||||
let
|
||||
currentClass =
|
||||
if cfg.current == Just item.id then
|
||||
@ -228,7 +228,7 @@ viewItem2 texts model cfg settings item =
|
||||
|> Maybe.withDefault Comp.ItemCard.init
|
||||
|
||||
cardHtml =
|
||||
Comp.ItemCard.view2 texts.itemCard vvcfg settings cardModel item
|
||||
Comp.ItemCard.view2 texts.itemCard vvcfg settings flags cardModel item
|
||||
in
|
||||
Html.map (ItemCardMsg item) cardHtml
|
||||
|
||||
|
@ -100,7 +100,6 @@ type alias Model =
|
||||
, sentMailsOpen : Bool
|
||||
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
||||
, attachMetaOpen : Bool
|
||||
, pdfNativeView : Maybe Bool
|
||||
, attachModal : Maybe ConfirmModalValue
|
||||
, addFilesOpen : Bool
|
||||
, addFilesModel : Comp.Dropzone.Model
|
||||
@ -236,7 +235,6 @@ emptyModel =
|
||||
, sentMailsOpen = False
|
||||
, attachMeta = Dict.empty
|
||||
, attachMetaOpen = False
|
||||
, pdfNativeView = Nothing
|
||||
, attachModal = Nothing
|
||||
, addFilesOpen = False
|
||||
, addFilesModel = Comp.Dropzone.init []
|
||||
@ -316,7 +314,6 @@ type Msg
|
||||
| SentMailsResp (Result Http.Error SentMails)
|
||||
| AttachMetaClick String
|
||||
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
||||
| TogglePdfNativeView Bool
|
||||
| RequestDeleteAttachment String
|
||||
| DeleteAttachConfirmed String
|
||||
| RequestDeleteSelected
|
||||
|
@ -85,12 +85,8 @@ view texts flags settings model pos attach =
|
||||
, style "max-height" "calc(100vh - 140px)"
|
||||
, style "min-height" "500px"
|
||||
]
|
||||
[ iframe
|
||||
[ if Maybe.withDefault settings.nativePdfPreview model.pdfNativeView then
|
||||
src fileUrl
|
||||
|
||||
else
|
||||
src (fileUrl ++ "/view")
|
||||
[ embed
|
||||
[ src <| Data.UiSettings.pdfUrl settings flags fileUrl
|
||||
, class "absolute h-full w-full top-0 left-0 mx-0 py-0"
|
||||
, id "ds-pdf-view-iframe"
|
||||
]
|
||||
@ -254,18 +250,6 @@ attachHeader texts settings model _ attach =
|
||||
, classList [ ( "hidden", not attach.converted ) ]
|
||||
]
|
||||
}
|
||||
, { icon =
|
||||
if Maybe.withDefault settings.nativePdfPreview model.pdfNativeView then
|
||||
"fa fa-toggle-on"
|
||||
|
||||
else
|
||||
"fa fa-toggle-off"
|
||||
, label = texts.renderPdfByBrowser
|
||||
, attrs =
|
||||
[ onClick (TogglePdfNativeView settings.nativePdfPreview)
|
||||
, href "#"
|
||||
]
|
||||
}
|
||||
, { icon =
|
||||
if isAttachMetaOpen model attach.id then
|
||||
"fa fa-toggle-on"
|
||||
|
@ -913,19 +913,6 @@ update key flags inav settings msg model =
|
||||
Nothing ->
|
||||
resultModel model
|
||||
|
||||
TogglePdfNativeView default ->
|
||||
resultModel
|
||||
{ model
|
||||
| pdfNativeView =
|
||||
case model.pdfNativeView of
|
||||
Just flag ->
|
||||
Just (not flag)
|
||||
|
||||
Nothing ->
|
||||
Just (not default)
|
||||
, attachmentDropdownOpen = False
|
||||
}
|
||||
|
||||
DeleteAttachConfirmed attachId ->
|
||||
let
|
||||
cmd =
|
||||
|
@ -28,6 +28,7 @@ import Data.DropdownStyle as DS
|
||||
import Data.Fields exposing (Field)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemTemplate as IT exposing (ItemTemplate)
|
||||
import Data.Pdf exposing (PdfMode)
|
||||
import Data.TagOrder
|
||||
import Data.UiSettings exposing (ItemPattern, Pos(..), UiSettings)
|
||||
import Dict exposing (Dict)
|
||||
@ -50,7 +51,8 @@ type alias Model =
|
||||
, searchPageSizeModel : Comp.IntField.Model
|
||||
, tagColors : Dict String Color
|
||||
, tagColorModel : Comp.ColorTagger.Model
|
||||
, nativePdfPreview : Bool
|
||||
, pdfMode : PdfMode
|
||||
, pdfModeModel : Comp.FixedDropdown.Model PdfMode
|
||||
, itemSearchNoteLength : Maybe Int
|
||||
, searchNoteLengthModel : Comp.IntField.Model
|
||||
, searchMenuFolderCount : Maybe Int
|
||||
@ -122,7 +124,8 @@ init flags settings =
|
||||
Comp.ColorTagger.init
|
||||
[]
|
||||
Data.Color.all
|
||||
, nativePdfPreview = settings.nativePdfPreview
|
||||
, pdfMode = settings.pdfMode
|
||||
, pdfModeModel = Comp.FixedDropdown.init Data.Pdf.allModes
|
||||
, itemSearchNoteLength = Just settings.itemSearchNoteLength
|
||||
, searchNoteLengthModel =
|
||||
Comp.IntField.init
|
||||
@ -169,7 +172,6 @@ type Msg
|
||||
= SearchPageSizeMsg Comp.IntField.Msg
|
||||
| TagColorMsg Comp.ColorTagger.Msg
|
||||
| GetTagsResp (Result Http.Error TagList)
|
||||
| TogglePdfPreview
|
||||
| NoteLengthMsg Comp.IntField.Msg
|
||||
| SearchMenuFolderMsg Comp.IntField.Msg
|
||||
| SearchMenuTagMsg Comp.IntField.Msg
|
||||
@ -185,6 +187,7 @@ type Msg
|
||||
| ToggleSideMenuVisible
|
||||
| TogglePowerSearch
|
||||
| UiLangMsg (Comp.FixedDropdown.Msg UiLanguage)
|
||||
| PdfModeMsg (Comp.FixedDropdown.Msg PdfMode)
|
||||
|
||||
|
||||
|
||||
@ -290,15 +293,6 @@ update sett msg model =
|
||||
in
|
||||
( model_, nextSettings )
|
||||
|
||||
TogglePdfPreview ->
|
||||
let
|
||||
flag =
|
||||
not model.nativePdfPreview
|
||||
in
|
||||
( { model | nativePdfPreview = flag }
|
||||
, Just { sett | nativePdfPreview = flag }
|
||||
)
|
||||
|
||||
GetTagsResp (Ok tl) ->
|
||||
let
|
||||
categories =
|
||||
@ -463,6 +457,22 @@ update sett msg model =
|
||||
Just { sett | uiLang = newLang }
|
||||
)
|
||||
|
||||
PdfModeMsg lm ->
|
||||
let
|
||||
( m, sel ) =
|
||||
Comp.FixedDropdown.update lm model.pdfModeModel
|
||||
|
||||
newMode =
|
||||
Maybe.withDefault model.pdfMode sel
|
||||
in
|
||||
( { model | pdfModeModel = m, pdfMode = newMode }
|
||||
, if newMode == model.pdfMode then
|
||||
Nothing
|
||||
|
||||
else
|
||||
Just { sett | pdfMode = newMode }
|
||||
)
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
@ -516,6 +526,13 @@ settingFormTabs texts flags _ model =
|
||||
, style = DS.mainStyle
|
||||
, selectPlaceholder = texts.basics.selectPlaceholder
|
||||
}
|
||||
|
||||
pdfModeCfg =
|
||||
{ display = texts.pdfMode
|
||||
, icon = \_ -> Nothing
|
||||
, style = DS.mainStyle
|
||||
, selectPlaceholder = texts.basics.selectPlaceholder
|
||||
}
|
||||
in
|
||||
[ { name = "general"
|
||||
, title = texts.general
|
||||
@ -689,13 +706,14 @@ settingFormTabs texts flags _ model =
|
||||
, info = Nothing
|
||||
, body =
|
||||
[ div [ class "mb-4" ]
|
||||
[ MB.viewItem <|
|
||||
MB.Checkbox
|
||||
{ tagger = \_ -> TogglePdfPreview
|
||||
, label = texts.browserNativePdfView
|
||||
, value = model.nativePdfPreview
|
||||
, id = "uisetting-pdfpreview-toggle"
|
||||
}
|
||||
[ label [ class S.inputLabel ] [ text texts.browserNativePdfView ]
|
||||
, Html.map PdfModeMsg
|
||||
(Comp.FixedDropdown.viewStyled2
|
||||
pdfModeCfg
|
||||
False
|
||||
(Just model.pdfMode)
|
||||
model.pdfModeModel
|
||||
)
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ MB.viewItem <|
|
||||
|
Reference in New Issue
Block a user