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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
320cf2e7
Commit
320cf2e7
authored
Jul 04, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SEARCH] fix sending dbs list when clicking on search button
parent
ed807a2e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+8
-9
SearchBar.purs
src/Gargantext/Pages/Layout/Specs/SearchBar.purs
+3
-2
No files found.
src/Gargantext/Components/Search/SearchField.purs
View file @
320cf2e7
...
...
@@ -46,8 +46,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
where
cpt props _ = do
let search = maybe defaultSearch identity (fst props.search)
term <- R.useState
$ \_ ->
search.term
db <- R.useState
$ \_ -> Nothing
term <- R.useState
'
search.term
db <- R.useState
' (Nothing :: Maybe Database)
pure $
div { className: "search-field input-group" }
[ databaseInput db props.databases
...
...
@@ -64,10 +64,9 @@ databaseInput (db /\ setDB) dbs =
, ul {className: "dropdown-menu", role: "menu"} (liItem <$> dbs)
]
where
liItem db = li { onClick }
[ a {href: "#"} [text (show db) ] ]
liItem db = li { onClick } [ a {href: "#"} [text (show db) ] ]
where
onClick = mkEffectFn1 $ \_ -> setDB (const $ Just db)
onClick = mkEffectFn1 $ \_ -> setDB $ const $ Just db
dropdownBtnProps = { id: "search-dropdown"
, className: "btn btn-default dropdown-toggle"
, type: "button"
...
...
@@ -83,7 +82,7 @@ searchInput (term /\ setTerm) =
, type: "text"
, onChange
, placeholder }
where onChange = mkEffectFn1 $ \e -> setTerm
(const $ e .. "target" .. "value")
where onChange = mkEffectFn1 $ \e -> setTerm
$ const $ e .. "target" .. "value"
submitButton :: R.State (Maybe Database) -> R.State String -> R.State (Maybe Search) -> R.Element
...
...
@@ -92,5 +91,5 @@ submitButton (database /\ _) (term /\ _) (_ /\ setSearch) =
where
click = mkEffectFn1 $ \_ -> do
case term of
"" -> setSearch
(const Nothing)
_ -> setSearch
(const $ Just { database, term })
"" -> setSearch
$ const Nothing
_ -> setSearch
$ const $ Just { database, term }
src/Gargantext/Pages/Layout/Specs/SearchBar.purs
View file @
320cf2e7
...
...
@@ -11,7 +11,6 @@ import Data.Tuple (fst)
import Data.Tuple.Nested ( (/\) )
import Effect.Class (liftEffect)
import Effect.Uncurried (EffectFn1, mkEffectFn1)
import Thermite (Spec, defaultPerformAction, simpleSpec)
import Reactix as R
import DOM.Simple.Console
import Effect.Aff (launchAff)
...
...
@@ -53,11 +52,13 @@ onSearchChange (search /\ setSearch) =
where
triggerSearch q = do
launchAff $ do
liftEffect $ log2 "Searching db: " $ show q.database
liftEffect $ log2 "Searching term: " q.term
(r :: Unit) <- Ajax.search (searchQuery q)
liftEffect $ log2 "Return:" r
liftEffect $ modalShow "addCorpus"
searchQuery {term} = over SearchQuery (_ {query=term}) defaultSearchQuery
searchQuery {database: Nothing, term} = over SearchQuery (_ {query=term}) defaultSearchQuery
searchQuery {database: Just db, term} = over SearchQuery (_ {databases=[db], query=term}) defaultSearchQuery
toggleButton :: R.State Boolean -> R.Element
toggleButton open =
...
...
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