diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm index 7a6db775..30085f5c 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm @@ -108,6 +108,7 @@ type alias Model = , attachmentDropdownOpen : Bool , editMenuTabsOpen : Set String , viewMode : ViewMode + , selectedAttachments: Set String } type ViewMode @@ -201,6 +202,7 @@ emptyModel = , attachmentDropdownOpen = False , editMenuTabsOpen = Set.empty , viewMode = SimpleView + , selectedAttachments = Set.empty } initSelectViewModel : SelectViewModel @@ -216,6 +218,7 @@ type Msg | Init | SetItem ItemDetail | SetActiveAttachment Int + | ToggleAttachment String | TagDropdownMsg (Comp.Dropdown.Msg Tag) | DirDropdownMsg (Comp.Dropdown.Msg Direction) | OrgDropdownMsg (Comp.Dropdown.Msg IdName) diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm index fe49677c..2a91ecd9 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm @@ -13,6 +13,7 @@ import Html.Attributes exposing (..) import Html.Events exposing (onClick, onInput) import Html5.DragDrop as DD import Messages.Comp.ItemDetail.SingleAttachment exposing (Texts) +import Set import Styles as S import Util.Maybe import Util.Size @@ -349,8 +350,30 @@ menuItem texts model pos attach = [ ( "bg-gray-300 dark:bg-bluegray-700 current-drop-target", enable ) ] - active = - model.visibleAttach == pos + iconClass = + case model.viewMode of + SelectView _ -> + if Set.member attach.id model.selectedAttachments then + "fa fa-check-circle ml-1" + else + "fa fa-circle ml-1" + _ -> + "fa fa-check-circle ml-1" + + visible = + case model.viewMode of + SelectView _ -> + True + _ -> + model.visibleAttach == pos + + msg = + case model.viewMode of + SelectView _ -> + (ToggleAttachment attach.id) + _ -> + (SetActiveAttachment pos) + in a ([ classList <| @@ -361,18 +384,18 @@ menuItem texts model pos attach = , class "flex flex-col relative border rounded px-1 py-1 mr-2" , class " hover:shadow dark:hover:border-bluegray-500" , href "#" - , onClick (SetActiveAttachment pos) + , onClick msg ] ++ DD.draggable AttachDDMsg attach.id ++ DD.droppable AttachDDMsg attach.id ) [ div [ classList - [ ( "hidden", not active ) + [ ( "hidden", not visible ) ] , class "absolute right-1 top-1 text-blue-400 dark:text-lightblue-400 text-xl" ] - [ i [ class "fa fa-check-circle ml-1" ] [] + [ i [ class iconClass ] [] ] , div [ class "flex-grow" ] [ img diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm index 544ed354..c5bf374a 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm @@ -280,6 +280,18 @@ update key flags inav settings msg model = , attachRename = Nothing } + ToggleAttachment id -> + if Set.member id model.selectedAttachments then + resultModel + { model + | selectedAttachments = Set.remove id model.selectedAttachments + } + else + resultModel + { model + | selectedAttachments = Set.insert id model.selectedAttachments + } + ToggleMenu -> resultModel { model | menuOpen = not model.menuOpen } @@ -1361,6 +1373,7 @@ update key flags inav settings msg model = resultModel { model | attachMenuOpen = not model.attachMenuOpen , viewMode = SimpleView + , selectedAttachments = Set.empty } UiSettingsUpdated -> @@ -1585,6 +1598,7 @@ update key flags inav settings msg model = withSub ( { model | viewMode = nextView + , selectedAttachments = Set.empty } , cmd )