Improve selecting attachments of an item

Use a list of small thumbnails instead of just names.

Closes: #396
This commit is contained in:
Eike Kettner 2021-01-08 22:06:55 +01:00
parent 9bc2084499
commit c0d7aba5d5
4 changed files with 55 additions and 23 deletions

View File

@ -1,10 +1,11 @@
module Comp.ItemDetail.AttachmentTabMenu exposing (view) module Comp.ItemDetail.AttachmentTabMenu exposing (view)
import Api
import Api.Model.Attachment exposing (Attachment) import Api.Model.Attachment exposing (Attachment)
import Comp.ItemDetail.Model exposing (Model, Msg(..)) import Comp.ItemDetail.Model exposing (Model, Msg(..))
import Comp.SentMails import Comp.SentMails
import Html exposing (Html, a, div, i, text) import Html exposing (Html, a, div, i, img, text)
import Html.Attributes exposing (class, classList, href, title) import Html.Attributes exposing (class, classList, href, src, title)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Html5.DragDrop as DD import Html5.DragDrop as DD
import Util.List import Util.List
@ -12,13 +13,23 @@ import Util.Maybe
import Util.String import Util.String
view : Model -> Html Msg view : Model -> List (Html Msg)
view model = view model =
div [ class "ui top attached tabular menu" ] [ div [ class "ui top attached tabular menu" ]
(activeAttach model (activeAttach model
:: selectMenu model :: selectMenu model
++ sentMailsTab model ++ sentMailsTab model
) )
, div
[ classList
[ ( "ui attached segment", model.attachMenuOpen )
, ( "invisible hidden", not model.attachMenuOpen )
]
]
[ div [ class "ui doubling small cards" ]
(List.indexedMap (menuItem model) model.item.attachments)
]
]
activeAttach : Model -> Html Msg activeAttach : Model -> Html Msg
@ -94,14 +105,6 @@ selectMenu model =
] ]
] ]
[] []
, div
[ classList
[ ( "menu transition", True )
, ( "visible", model.attachMenuOpen )
, ( "hidden", not model.attachMenuOpen )
]
]
(List.indexedMap (menuItem model) model.item.attachments)
] ]
] ]
@ -109,7 +112,7 @@ selectMenu model =
menuItem : Model -> Int -> Attachment -> Html Msg menuItem : Model -> Int -> Attachment -> Html Msg
menuItem model pos attach = menuItem model pos attach =
let let
highlight el = highlight =
let let
dropId = dropId =
DD.getDropId model.attachDD DD.getDropId model.attachDD
@ -118,26 +121,46 @@ menuItem model pos attach =
DD.getDragId model.attachDD DD.getDragId model.attachDD
enable = enable =
Just el.id == dropId && dropId /= dragId Just attach.id == dropId && dropId /= dragId
in in
[ ( "current-drop-target", enable ) [ ( "current-drop-target", enable )
] ]
active =
model.visibleAttach == pos
in in
a a
([ classList <| ([ classList <|
[ ( "item", True ) [ ( "ui card", True )
, ( "blue", pos == 0 )
] ]
++ highlight attach ++ highlight
, href "#" , href "#"
, onClick (SetActiveAttachment pos) , onClick (SetActiveAttachment pos)
] ]
++ DD.draggable AttachDDMsg attach.id ++ DD.draggable AttachDDMsg attach.id
++ DD.droppable AttachDDMsg attach.id ++ DD.droppable AttachDDMsg attach.id
) )
[ div
[ classList [ ( "invisible hidden", not active ) ]
, class "ui corner icon label"
]
[ i [ class "check icon" ] []
]
, div [ class "image" ]
[ img
[ src (Api.attachmentPreviewURL attach.id)
]
[]
]
, div [ class "content" ]
[ div [ class "description" ]
[ Maybe.map (Util.String.ellipsis 60) attach.name [ Maybe.map (Util.String.ellipsis 60) attach.name
|> Maybe.withDefault "No Name" |> Maybe.withDefault "No Name"
|> text |> text
] ]
]
]
sentMailsTab : Model -> List (Html Msg) sentMailsTab : Model -> List (Html Msg)

View File

@ -88,6 +88,7 @@ update key flags inav settings msg model =
, dueDatePicker = dp , dueDatePicker = dp
, itemMail = im , itemMail = im
, visibleAttach = 0 , visibleAttach = 0
, attachMenuOpen = False
, customFieldsModel = cm , customFieldsModel = cm
} }
, Cmd.batch , Cmd.batch
@ -274,6 +275,7 @@ update key flags inav settings msg model =
resultModel resultModel
{ model { model
| visibleAttach = pos | visibleAttach = pos
, attachMenuOpen = False
, sentMailsOpen = False , sentMailsOpen = False
, attachRename = Nothing , attachRename = Nothing
} }

View File

@ -84,8 +84,7 @@ view inav settings model =
else else
[] []
, [ renderAttachmentsTabMenu model , renderAttachmentsTabMenu model
]
, renderAttachmentsTabBody settings model , renderAttachmentsTabBody settings model
, renderIdInfo model , renderIdInfo model
, if settings.itemDetailNotesPosition == Data.UiSettings.Bottom then , if settings.itemDetailNotesPosition == Data.UiSettings.Bottom then
@ -319,7 +318,7 @@ attachmentVisible model pos =
) )
renderAttachmentsTabMenu : Model -> Html Msg renderAttachmentsTabMenu : Model -> List (Html Msg)
renderAttachmentsTabMenu model = renderAttachmentsTabMenu model =
Comp.ItemDetail.AttachmentTabMenu.view model Comp.ItemDetail.AttachmentTabMenu.view model

View File

@ -225,9 +225,17 @@ textarea.markdown-editor {
background: rgba(240,248,255,0.4); background: rgba(240,248,255,0.4);
} }
.default-layout .ui.dropdown .menu .item.current-drop-target, .header.current-drop-target, .item.current-drop-target { .default-layout .ui.dropdown .menu .current-drop-target, .header.current-drop-target, .current-drop-target {
background: rgba(0,0,0,0.2) !important; background: rgba(0,0,0,0.2) !important;
} }
.default-layout .ui.cards.small > .ui.card {
max-width: 180px;
}
.default-layout .ui.cards.small > .ui.card .image {
max-width: 100px;
margin-left: auto;
margin-right: auto;
}
.default-layout .search-menu { .default-layout .search-menu {
box-shadow: 2px 1px 3px rgba(216, 223, 229, 1); box-shadow: 2px 1px 3px rgba(216, 223, 229, 1);