mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Use Ctrl modifier when navigating in item detail
Otherwise it clashes with input fields
This commit is contained in:
@ -25,6 +25,7 @@ import Comp.DetailEdit
|
||||
import Comp.Dropdown
|
||||
import Comp.Dropzone
|
||||
import Comp.ItemMail
|
||||
import Comp.KeyInput
|
||||
import Comp.MarkdownInput
|
||||
import Comp.SentMails
|
||||
import Comp.YesNoDimmer
|
||||
@ -40,7 +41,6 @@ import Http
|
||||
import Page exposing (Page(..))
|
||||
import Set exposing (Set)
|
||||
import Throttle exposing (Throttle)
|
||||
import Util.Html exposing (KeyCode)
|
||||
import Util.Tag
|
||||
|
||||
|
||||
@ -86,6 +86,7 @@ type alias Model =
|
||||
, attachDD : DD.Model String String
|
||||
, modalEdit : Maybe Comp.DetailEdit.Model
|
||||
, attachRename : Maybe AttachmentRename
|
||||
, keyInputModel : Comp.KeyInput.Model
|
||||
}
|
||||
|
||||
|
||||
@ -185,6 +186,7 @@ emptyModel =
|
||||
, attachDD = DD.init
|
||||
, modalEdit = Nothing
|
||||
, attachRename = Nothing
|
||||
, keyInputModel = Comp.KeyInput.init
|
||||
}
|
||||
|
||||
|
||||
@ -266,7 +268,7 @@ type Msg
|
||||
| ResetHiddenMsg Field (Result Http.Error BasicResult)
|
||||
| SaveNameResp (Result Http.Error BasicResult)
|
||||
| UpdateThrottle
|
||||
| KeyPress (Maybe KeyCode)
|
||||
| KeyInputMsg Comp.KeyInput.Msg
|
||||
|
||||
|
||||
type SaveNameState
|
||||
|
@ -28,12 +28,13 @@ import Comp.ItemDetail.Model
|
||||
, isEditNotes
|
||||
)
|
||||
import Comp.ItemMail
|
||||
import Comp.KeyInput
|
||||
import Comp.MarkdownInput
|
||||
import Comp.OrgForm
|
||||
import Comp.PersonForm
|
||||
import Comp.SentMails
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Direction exposing (Direction)
|
||||
import Data.Direction
|
||||
import Data.Fields exposing (Field)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemNav exposing (ItemNav)
|
||||
@ -51,7 +52,6 @@ import Throttle
|
||||
import Time
|
||||
import Util.File exposing (makeFileId)
|
||||
import Util.Folder exposing (mkFolderOption)
|
||||
import Util.Html exposing (KeyCode(..))
|
||||
import Util.Http
|
||||
import Util.List
|
||||
import Util.Maybe
|
||||
@ -1230,40 +1230,41 @@ update key flags inav settings msg model =
|
||||
in
|
||||
withSub ( { model | nameSaveThrottle = newThrottle }, cmd )
|
||||
|
||||
KeyPress n ->
|
||||
case n of
|
||||
Just Letter_C ->
|
||||
if model.item.state == "created" then
|
||||
update key flags inav settings ConfirmItem model
|
||||
KeyInputMsg lm ->
|
||||
let
|
||||
( km, keys ) =
|
||||
Comp.KeyInput.update lm model.keyInputModel
|
||||
|
||||
else
|
||||
noSub ( model, Cmd.none )
|
||||
model_ =
|
||||
{ model | keyInputModel = km }
|
||||
in
|
||||
if keys == Just Comp.KeyInput.ctrlC then
|
||||
if model.item.state == "created" then
|
||||
update key flags inav settings ConfirmItem model_
|
||||
|
||||
Just Letter_U ->
|
||||
if model.item.state /= "created" then
|
||||
update key flags inav settings UnconfirmItem model
|
||||
else
|
||||
update key flags inav settings UnconfirmItem model_
|
||||
|
||||
else
|
||||
noSub ( model, Cmd.none )
|
||||
else if keys == Just Comp.KeyInput.ctrlPoint then
|
||||
case inav.next of
|
||||
Just id ->
|
||||
noSub ( model_, Page.set key (ItemDetailPage id) )
|
||||
|
||||
Just Point ->
|
||||
case inav.next of
|
||||
Just id ->
|
||||
noSub ( model, Page.set key (ItemDetailPage id) )
|
||||
Nothing ->
|
||||
noSub ( model_, Cmd.none )
|
||||
|
||||
Nothing ->
|
||||
noSub ( model, Cmd.none )
|
||||
else if keys == Just Comp.KeyInput.ctrlComma then
|
||||
case inav.prev of
|
||||
Just id ->
|
||||
noSub ( model_, Page.set key (ItemDetailPage id) )
|
||||
|
||||
Just Comma ->
|
||||
case inav.prev of
|
||||
Just id ->
|
||||
noSub ( model, Page.set key (ItemDetailPage id) )
|
||||
Nothing ->
|
||||
noSub ( model_, Cmd.none )
|
||||
|
||||
Nothing ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
_ ->
|
||||
noSub ( model, Cmd.none )
|
||||
else
|
||||
-- withSub because the keypress may be inside the name
|
||||
-- field and requires to activate the throttle
|
||||
withSub ( model_, Cmd.none )
|
||||
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import Comp.Dropdown
|
||||
import Comp.Dropzone
|
||||
import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..))
|
||||
import Comp.ItemMail
|
||||
import Comp.KeyInput
|
||||
import Comp.MarkdownInput
|
||||
import Comp.SentMails
|
||||
import Comp.YesNoDimmer
|
||||
@ -28,7 +29,6 @@ import Page exposing (Page(..))
|
||||
import Set
|
||||
import Util.File exposing (makeFileId)
|
||||
import Util.Folder
|
||||
import Util.Html exposing (onKeyUpCode)
|
||||
import Util.List
|
||||
import Util.Maybe
|
||||
import Util.Size
|
||||
@ -39,8 +39,7 @@ import Util.Time
|
||||
view : ItemNav -> UiSettings -> Model -> Html Msg
|
||||
view inav settings model =
|
||||
div
|
||||
[ onKeyUpCode KeyPress
|
||||
]
|
||||
[]
|
||||
[ renderItemInfo settings model
|
||||
, renderDetailMenu inav model
|
||||
, renderMailForm settings model
|
||||
@ -113,7 +112,7 @@ renderDetailMenu inav model =
|
||||
, Maybe.map ItemDetailPage inav.prev
|
||||
|> Maybe.map Page.href
|
||||
|> Maybe.withDefault (href "#")
|
||||
, title "Previous item. Key ','"
|
||||
, title "Previous item. Key 'Ctrl-,'"
|
||||
]
|
||||
[ i [ class "caret square left outline icon" ] []
|
||||
]
|
||||
@ -125,7 +124,7 @@ renderDetailMenu inav model =
|
||||
, Maybe.map ItemDetailPage inav.next
|
||||
|> Maybe.map Page.href
|
||||
|> Maybe.withDefault (href "#")
|
||||
, title "Next item. Key '.'"
|
||||
, title "Next item. Key 'Ctrl-.'"
|
||||
]
|
||||
[ i [ class "caret square right outline icon" ] []
|
||||
]
|
||||
@ -709,7 +708,7 @@ renderTags settings model =
|
||||
renderEditMenu : UiSettings -> Model -> List (Html Msg)
|
||||
renderEditMenu settings model =
|
||||
[ Html.map ModalEditMsg (Comp.DetailEdit.viewModal settings model.modalEdit)
|
||||
, div []
|
||||
, div (Comp.KeyInput.eventsM KeyInputMsg)
|
||||
[ renderEditButtons model
|
||||
, renderEditForm settings model
|
||||
]
|
||||
@ -724,7 +723,7 @@ renderEditButtons model =
|
||||
[ ( "borderless item", True )
|
||||
, ( "invisible", model.item.state /= "created" )
|
||||
]
|
||||
, title "Confirm metadata. Key 'c'."
|
||||
, title "Confirm metadata. Key 'Ctrl-c'."
|
||||
, href "#"
|
||||
, onClick ConfirmItem
|
||||
]
|
||||
@ -736,7 +735,7 @@ renderEditButtons model =
|
||||
, ( "invisible", model.item.state /= "confirmed" )
|
||||
]
|
||||
, href "#"
|
||||
, title "Unconfirm metadata. Key 'u'."
|
||||
, title "Unconfirm metadata. Key 'Ctrl-c'."
|
||||
, onClick UnconfirmItem
|
||||
]
|
||||
[ i [ class "eye slash outline icon" ] []
|
||||
|
Reference in New Issue
Block a user