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

View File

@ -4,13 +4,7 @@ import Api
import Api.Model.Attachment exposing (Attachment)
import Comp.AttachmentMeta
import Comp.ConfirmModal
import Comp.ItemDetail.Model
exposing
( Model
, Msg(..)
, NotesField(..)
, SaveNameState(..)
)
import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..), ViewMode(..))
import Comp.MenuBar as MB
import Data.UiSettings exposing (UiSettings)
import Dict
@ -19,7 +13,6 @@ import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Html5.DragDrop as DD
import Messages.Comp.ItemDetail.SingleAttachment exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.Maybe
import Util.Size
@ -87,6 +80,7 @@ view texts settings model pos attach =
- toggle thumbs
- name + size
- eye icon to open it
- toggle multi select
- menu
- rename
- meta data
@ -112,6 +106,26 @@ attachHeader texts settings model _ attach =
multiAttach =
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 =
a
[ href "#"
@ -143,15 +157,40 @@ attachHeader texts settings model _ attach =
, title texts.openFileInNewTab
, class S.secondaryBasicButton
, class "ml-2"
, classList [ ( "hidden", selectView ) ]
]
[ 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.Dropdown
{ linkIcon = "fa fa-bars"
, linkClass =
[ ( "ml-2", True )
, ( S.secondaryBasicButton, True )
, ( "hidden", selectView )
]
, toggleMenu = ToggleAttachmentDropdown
, menuOpen = model.attachmentDropdownOpen

View File

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

View File

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