First ui view of preview images for items

Users can choose to not show them via ui settings
This commit is contained in:
Eike Kettner
2020-11-08 15:11:00 +01:00
parent 7ba6baf6f0
commit 2c96590aad
6 changed files with 50 additions and 2 deletions

View File

@ -30,6 +30,7 @@ module Api exposing
, deleteSource , deleteSource
, deleteTag , deleteTag
, deleteUser , deleteUser
, fileURL
, getAttachmentMeta , getAttachmentMeta
, getCollective , getCollective
, getCollectiveSettings , getCollectiveSettings
@ -59,6 +60,7 @@ module Api exposing
, getUsers , getUsers
, itemDetail , itemDetail
, itemIndexSearch , itemIndexSearch
, itemPreviewURL
, itemSearch , itemSearch
, login , login
, loginSession , loginSession
@ -1501,6 +1503,16 @@ deleteAllItems flags ids receive =
--- Item --- Item
itemPreviewURL : String -> String
itemPreviewURL itemId =
"/api/v1/sec/item/" ++ itemId ++ "/preview"
fileURL : String -> String
fileURL attachId =
"/api/v1/sec/attachment/" ++ attachId
setAttachmentName : setAttachmentName :
Flags Flags
-> String -> String

View File

@ -10,6 +10,7 @@ module Comp.ItemCardList exposing
, view , view
) )
import Api
import Api.Model.HighlightEntry exposing (HighlightEntry) import Api.Model.HighlightEntry exposing (HighlightEntry)
import Api.Model.ItemLight exposing (ItemLight) import Api.Model.ItemLight exposing (ItemLight)
import Api.Model.ItemLightGroup exposing (ItemLightGroup) import Api.Model.ItemLightGroup exposing (ItemLightGroup)
@ -230,7 +231,18 @@ viewItem cfg settings item =
] ]
++ DD.draggable ItemDDMsg item.id ++ DD.draggable ItemDDMsg item.id
) )
[ div [ class "content" ] [ if fieldHidden Data.Fields.PreviewImage then
span [ class "invisible" ] []
else
div [ class "image" ]
[ img
[ class "preview-image"
, src (Api.itemPreviewURL item.id)
]
[]
]
, div [ class "content" ]
[ case cfg.selection of [ case cfg.selection of
Data.ItemSelection.Active ids -> Data.ItemSelection.Active ids ->
div [ class "header" ] div [ class "header" ]

View File

@ -1464,6 +1464,9 @@ resetField flags item tagger field =
Data.Fields.Direction -> Data.Fields.Direction ->
Cmd.none Cmd.none
Data.Fields.PreviewImage ->
Cmd.none
resetHiddenFields : resetHiddenFields :
UiSettings UiSettings

View File

@ -1,5 +1,6 @@
module Comp.ItemDetail.View exposing (view) module Comp.ItemDetail.View exposing (view)
import Api
import Api.Model.Attachment exposing (Attachment) import Api.Model.Attachment exposing (Attachment)
import Comp.AttachmentMeta import Comp.AttachmentMeta
import Comp.DatePicker import Comp.DatePicker
@ -320,7 +321,7 @@ renderAttachmentView : UiSettings -> Model -> Int -> Attachment -> Html Msg
renderAttachmentView settings model pos attach = renderAttachmentView settings model pos attach =
let let
fileUrl = fileUrl =
"/api/v1/sec/attachment/" ++ attach.id Api.fileURL attach.id
attachName = attachName =
Maybe.withDefault "No name" attach.name Maybe.withDefault "No name" attach.name

View File

@ -19,6 +19,7 @@ type Field
| Date | Date
| DueDate | DueDate
| Direction | Direction
| PreviewImage
all : List Field all : List Field
@ -33,6 +34,7 @@ all =
, Date , Date
, DueDate , DueDate
, Direction , Direction
, PreviewImage
] ]
@ -71,6 +73,9 @@ fromString str =
"direction" -> "direction" ->
Just Direction Just Direction
"preview" ->
Just PreviewImage
_ -> _ ->
Nothing Nothing
@ -105,6 +110,9 @@ toString field =
Direction -> Direction ->
"direction" "direction"
PreviewImage ->
"preview"
label : Field -> String label : Field -> String
label field = label field =
@ -136,6 +144,9 @@ label field =
Direction -> Direction ->
"Direction" "Direction"
PreviewImage ->
"Preview Image"
fromList : List String -> List Field fromList : List String -> List Field
fromList strings = fromList strings =

View File

@ -93,6 +93,15 @@
padding: 0.8em; padding: 0.8em;
} }
.default-layout .ui.card div.image {
background: #fff;
}
.default-layout img.preview-image {
max-width: 200px;
margin-left: auto;
margin-right: auto;
}
.default-layout .menu .item.active a.right-tab-icon-link { .default-layout .menu .item.active a.right-tab-icon-link {
position: relative; position: relative;
right: -8px; right: -8px;