Commit 2a06da0c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FOREST][Search Form] cosmetics.

parent 52db2f1e
...@@ -137,6 +137,7 @@ fldr nt open = if open ...@@ -137,6 +137,7 @@ fldr nt open = if open
color _ = " text-danger" color _ = " text-danger"
-} -}
-- START node text -- START node text
type NodeTextProps = type NodeTextProps =
( isSelected :: Boolean ( isSelected :: Boolean
......
...@@ -35,7 +35,7 @@ searchBarCpt = R.hooksComponent "G.C.Node.SearchBar.searchBar" cpt ...@@ -35,7 +35,7 @@ searchBarCpt = R.hooksComponent "G.C.Node.SearchBar.searchBar" cpt
cpt {session, databases, langs, node_id} _ = do cpt {session, databases, langs, node_id} _ = do
search <- R.useState' Nothing search <- R.useState' Nothing
onSearchChange session search 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 onSearchChange :: Session -> R.State (Maybe Search) -> R.Hooks Unit
......
...@@ -28,7 +28,7 @@ type Search = { database :: Maybe Database ...@@ -28,7 +28,7 @@ type Search = { database :: Maybe Database
} }
defaultSearch :: Search defaultSearch :: Search
defaultSearch = { database: Just InGargantext defaultSearch = { database: Just Gargantext
, term: "" , term: ""
, lang: Nothing , lang: Nothing
, org : Nothing , org : Nothing
...@@ -54,7 +54,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -54,7 +54,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
cpt props@{node_id} _ = do cpt props@{node_id} _ = do
let search = maybe defaultSearch identity (fst props.search) let search = maybe defaultSearch identity (fst props.search)
term <- R.useState' search.term term <- R.useState' search.term
db@(curDb /\ setDb) <- R.useState' (Just InGargantext :: Maybe Database) db@(curDb /\ setDb) <- R.useState' (Just Gargantext :: Maybe Database)
lang <- R.useState' (Nothing :: Maybe Lang) lang <- R.useState' (Nothing :: Maybe Lang)
org@(curOrg /\ setOrg) <- R.useState' (Nothing :: Maybe Org) org@(curOrg /\ setOrg) <- R.useState' (Nothing :: Maybe Org)
filters@(curFilters /\ setFilters) <- R.useState' (Nothing :: Maybe HAL_Filters) filters@(curFilters /\ setFilters) <- R.useState' (Nothing :: Maybe HAL_Filters)
...@@ -63,10 +63,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -63,10 +63,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div { className: "search-field-group" } div { className: "search-field-group" }
[ searchInput term [ searchInput term
, langInput lang props.langs , langInput lang props.langs
, div {className: "text-primary center"} [text "in"]
, databaseInput db filters org props.databases , databaseInput db filters org props.databases
, if isHAL curDb , if isHAL curDb
then orgInput org allOrgs then orgInput org allOrgs
else div {} [] else div {} []
...@@ -99,8 +97,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -99,8 +97,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div {} [] div {} []
else else
div {} [] 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) hasChanged p p' = (fst p.search /= fst p'.search)
|| (p.databases /= p'.databases ) || (p.databases /= p'.databases )
...@@ -137,6 +134,22 @@ updateFilter org _ = Just $ HAL_IMT { imtOrgs: imtOrgs', structIds: Set.empty} ...@@ -137,6 +134,22 @@ updateFilter org _ = Just $ HAL_IMT { imtOrgs: imtOrgs', structIds: Set.empty}
then Set.fromFoldable allIMTorgs then Set.fromFoldable allIMTorgs
else Set.fromFoldable [org] 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) databaseInput :: R.State (Maybe Database)
-> R.State (Maybe HAL_Filters) -> R.State (Maybe HAL_Filters)
...@@ -145,7 +158,8 @@ databaseInput :: R.State (Maybe Database) ...@@ -145,7 +158,8 @@ databaseInput :: R.State (Maybe Database)
-> R.Element -> R.Element
databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs = databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
div { className: "form-group" } div { className: "form-group" }
[ R2.select { className: "form-control" [ div {className: "text-primary center"} [text "in database"]
, R2.select { className: "form-control"
, on: { change: \e -> (setDB , on: { change: \e -> (setDB
$ const $ const
$ readDatabase $ readDatabase
...@@ -154,32 +168,17 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs = ...@@ -154,32 +168,17 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
*> (setFilters $ const Nothing) *> (setFilters $ const Nothing)
} }
} (liItem <$> dbs) } (liItem <$> dbs)
, div {className:"center"} [ text $ maybe "" doc db ]
] ]
where where
liItem :: Database -> R.Element liItem :: Database -> R.Element
liItem db = option {className : "text-primary center"} [ text (show db) ] 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 :: R.State (Maybe Org) -> Array Org -> R.Element
orgInput (org /\ setOrg) orgs = orgInput (org /\ setOrg) orgs =
div { className: "form-group" } div { className: "form-group" }
[ text "filter with organization: " [ div {className: "text-primary center"} [text "filter with organization: "]
, R2.select { className: "form-control" , R2.select { className: "form-control"
, on: { change: \e -> setOrg , on: { change: \e -> setOrg
$ const $ const
...@@ -194,7 +193,7 @@ orgInput (org /\ setOrg) orgs = ...@@ -194,7 +193,7 @@ orgInput (org /\ setOrg) orgs =
filterInput :: R.State String -> R.Element filterInput :: R.State String -> R.Element
filterInput (term /\ setTerm) = filterInput (term /\ setTerm) =
div {className: ""} [ input { defaultValue: term div {className: "form-group"} [ input { defaultValue: term
, className: "form-control" , className: "form-control"
, type: "text" , type: "text"
, on: { change: \e -> setTerm , on: { change: \e -> setTerm
...@@ -229,12 +228,11 @@ submitButton :: Maybe Int ...@@ -229,12 +228,11 @@ submitButton :: Maybe Int
-> R.State (Maybe HAL_Filters) -> R.State (Maybe HAL_Filters)
-> R.State (Maybe Search) -> R.State (Maybe Search)
-> R.Element -> R.Element
submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /\ _) (_ /\ setSearch) = submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /\ _) (_ /\ setSearch) = div { className : "panel-footer" }
R.fragment [ div { className : "" } [] [ button { className: "btn btn-primary"
, button { className: "btn btn-primary"
, type: "button" , type: "button"
, on: {click: doSearch} , on: {click: doSearch}
} [ text "Search" ] } [ text "Launch Search" ]
] ]
where where
doSearch = \_ -> do doSearch = \_ -> do
......
...@@ -54,36 +54,51 @@ instance encodeJsonLang :: EncodeJson Lang where ...@@ -54,36 +54,51 @@ instance encodeJsonLang :: EncodeJson Lang where
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Database search specifications -- | Database search specifications
allDatabases :: Array Database allDatabases :: Array Database
allDatabases = [ InGargantext allDatabases = [ Gargantext
, PubMed , PubMed
, HAL , HAL
, IsTex , IsTex
, Isidore , Isidore
-- , Web
] ]
data Database = All data Database = All_Databases
| InGargantext | Gargantext
| PubMed | PubMed
| HAL | HAL
| IsTex | IsTex
| Isidore | Isidore
| Web
instance showDatabase :: Show Database where instance showDatabase :: Show Database where
show All = "All" show All_Databases= "All Databases"
show InGargantext = "In Gargantext" show Gargantext = "In Gargantext"
show PubMed = "PubMed" show PubMed = "PubMed"
show HAL = "HAL" show HAL = "HAL"
show IsTex = "IsTex" show IsTex = "IsTex"
show Isidore= "Isidore" 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 :: String -> Maybe Database
readDatabase "All" = Just All readDatabase "All Databases" = Just All_Databases
readDatabase "In Gargantext" = Just InGargantext readDatabase "Gargantext" = Just Gargantext
readDatabase "PubMed" = Just PubMed readDatabase "PubMed" = Just PubMed
readDatabase "HAL" = Just HAL readDatabase "HAL" = Just HAL
readDatabase "IsTex" = Just IsTex readDatabase "IsTex" = Just IsTex
readDatabase "Isidore"= Just Isidore readDatabase "Isidore"= Just Isidore
readDatabase "Web" = Just Web
readDatabase _ = Nothing readDatabase _ = Nothing
derive instance eqDatabase :: Eq Database derive instance eqDatabase :: Eq Database
......
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