Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
83b4876a
Commit
83b4876a
authored
Jul 06, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngramsTable] search: delay search on button/enter press
parent
83e84d51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
25 deletions
+41
-25
Search.purs
src/Gargantext/Components/NgramsTable/Search.purs
+35
-25
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+6
-0
No files found.
src/Gargantext/Components/NgramsTable/Search.purs
View file @
83b4876a
...
...
@@ -32,8 +32,8 @@ searchInputCpt = here.component "searchInput" cpt
pure $ R2.row
[ H.div { className: "col-12" }
[ H.div { className: "input-group" }
[ search
Button
{ inputRef, searchQuery } []
, search
FieldInput
{ inputRef, searchQuery } []
[ search
FieldInput
{ inputRef, searchQuery } []
, search
Button
{ inputRef, searchQuery } []
]
]
]
...
...
@@ -53,31 +53,34 @@ searchButtonCpt = here.component "searchButton" cpt where
pure $
H.div
{ className: intercalate " "
[ "search-button-prepend"
, "input-group-prepend"
]
}
{ className: "search-button-append input-group-append" }
[
if searchQuery' /= ""
then
B.button
{ variant: ButtonVariant Light
, callback: \_ -> R2.setInputValue inputRef ""
-- T.write "" searchQuery
, className: "input-group-text"
}
[
B.icon
{ name: "times"
, className: "text-danger"
}
]
R.fragment
[ B.button
{ variant: ButtonVariant Light
, callback: \_ -> do
R2.setInputValue inputRef ""
T.write_ "" searchQuery
, className: "input-group-text" }
[ B.icon
{ name: "times"
, className: "text-danger"
}
]
, B.button { callback: \_ -> T.write_ (R2.getInputValue inputRef) searchQuery
, className: "input-group-text" }
[ B.icon { name: "search" }
]
]
else
B.icon
{ name: "search"
, className: "input-group-text"
}
B.button { callback: \_ -> T.write_ (R2.getInputValue inputRef) searchQuery
, className: "input-group-text" }
[ B.icon
{ name: "search" }
]
]
type SearchFieldInputProps =
...
...
@@ -90,13 +93,20 @@ searchFieldInput = R.createElement searchFieldInputCpt
searchFieldInputCpt :: R.Component SearchFieldInputProps
searchFieldInputCpt = here.component "searchFieldInput" cpt where
cpt { inputRef, searchQuery } _ = do
-- searchQuery' <- T.useLive T.unequal searchQuery
pure $ H.input { className: "form-control"
-- , defaultValue: searchQuery'
, name: "search"
, on: {
input: \e -> T.write (R.unsafeEventValue e) searchQuery
}
, on: {
keyPress: onKeyPress
}
, placeholder: "Search"
, ref: inputRef
, type: "value"
}
where
onKeyPress e = do
char <- R2.keyCode e
if char == 13 then
T.write_ (R2.getInputValue inputRef) searchQuery
else
pure unit
src/Gargantext/Utils/Reactix.purs
View file @
83b4876a
...
...
@@ -608,6 +608,12 @@ foreign import _triggerEvent
triggerEvent :: forall el. el -> String -> Effect Unit
triggerEvent = runEffectFn2 _triggerEvent
-------------------------------------------------------
getInputValue :: R.Ref (Nullable DOM.Element) -> String
getInputValue elNullableRef = case toMaybe (R.readRef elNullableRef) of
Nothing -> ""
Just el ->
el .. "value"
setInputValue :: R.Ref (Nullable DOM.Element) -> String -> Effect Unit
setInputValue elNullableRef val = case toMaybe (R.readRef elNullableRef) of
Nothing -> pure unit
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment