Commit 9b659dbf authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[DocsTable] keyup enter event for search

parent 8ccdc2e6
...@@ -24,6 +24,7 @@ import Data.Int (fromString) ...@@ -24,6 +24,7 @@ import Data.Int (fromString)
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst) import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
...@@ -31,6 +32,7 @@ import Effect.Uncurried (EffectFn1, mkEffectFn1) ...@@ -31,6 +32,7 @@ import Effect.Uncurried (EffectFn1, mkEffectFn1)
import React as React import React as React
import React (ReactClass, ReactElement, Children) import React (ReactClass, ReactElement, Children)
import Reactix as R import Reactix as R
import Reactix.SyntheticEvent as RE
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -210,7 +212,7 @@ searchBar (query /\ setQuery) = R.createElement el {} [] ...@@ -210,7 +212,7 @@ searchBar (query /\ setQuery) = R.createElement el {} []
[ H.div {className: "col col-md-3 form-group"} [ H.div {className: "col col-md-3 form-group"}
[ H.input { type: "text" [ H.input { type: "text"
, className: "form-control" , className: "form-control"
, on: {change: onSearchChange queryText} , on: {change: onSearchChange queryText, keyUp: onSearchKeyup queryText}
, placeholder: query} , placeholder: query}
] ]
, H.div {className: "col col-md-1"} , H.div {className: "col col-md-1"}
...@@ -225,6 +227,13 @@ searchBar (query /\ setQuery) = R.createElement el {} [] ...@@ -225,6 +227,13 @@ searchBar (query /\ setQuery) = R.createElement el {} []
onSearchChange (_ /\ setQueryText) = \e -> onSearchChange (_ /\ setQueryText) = \e ->
setQueryText $ const $ R2.unsafeEventValue e setQueryText $ const $ R2.unsafeEventValue e
onSearchKeyup :: R.State Query -> DE.KeyboardEvent -> Effect Unit
onSearchKeyup (queryText /\ _) = \e ->
if DE.key e == "Enter" then
setQuery $ const queryText
else
pure $ unit
onSearchClick :: forall e. R.State Query -> e -> Effect Unit onSearchClick :: forall e. R.State Query -> e -> Effect Unit
onSearchClick (queryText /\ _) = \e -> onSearchClick (queryText /\ _) = \e ->
setQuery $ const queryText setQuery $ const queryText
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment