Prepared multiselect view mode for attachment list

This commit is contained in:
Stefan Scheidewig 2021-04-17 13:04:30 +02:00
parent 558197e415
commit a9c02e9e88
4 changed files with 98 additions and 12 deletions

View File

@ -5,12 +5,14 @@ module Comp.ItemDetail.Model exposing
, NotesField(..) , NotesField(..)
, SaveNameState(..) , SaveNameState(..)
, UpdateResult , UpdateResult
, ViewMode(..)
, emptyModel , emptyModel
, isEditNotes , isEditNotes
, personMatchesOrg , personMatchesOrg
, resultModel , resultModel
, resultModelCmd , resultModelCmd
, resultModelCmdSub , resultModelCmdSub
, initSelectViewModel
) )
import Api.Model.BasicResult exposing (BasicResult) import Api.Model.BasicResult exposing (BasicResult)
@ -105,8 +107,21 @@ type alias Model =
, allPersons : Dict String Person , allPersons : Dict String Person
, attachmentDropdownOpen : Bool , attachmentDropdownOpen : Bool
, editMenuTabsOpen : Set String , editMenuTabsOpen : Set String
, viewMode : ViewMode
} }
type ViewMode
= SimpleView
| SelectView SelectViewModel
type alias SelectViewModel =
{ ids : Set String
, action : SelectActionMode
}
type SelectActionMode
= NoneAction
| DeleteSelected
type NotesField type NotesField
= ViewNotes = ViewNotes
@ -185,6 +200,13 @@ emptyModel =
, allPersons = Dict.empty , allPersons = Dict.empty
, attachmentDropdownOpen = False , attachmentDropdownOpen = False
, editMenuTabsOpen = Set.empty , editMenuTabsOpen = Set.empty
, viewMode = SimpleView
}
initSelectViewModel : SelectViewModel
initSelectViewModel =
{ ids = Set.empty
, action = NoneAction
} }
@ -283,6 +305,7 @@ type Msg
| ReprocessFileResp (Result Http.Error BasicResult) | ReprocessFileResp (Result Http.Error BasicResult)
| RequestReprocessItem | RequestReprocessItem
| ReprocessItemConfirmed | ReprocessItemConfirmed
| ToggleSelectView
type SaveNameState type SaveNameState

View File

