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
2a06da0c
Commit
2a06da0c
authored
Nov 08, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FOREST][Search Form] cosmetics.
parent
52db2f1e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
49 deletions
+63
-49
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+1
-0
SearchBar.purs
src/Gargantext/Components/Search/SearchBar.purs
+1
-1
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+38
-40
Types.purs
src/Gargantext/Components/Search/Types.purs
+23
-8
No files found.
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
2a06da0c
...
...
@@ -137,6 +137,7 @@ fldr nt open = if open
color _ = " text-danger"
-}
-- START node text
type NodeTextProps =
( isSelected :: Boolean
...
...
src/Gargantext/Components/Search/SearchBar.purs
View file @
2a06da0c
...
...
@@ -35,7 +35,7 @@ searchBarCpt = R.hooksComponent "G.C.Node.SearchBar.searchBar" cpt
cpt {session, databases, langs, node_id} _ = do
search <- R.useState' Nothing
onSearchChange session search
pure $ H.div {
className: ""
} [ searchField {databases, langs, search, node_id}]
pure $ H.div {} [ searchField {databases, langs, search, node_id}]
onSearchChange :: Session -> R.State (Maybe Search) -> R.Hooks Unit
...
...
src/Gargantext/Components/Search/SearchField.purs
View file @
2a06da0c
...
...
@@ -28,7 +28,7 @@ type Search = { database :: Maybe Database
}
defaultSearch :: Search
defaultSearch = { database: Just
In
Gargantext
defaultSearch = { database: Just Gargantext
, term: ""
, lang: Nothing
, org : Nothing
...
...
@@ -54,7 +54,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
cpt props@{node_id} _ = do
let search = maybe defaultSearch identity (fst props.search)
term <- R.useState' search.term
db@(curDb /\ setDb) <- R.useState' (Just
In
Gargantext :: Maybe Database)
db@(curDb /\ setDb) <- R.useState' (Just Gargantext :: Maybe Database)
lang <- R.useState' (Nothing :: Maybe Lang)
org@(curOrg /\ setOrg) <- R.useState' (Nothing :: Maybe Org)
filters@(curFilters /\ setFilters) <- R.useState' (Nothing :: Maybe HAL_Filters)
...
...
@@ -63,10 +63,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div { className: "search-field-group" }
[ searchInput term
, langInput lang props.langs
, div {className: "text-primary center"} [text "in"]
, databaseInput db filters org props.databases
, if isHAL curDb
then orgInput org allOrgs
else div {} []
...
...
@@ -99,8 +97,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div {} []
else
div {} []
, div { className: "" }
[ submitButton node_id db term lang org filters props.search ]
, submitButton node_id db term lang org filters props.search
]
hasChanged p p' = (fst p.search /= fst p'.search)
|| (p.databases /= p'.databases )
...
...
@@ -137,6 +134,22 @@ updateFilter org _ = Just $ HAL_IMT { imtOrgs: imtOrgs', structIds: Set.empty}
then Set.fromFoldable allIMTorgs
else Set.fromFoldable [org]
langInput :: R.State (Maybe Lang) -> Array Lang -> R.Element
langInput (lang /\ setLang) langs =
div { className: "form-group" }
[ div {className: "text-primary center"} [text "with lang"]
, R2.select { className: "form-control"
, on: { change: \e -> setLang
$ const
$ readLang
$ e .. "target" .. "value"
}
} (liItem <$> langs)
]
where
liItem :: Lang -> R.Element
liItem lang = option {className : "text-primary center"} [ text (show lang) ]
databaseInput :: R.State (Maybe Database)
-> R.State (Maybe HAL_Filters)
...
...
@@ -144,8 +157,9 @@ databaseInput :: R.State (Maybe Database)
-> Array Database
-> R.Element
databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
div { className: "form-group" }
[ R2.select { className: "form-control"
div { className: "form-group" }
[ div {className: "text-primary center"} [text "in database"]
, R2.select { className: "form-control"
, on: { change: \e -> (setDB
$ const
$ readDatabase
...
...
@@ -154,32 +168,17 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
*> (setFilters $ const Nothing)
}
} (liItem <$> dbs)
, div {className:"center"} [ text $ maybe "" doc db ]
]
where
liItem :: Database -> R.Element
liItem db = option {className : "text-primary center"} [ text (show db) ]
langInput :: R.State (Maybe Lang) -> Array Lang -> R.Element
langInput (lang /\ setLang) langs =
div { className: "form-group" }
[ div {className: "text-primary center"} [text "with lang"]
, R2.select { className: "form-control"
, on: { change: \e -> setLang
$ const
$ readLang
$ e .. "target" .. "value"
}
} (liItem <$> langs)
]
where
liItem :: Lang -> R.Element
liItem lang = option {className : "text-primary center"} [ text (show lang) ]
orgInput :: R.State (Maybe Org) -> Array Org -> R.Element
orgInput (org /\ setOrg) orgs =
div { className: "form-group" }
[
text "filter with organization: "
[
div {className: "text-primary center"} [text "filter with organization: "]
, R2.select { className: "form-control"
, on: { change: \e -> setOrg
$ const
...
...
@@ -194,7 +193,7 @@ orgInput (org /\ setOrg) orgs =
filterInput :: R.State String -> R.Element
filterInput (term /\ setTerm) =
div {className: ""} [ input { defaultValue: term
div {className: "
form-group
"} [ input { defaultValue: term
, className: "form-control"
, type: "text"
, on: { change: \e -> setTerm
...
...
@@ -212,13 +211,13 @@ filterInput (term /\ setTerm) =
searchInput :: R.State String -> R.Element
searchInput (term /\ setTerm) =
div { className : "" }
[ input { defaultValue: term
, className: "form-control"
, type: "text"
, on: { change : \e -> setTerm $ const $ e .. "target" .. "value" }
, placeholder: "Your Query here" }
]
div { className : "" }
[ input { defaultValue: term
, className: "form-control"
, type: "text"
, on: { change : \e -> setTerm $ const $ e .. "target" .. "value" }
, placeholder: "Your Query here" }
]
submitButton :: Maybe Int
...
...
@@ -229,13 +228,12 @@ submitButton :: Maybe Int
-> R.State (Maybe HAL_Filters)
-> R.State (Maybe Search)
-> R.Element
submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /\ _) (_ /\ setSearch) =
R.fragment [ div { className : "" } []
, button { className: "btn btn-primary"
, type: "button"
, on: {click: doSearch}
} [ text "Search" ]
]
submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /\ _) (_ /\ setSearch) = div { className : "panel-footer" }
[ button { className: "btn btn-primary"
, type: "button"
, on: {click: doSearch}
} [ text "Launch Search" ]
]
where
doSearch = \_ -> do
case term of
...
...
src/Gargantext/Components/Search/Types.purs
View file @
2a06da0c
...
...
@@ -54,36 +54,51 @@ instance encodeJsonLang :: EncodeJson Lang where
------------------------------------------------------------------------
-- | Database search specifications
allDatabases :: Array Database
allDatabases = [
In
Gargantext
allDatabases = [ Gargantext
, PubMed
, HAL
, IsTex
, Isidore
-- , Web
]
data Database = All
|
In
Gargantext
data Database = All
_Databases
| Gargantext
| PubMed
| HAL
| IsTex
| Isidore
| Web
instance showDatabase :: Show Database where
show All
= "All
"
show
In
Gargantext = "In Gargantext"
show All
_Databases= "All Databases
"
show Gargantext = "In Gargantext"
show PubMed = "PubMed"
show HAL = "HAL"
show IsTex = "IsTex"
show Isidore= "Isidore"
show Web = "Web"
class Doc a where
doc :: a -> String
instance docDatabase :: Doc Database where
doc All_Databases = "All databases"
doc Gargantext = "All Gargantext Database"
doc PubMed = "All Medical publications"
doc HAL = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc Isidore = "All (French) Social Sciences"
doc Web = "All the web"
readDatabase :: String -> Maybe Database
readDatabase "All
" = Just All
readDatabase "
In Gargantext" = Just In
Gargantext
readDatabase "All
Databases" = Just All_Databases
readDatabase "
Gargantext" = Just
Gargantext
readDatabase "PubMed" = Just PubMed
readDatabase "HAL" = Just HAL
readDatabase "IsTex" = Just IsTex
readDatabase "Isidore"= Just Isidore
readDatabase "Web" = Just Web
readDatabase _ = Nothing
derive instance eqDatabase :: Eq Database
...
...
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