mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Attachments selectable
This commit is contained in:
parent
a9c02e9e88
commit
1db5eaf5ee
@ -108,6 +108,7 @@ type alias Model =
|
|||||||
, attachmentDropdownOpen : Bool
|
, attachmentDropdownOpen : Bool
|
||||||
, editMenuTabsOpen : Set String
|
, editMenuTabsOpen : Set String
|
||||||
, viewMode : ViewMode
|
, viewMode : ViewMode
|
||||||
|
, selectedAttachments: Set String
|
||||||
}
|
}
|
||||||
|
|
||||||
type ViewMode
|
type ViewMode
|
||||||
@ -201,6 +202,7 @@ emptyModel =
|
|||||||
, attachmentDropdownOpen = False
|
, attachmentDropdownOpen = False
|
||||||
, editMenuTabsOpen = Set.empty
|
, editMenuTabsOpen = Set.empty
|
||||||
, viewMode = SimpleView
|
, viewMode = SimpleView
|
||||||
|
, selectedAttachments = Set.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
initSelectViewModel : SelectViewModel
|
initSelectViewModel : SelectViewModel
|
||||||
@ -216,6 +218,7 @@ type Msg
|
|||||||
| Init
|
| Init
|
||||||
| SetItem ItemDetail
|
| SetItem ItemDetail
|
||||||
| SetActiveAttachment Int
|
| SetActiveAttachment Int
|
||||||
|
| ToggleAttachment String
|
||||||
| TagDropdownMsg (Comp.Dropdown.Msg Tag)
|
| TagDropdownMsg (Comp.Dropdown.Msg Tag)
|
||||||
| DirDropdownMsg (Comp.Dropdown.Msg Direction)
|
| DirDropdownMsg (Comp.Dropdown.Msg Direction)
|
||||||
| OrgDropdownMsg (Comp.Dropdown.Msg IdName)
|
| OrgDropdownMsg (Comp.Dropdown.Msg IdName)
|
||||||
|
@ -13,6 +13,7 @@ import Html.Attributes exposing (..)
|
|||||||
import Html.Events exposing (onClick, onInput)
|
import Html.Events exposing (onClick, onInput)
|
||||||
import Html5.DragDrop as DD
|
import Html5.DragDrop as DD
|
||||||
import Messages.Comp.ItemDetail.SingleAttachment exposing (Texts)
|
import Messages.Comp.ItemDetail.SingleAttachment exposing (Texts)
|
||||||
|
import Set
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Maybe
|
import Util.Maybe
|
||||||
import Util.Size
|
import Util.Size
|
||||||
@ -349,8 +350,30 @@ menuItem texts model pos attach =
|
|||||||
[ ( "bg-gray-300 dark:bg-bluegray-700 current-drop-target", enable )
|
[ ( "bg-gray-300 dark:bg-bluegray-700 current-drop-target", enable )
|
||||||
]
|
]
|
||||||
|
|
||||||
active =
|
iconClass =
|
||||||
model.visibleAttach == pos
|
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
|
in
|
||||||
a
|
a
|
||||||
([ classList <|
|
([ classList <|
|
||||||
@ -361,18 +384,18 @@ menuItem texts model pos attach =
|
|||||||
, class "flex flex-col relative border rounded px-1 py-1 mr-2"
|
, class "flex flex-col relative border rounded px-1 py-1 mr-2"
|
||||||
, class " hover:shadow dark:hover:border-bluegray-500"
|
, class " hover:shadow dark:hover:border-bluegray-500"
|
||||||
, href "#"
|
, href "#"
|
||||||
, onClick (SetActiveAttachment pos)
|
, onClick msg
|
||||||
]
|
]
|
||||||
++ DD.draggable AttachDDMsg attach.id
|
++ DD.draggable AttachDDMsg attach.id
|
||||||
++ DD.droppable AttachDDMsg attach.id
|
++ DD.droppable AttachDDMsg attach.id
|
||||||
)
|
)
|
||||||
[ div
|
[ div
|
||||||
[ classList
|
[ classList
|
||||||
[ ( "hidden", not active )
|
[ ( "hidden", not visible )
|
||||||
]
|
]
|
||||||
, class "absolute right-1 top-1 text-blue-400 dark:text-lightblue-400 text-xl"
|
, 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" ]
|
, div [ class "flex-grow" ]
|
||||||
[ img
|
[ img
|
||||||
|
@ -280,6 +280,18 @@ update key flags inav settings msg model =
|
|||||||
, attachRename = Nothing
|
, 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 ->
|
ToggleMenu ->
|
||||||
resultModel
|
resultModel
|
||||||
{ model | menuOpen = not model.menuOpen }
|
{ model | menuOpen = not model.menuOpen }
|
||||||
@ -1361,6 +1373,7 @@ update key flags inav settings msg model =
|
|||||||
resultModel { model
|
resultModel { model
|
||||||
| attachMenuOpen = not model.attachMenuOpen
|
| attachMenuOpen = not model.attachMenuOpen
|
||||||
, viewMode = SimpleView
|
, viewMode = SimpleView
|
||||||
|
, selectedAttachments = Set.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
UiSettingsUpdated ->
|
UiSettingsUpdated ->
|
||||||
@ -1585,6 +1598,7 @@ update key flags inav settings msg model =
|
|||||||
withSub
|
withSub
|
||||||
( { model
|
( { model
|
||||||
| viewMode = nextView
|
| viewMode = nextView
|
||||||
|
, selectedAttachments = Set.empty
|
||||||
}
|
}
|
||||||
, cmd
|
, cmd
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user