@ -4,13 +4,7 @@ import Api
import Api.Model.Attachment exposing (Attachment) import Api.Model.Attachment exposing (Attachment)
import Comp.AttachmentMeta import Comp.AttachmentMeta
import Comp.ConfirmModal import Comp.ConfirmModal
import Comp.ItemDetail.Model import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..), ViewMode(..))
exposing
( Model
, Msg(..)
, NotesField(..)
, SaveNameState(..)
)
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Dict import Dict
@ -19,7 +13,6 @@ 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 Page exposing (Page(..))
import Styles as S import Styles as S
import Util.Maybe import Util.Maybe
import Util.Size import Util.Size
@ -87,6 +80,7 @@ view texts settings model pos attach =
- toggle thumbs - toggle thumbs
- name + size - name + size
- eye icon to open it - eye icon to open it
- toggle multi select
- menu - menu
- rename - rename
- meta data - meta data
@ -112,6 +106,26 @@ attachHeader texts settings model _ attach =
multiAttach = multiAttach =
List.length model.item.attachments > 1 List.length model.item.attachments > 1
selectPossible =
multiAttach && model.attachMenuOpen
selectView =
case model.viewMode of
SelectView _ ->
True
_ ->
False
selectToggleText =
case model.viewMode of
SelectView _ ->
texts.exitSelectMode
_ ->
texts.selectModeTitle
noAttachmentsSelected =
List.isEmpty model.item.attachments
attachSelectToggle mobile = attachSelectToggle mobile =
a a
[ href "#" [ href "#"
@ -143,15 +157,40 @@ attachHeader texts settings model _ attach =
, title texts.openFileInNewTab , title texts.openFileInNewTab
, class S.secondaryBasicButton , class S.secondaryBasicButton
, class "ml-2" , class "ml-2"
, classList [ ( "hidden", selectView ) ]
] ]
[ i [ class "fa fa-eye font-thin" ] [] [ i [ class "fa fa-eye font-thin" ] []
] ]
, a
[ classList [ (S.secondaryBasicButton ++ " text-sm", True)
, ( "bg-gray-200 dark:bg-bluegray-600", selectView )
, ( "hidden", not selectPossible )
, ( "ml-2", True )
]
, href "#"
, title selectToggleText
, onClick ToggleSelectView
]
[ i [ class "fa fa-tasks" ] []
]
, a
[ classList [ ( S.deleteButton, True )
, ( "disabled", noAttachmentsSelected )
, ( "hidden", not selectPossible || not selectView )
, ( "ml-2", True )
]
, href "#"
, title texts.deleteAttachments
]
[ i [ class "fa fa-trash" ] []
]
, MB.viewItem <| , MB.viewItem <|
MB.Dropdown MB.Dropdown
{ linkIcon = "fa fa-bars" { linkIcon = "fa fa-bars"
, linkClass = , linkClass =
[ ( "ml-2", True ) [ ( "ml-2", True )
, ( S.secondaryBasicButton, True ) , ( S.secondaryBasicButton, True )
, ( "hidden", selectView )
] ]
, toggleMenu = ToggleAttachmentDropdown , toggleMenu = ToggleAttachmentDropdown
, menuOpen = model.attachmentDropdownOpen , menuOpen = model.attachmentDropdownOpen

View File

@ -23,7 +23,6 @@ import Comp.DetailEdit
import Comp.Dropdown exposing (isDropdownChangeMsg) import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.Dropzone import Comp.Dropzone
import Comp.EquipmentForm import Comp.EquipmentForm
import Comp.ItemDetail.EditForm
import Comp.ItemDetail.FieldTabState as FTabState import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.Model import Comp.ItemDetail.Model
exposing exposing
@ -54,11 +53,10 @@ import Data.PersonUse
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import DatePicker import DatePicker
import Dict import Dict
import Html exposing (..)
import Html.Attributes exposing (..)
import Html5.DragDrop as DD import Html5.DragDrop as DD
import Http import Http
import Page exposing (Page(..)) import Page exposing (Page(..))
import Comp.ItemDetail.Model exposing (ViewMode(..), initSelectViewModel)
import Set exposing (Set) import Set exposing (Set)
import Throttle import Throttle
import Time import Time
@ -1360,7 +1358,10 @@ update key flags inav settings msg model =
withSub ( model_, Cmd.none ) withSub ( model_, Cmd.none )
ToggleAttachMenu -> ToggleAttachMenu ->
resultModel { model | attachMenuOpen = not model.attachMenuOpen } resultModel { model
| attachMenuOpen = not model.attachMenuOpen
, viewMode = SimpleView
}
UiSettingsUpdated -> UiSettingsUpdated ->
let let
@ -1571,6 +1572,23 @@ update key flags inav settings msg model =
in in
resultModelCmd ( { model | itemModal = Nothing }, cmd ) resultModelCmd ( { model | itemModal = Nothing }, cmd )
ToggleSelectView ->
let
( nextView, cmd ) =
case model.viewMode of
SimpleView ->
( SelectView initSelectViewModel, Cmd.none )
SelectView _ ->
( SimpleView, Cmd.none )
in
withSub
( { model
| viewMode = nextView
}
, cmd
)
--- Helper --- Helper

View File

@ -15,6 +15,9 @@ type alias Texts =
, viewExtractedData : String , viewExtractedData : String
, reprocessFile : String , reprocessFile : String
, deleteThisFile : String , deleteThisFile : String
, selectModeTitle : String
, exitSelectMode : String
, deleteAttachments: String
} }
@ -31,4 +34,7 @@ gb =
, viewExtractedData = "View extracted data" , viewExtractedData = "View extracted data"
, reprocessFile = "Re-process this file" , reprocessFile = "Re-process this file"
, deleteThisFile = "Delete this file" , deleteThisFile = "Delete this file"
, selectModeTitle = "Select Mode"
, exitSelectMode = "Exit Select Mode"
, deleteAttachments = "Delete attachments"
} }