mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Refactor to allow internal card links into search menu
Also allows to exchange the preview-url in the item card
This commit is contained in:
@ -56,6 +56,8 @@ type Msg
|
||||
type alias ViewConfig =
|
||||
{ selection : ItemSelection
|
||||
, extraClasses : String
|
||||
, previewUrl : AttachmentLight -> String
|
||||
, previewUrlFallback : ItemLight -> String
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +162,7 @@ view2 texts cfg settings model item =
|
||||
"text-blue-500 dark:text-lightblue-500"
|
||||
|
||||
else if isDeleted then
|
||||
"text-red-600 dark:text-orange-600"
|
||||
"text-red-600 dark:text-orange-600"
|
||||
|
||||
else
|
||||
""
|
||||
@ -210,7 +212,7 @@ view2 texts cfg settings model item =
|
||||
[]
|
||||
|
||||
else
|
||||
[ previewImage2 settings cardAction model item
|
||||
[ previewImage2 cfg settings cardAction model item
|
||||
]
|
||||
)
|
||||
++ [ mainContent2 texts cardAction cardColor isCreated isDeleted settings cfg item
|
||||
@ -443,16 +445,15 @@ mainTagsAndFields2 settings item =
|
||||
(renderFields ++ renderTags)
|
||||
|
||||
|
||||
previewImage2 : UiSettings -> List (Attribute Msg) -> Model -> ItemLight -> Html Msg
|
||||
previewImage2 settings cardAction model item =
|
||||
previewImage2 : ViewConfig -> UiSettings -> List (Attribute Msg) -> Model -> ItemLight -> Html Msg
|
||||
previewImage2 cfg settings cardAction model item =
|
||||
let
|
||||
mainAttach =
|
||||
currentAttachment model item
|
||||
|
||||
previewUrl =
|
||||
Maybe.map .id mainAttach
|
||||
|> Maybe.map Api.attachmentPreviewURL
|
||||
|> Maybe.withDefault (Api.itemBasePreviewURL item.id)
|
||||
Maybe.map cfg.previewUrl mainAttach
|
||||
|> Maybe.withDefault (cfg.previewUrlFallback item)
|
||||
in
|
||||
a
|
||||
([ class "overflow-hidden block bg-gray-50 dark:bg-bluegray-700 dark:bg-opacity-40 border-gray-400 dark:hover:border-bluegray-500 rounded-t-lg"
|
||||
|
@ -17,6 +17,7 @@ module Comp.ItemCardList exposing
|
||||
, view2
|
||||
)
|
||||
|
||||
import Api.Model.AttachmentLight exposing (AttachmentLight)
|
||||
import Api.Model.ItemLight exposing (ItemLight)
|
||||
import Api.Model.ItemLightGroup exposing (ItemLightGroup)
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
@ -72,13 +73,13 @@ prevItem model id =
|
||||
--- Update
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, LinkTarget )
|
||||
update flags msg model =
|
||||
let
|
||||
res =
|
||||
updateDrag DD.init flags msg model
|
||||
in
|
||||
( res.model, res.cmd )
|
||||
( res.model, res.cmd, res.linkTarget )
|
||||
|
||||
|
||||
type alias UpdateResult =
|
||||
@ -161,6 +162,8 @@ updateDrag dm _ msg model =
|
||||
type alias ViewConfig =
|
||||
{ current : Maybe String
|
||||
, selection : ItemSelection
|
||||
, previewUrl : AttachmentLight -> String
|
||||
, previewUrlFallback : ItemLight -> String
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +219,7 @@ viewItem2 texts model cfg settings item =
|
||||
""
|
||||
|
||||
vvcfg =
|
||||
Comp.ItemCard.ViewConfig cfg.selection currentClass
|
||||
Comp.ItemCard.ViewConfig cfg.selection currentClass cfg.previewUrl cfg.previewUrlFallback
|
||||
|
||||
cardModel =
|
||||
Dict.get item.id model.itemCards
|
||||
|
@ -14,6 +14,7 @@ module Comp.SearchMenu exposing
|
||||
, init
|
||||
, isFulltextSearch
|
||||
, isNamesSearch
|
||||
, linkTargetMsg
|
||||
, textSearchString
|
||||
, update
|
||||
, updateDrop
|
||||
@ -34,6 +35,7 @@ import Comp.CustomFieldMultiInput
|
||||
import Comp.DatePicker
|
||||
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
||||
import Comp.FolderSelect
|
||||
import Comp.LinkTarget exposing (LinkTarget)
|
||||
import Comp.MenuBar as MB
|
||||
import Comp.Tabs
|
||||
import Comp.TagSelect
|
||||
@ -377,6 +379,37 @@ type Msg
|
||||
| ToggleOpenAllAkkordionTabs
|
||||
|
||||
|
||||
linkTargetMsg : LinkTarget -> Maybe Msg
|
||||
linkTargetMsg linkTarget =
|
||||
case linkTarget of
|
||||
Comp.LinkTarget.LinkNone ->
|
||||
Nothing
|
||||
|
||||
Comp.LinkTarget.LinkCorrOrg id ->
|
||||
Just <| SetCorrOrg id
|
||||
|
||||
Comp.LinkTarget.LinkCorrPerson id ->
|
||||
Just <| SetCorrPerson id
|
||||
|
||||
Comp.LinkTarget.LinkConcPerson id ->
|
||||
Just <| SetConcPerson id
|
||||
|
||||
Comp.LinkTarget.LinkConcEquip id ->
|
||||
Just <| SetConcEquip id
|
||||
|
||||
Comp.LinkTarget.LinkFolder id ->
|
||||
Just <| SetFolder id
|
||||
|
||||
Comp.LinkTarget.LinkTag id ->
|
||||
Just <| SetTag id.id
|
||||
|
||||
Comp.LinkTarget.LinkCustomField id ->
|
||||
Just <| SetCustomField id
|
||||
|
||||
Comp.LinkTarget.LinkSource str ->
|
||||
Just <| ResetToSource str
|
||||
|
||||
|
||||
type alias NextState =
|
||||
{ model : Model
|
||||
, cmd : Cmd Msg
|
||||
|
Reference in New Issue
Block a user