diff --git a/modules/webapp/src/main/elm/Api.elm b/modules/webapp/src/main/elm/Api.elm index a049bce3..bb6b94e7 100644 --- a/modules/webapp/src/main/elm/Api.elm +++ b/modules/webapp/src/main/elm/Api.elm @@ -143,6 +143,7 @@ module Api exposing , setTagsMultiple , setUnconfirmed , shareAttachmentPreviewURL + , shareFileURL , shareItemBasePreviewURL , startClassifier , startEmptyTrash @@ -2311,6 +2312,11 @@ shareItemBasePreviewURL itemId = "/api/v1/share/item/" ++ itemId ++ "/preview?withFallback=true" +shareFileURL : String -> String +shareFileURL attachId = + "/api/v1/share/attachment/" ++ attachId + + --- Helper diff --git a/modules/webapp/src/main/elm/Comp/ItemCard.elm b/modules/webapp/src/main/elm/Comp/ItemCard.elm index b4ce9786..15d66ce5 100644 --- a/modules/webapp/src/main/elm/Comp/ItemCard.elm +++ b/modules/webapp/src/main/elm/Comp/ItemCard.elm @@ -58,6 +58,7 @@ type alias ViewConfig = , extraClasses : String , previewUrl : AttachmentLight -> String , previewUrlFallback : ItemLight -> String + , attachUrl : AttachmentLight -> String } @@ -219,7 +220,7 @@ view2 texts cfg settings model item = , metaDataContent2 texts settings item , notesContent2 settings item , fulltextResultsContent2 item - , previewMenu2 texts settings model item (currentAttachment model item) + , previewMenu2 texts settings cfg model item (currentAttachment model item) , selectedDimmer ] ) @@ -473,8 +474,8 @@ previewImage2 cfg settings cardAction model item = ] -previewMenu2 : Texts -> UiSettings -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg -previewMenu2 texts settings model item mainAttach = +previewMenu2 : Texts -> UiSettings -> ViewConfig -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg +previewMenu2 texts settings cfg model item mainAttach = let pageCount = Maybe.andThen .pageCount mainAttach @@ -486,16 +487,15 @@ previewMenu2 texts settings model item mainAttach = fieldHidden f = Data.UiSettings.fieldHidden settings f - mkAttachUrl id = + mkAttachUrl attach = if settings.nativePdfPreview then - Api.fileURL id + cfg.attachUrl attach else - Api.fileURL id ++ "/view" + cfg.attachUrl attach ++ "/view" attachUrl = - Maybe.map .id mainAttach - |> Maybe.map mkAttachUrl + Maybe.map mkAttachUrl mainAttach |> Maybe.withDefault "/api/v1/sec/attachment/none" dueDate = diff --git a/modules/webapp/src/main/elm/Comp/ItemCardList.elm b/modules/webapp/src/main/elm/Comp/ItemCardList.elm index 6c66004d..a23894e2 100644 --- a/modules/webapp/src/main/elm/Comp/ItemCardList.elm +++ b/modules/webapp/src/main/elm/Comp/ItemCardList.elm @@ -164,6 +164,7 @@ type alias ViewConfig = , selection : ItemSelection , previewUrl : AttachmentLight -> String , previewUrlFallback : ItemLight -> String + , attachUrl : AttachmentLight -> String } @@ -219,7 +220,7 @@ viewItem2 texts model cfg settings item = "" vvcfg = - Comp.ItemCard.ViewConfig cfg.selection currentClass cfg.previewUrl cfg.previewUrlFallback + Comp.ItemCard.ViewConfig cfg.selection currentClass cfg.previewUrl cfg.previewUrlFallback cfg.attachUrl cardModel = Dict.get item.id model.itemCards diff --git a/modules/webapp/src/main/elm/Page/Home/View2.elm b/modules/webapp/src/main/elm/Page/Home/View2.elm index b0ca349e..506ae853 100644 --- a/modules/webapp/src/main/elm/Page/Home/View2.elm +++ b/modules/webapp/src/main/elm/Page/Home/View2.elm @@ -476,6 +476,7 @@ itemCardList texts _ settings model = (Data.ItemSelection.Active svm.ids) previewUrl previewUrlFallback + (.id >> Api.fileURL) _ -> Comp.ItemCardList.ViewConfig @@ -483,6 +484,7 @@ itemCardList texts _ settings model = Data.ItemSelection.Inactive previewUrl previewUrlFallback + (.id >> Api.fileURL) in [ Html.map ItemCardListMsg (Comp.ItemCardList.view2 texts.itemCardList diff --git a/modules/webapp/src/main/elm/Page/Share/Results.elm b/modules/webapp/src/main/elm/Page/Share/Results.elm index c50af9e8..5bd69400 100644 --- a/modules/webapp/src/main/elm/Page/Share/Results.elm +++ b/modules/webapp/src/main/elm/Page/Share/Results.elm @@ -25,6 +25,7 @@ view texts settings model = , selection = Data.ItemSelection.Inactive , previewUrl = \attach -> Api.shareAttachmentPreviewURL attach.id , previewUrlFallback = \item -> Api.shareItemBasePreviewURL item.id + , attachUrl = .id >> Api.shareFileURL } in div []