mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
Start search by pressing enter and not on each stroke
This reduces (unecessary) requests and eases the restless list rendering. Throttling is still in place to avoid too many requests when e.g. holding the enter-key.
This commit is contained in:
@ -25,8 +25,9 @@ import Data.UiSettings exposing (UiSettings)
|
||||
import DatePicker exposing (DatePicker)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onInput)
|
||||
import Html.Events exposing (onCheck, onClick, onInput)
|
||||
import Http
|
||||
import Util.Html exposing (KeyCode(..))
|
||||
import Util.Maybe
|
||||
import Util.Tag
|
||||
import Util.Update
|
||||
@ -57,6 +58,7 @@ type alias Model =
|
||||
, allNameModel : Maybe String
|
||||
, fulltextModel : Maybe String
|
||||
, datePickerInitialized : Bool
|
||||
, showNameHelp : Bool
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +116,7 @@ init =
|
||||
, allNameModel = Nothing
|
||||
, fulltextModel = Nothing
|
||||
, datePickerInitialized = False
|
||||
, showNameHelp = False
|
||||
}
|
||||
|
||||
|
||||
@ -139,6 +142,8 @@ type Msg
|
||||
| SetAllName String
|
||||
| SetFulltext String
|
||||
| ResetForm
|
||||
| KeyUpMsg (Maybe KeyCode)
|
||||
| ToggleNameHelp
|
||||
|
||||
|
||||
getDirection : Model -> Maybe Direction
|
||||
@ -475,7 +480,7 @@ update flags settings msg model =
|
||||
( { model | nameModel = next }
|
||||
, Cmd.none
|
||||
)
|
||||
(model.nameModel /= next)
|
||||
(model.nameModel /= Nothing && str == "")
|
||||
|
||||
SetAllName str ->
|
||||
let
|
||||
@ -486,7 +491,7 @@ update flags settings msg model =
|
||||
( { model | allNameModel = next }
|
||||
, Cmd.none
|
||||
)
|
||||
(model.allNameModel /= next)
|
||||
(model.allNameModel /= Nothing && str == "")
|
||||
|
||||
SetFulltext str ->
|
||||
let
|
||||
@ -497,7 +502,16 @@ update flags settings msg model =
|
||||
( { model | fulltextModel = next }
|
||||
, Cmd.none
|
||||
)
|
||||
(model.fulltextModel /= next)
|
||||
(model.fulltextModel /= Nothing && str == "")
|
||||
|
||||
KeyUpMsg (Just Enter) ->
|
||||
NextState ( model, Cmd.none ) True
|
||||
|
||||
KeyUpMsg _ ->
|
||||
NextState ( model, Cmd.none ) False
|
||||
|
||||
ToggleNameHelp ->
|
||||
NextState ( { model | showNameHelp = not model.showNameHelp }, Cmd.none ) False
|
||||
|
||||
|
||||
|
||||
@ -515,6 +529,21 @@ view flags settings model =
|
||||
]
|
||||
]
|
||||
|
||||
formHeaderHelp icon headline tagger =
|
||||
div [ class "ui small dividing header" ]
|
||||
[ a
|
||||
[ class "right-float"
|
||||
, href "#"
|
||||
, onClick tagger
|
||||
]
|
||||
[ i [ class "small grey help link icon" ] []
|
||||
]
|
||||
, icon
|
||||
, div [ class "content" ]
|
||||
[ text headline
|
||||
]
|
||||
]
|
||||
|
||||
nameIcon =
|
||||
i [ class "left align icon" ] []
|
||||
in
|
||||
@ -542,6 +571,7 @@ view flags settings model =
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetFulltext
|
||||
, Util.Html.onKeyUpCode KeyUpMsg
|
||||
, model.fulltextModel |> Maybe.withDefault "" |> value
|
||||
]
|
||||
[]
|
||||
@ -549,17 +579,36 @@ view flags settings model =
|
||||
[ text "Fulltext search in document contents."
|
||||
]
|
||||
]
|
||||
, formHeader nameIcon "Names"
|
||||
, formHeaderHelp nameIcon "Names" ToggleNameHelp
|
||||
, span
|
||||
[ classList
|
||||
[ ( "small-info", True )
|
||||
, ( "invisible hidden", not model.showNameHelp )
|
||||
]
|
||||
]
|
||||
[ text "Use wildcards "
|
||||
, code [] [ text "*" ]
|
||||
, text " at beginning or end. Added automatically if not "
|
||||
, text "present and not quoted. Press "
|
||||
, em [] [ text "Enter" ]
|
||||
, text " to start searching."
|
||||
]
|
||||
, div [ class "field" ]
|
||||
[ label [] [ text "All Names" ]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetAllName
|
||||
, Util.Html.onKeyUpCode KeyUpMsg
|
||||
, model.allNameModel |> Maybe.withDefault "" |> value
|
||||
]
|
||||
[]
|
||||
, span [ class "small-info" ]
|
||||
[ text "Looks in correspondents, concerned, item name and notes."
|
||||
, span
|
||||
[ classList
|
||||
[ ( "small-info", True )
|
||||
, ( "invisible hidden", not model.showNameHelp )
|
||||
]
|
||||
]
|
||||
[ text "Looks in correspondents, concerned entities, item name and notes."
|
||||
]
|
||||
]
|
||||
, div [ class "field" ]
|
||||
@ -567,18 +616,18 @@ view flags settings model =
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetName
|
||||
, Util.Html.onKeyUpCode KeyUpMsg
|
||||
, model.nameModel |> Maybe.withDefault "" |> value
|
||||
]
|
||||
[]
|
||||
, span [ class "small-info" ]
|
||||
[ text "Looks in item name."
|
||||
, span
|
||||
[ classList
|
||||
[ ( "small-info", True )
|
||||
, ( "invisible hidden", not model.showNameHelp )
|
||||
]
|
||||
]
|
||||
[ text "Looks in item name only."
|
||||
]
|
||||
]
|
||||
, span [ class "small-info" ]
|
||||
[ text "Use wildcards "
|
||||
, code [] [ text "*" ]
|
||||
, text " at beginning or end. Added automatically if not "
|
||||
, text "present and not quoted."
|
||||
]
|
||||
, formHeader (Icons.tagsIcon "") "Tags"
|
||||
, div [ class "field" ]
|
||||
|
Reference in New Issue
Block a user