Commit ef4c4674 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[SEARCH FORM] Adding Lang in request.

parent 8602174e
...@@ -49,6 +49,7 @@ onSearchChange session (search /\ setSearch) = ...@@ -49,6 +49,7 @@ onSearchChange session (search /\ setSearch) =
log2 "Searching db: " $ show q.database log2 "Searching db: " $ show q.database
log2 "Searching term: " q.term log2 "Searching term: " q.term
log2 "Searching filters: " q.filters log2 "Searching filters: " q.filters
log2 "Searching lang: " q.lang
r <- (performSearch session $ searchQuery q) :: Aff Unit r <- (performSearch session $ searchQuery q) :: Aff Unit
...@@ -60,7 +61,13 @@ onSearchChange session (search /\ setSearch) = ...@@ -60,7 +61,13 @@ onSearchChange session (search /\ setSearch) =
over SearchQuery (_ {query=term}) defaultSearchQuery over SearchQuery (_ {query=term}) defaultSearchQuery
searchQuery {database: Just db, lang, term, filters, node_id} = searchQuery {database: Just db, lang, term, filters, node_id} =
over SearchQuery (_ {databases=[db], lang=lang, query=term, filters=filters', node_id=node_id}) defaultSearchQuery over SearchQuery (_ { databases=[db]
, lang=lang
, query=term
, filters=filters'
, node_id=node_id
}
) defaultSearchQuery
where where
filters' = toInt filters filters' = toInt filters
toInt (Just (HAL_StructId {structIds})) = Set.toUnfoldable structIds toInt (Just (HAL_StructId {structIds})) = Set.toUnfoldable structIds
......
...@@ -62,12 +62,10 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -62,12 +62,10 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
pure $ pure $
div { className: "search-field-group" } div { className: "search-field-group" }
[ searchInput term [ searchInput term
, langInput lang props.langs
, div {className: "text-primary center"} [text "in"] , div {className: "text-primary center"} [text "in"]
, databaseInput db filters org props.databases , databaseInput db filters org props.databases
, if curDb /= Just PubMed
then langInput lang props.langs
else div {} []
, if isHAL curDb , if isHAL curDb
then orgInput org allOrgs then orgInput org allOrgs
...@@ -165,7 +163,7 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs = ...@@ -165,7 +163,7 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
langInput :: R.State (Maybe Lang) -> Array Lang -> R.Element langInput :: R.State (Maybe Lang) -> Array Lang -> R.Element
langInput (lang /\ setLang) langs = langInput (lang /\ setLang) langs =
div { className: "form-group" } div { className: "form-group" }
[ text "with lang" [ div {className: "text-primary center"} [text "with lang"]
, R2.select { className: "form-control" , R2.select { className: "form-control"
, on: { change: \e -> setLang , on: { change: \e -> setLang
$ const $ const
......
...@@ -310,12 +310,13 @@ instance searchQueryToQuery :: ToQuery SearchQuery where ...@@ -310,12 +310,13 @@ instance searchQueryToQuery :: ToQuery SearchQuery where
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ] [ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance encodeJsonSearchQuery :: EncodeJson SearchQuery where instance encodeJsonSearchQuery :: EncodeJson SearchQuery where
encodeJson (SearchQuery {query, databases, node_id, files_id, filters}) encodeJson (SearchQuery {query, databases, node_id, files_id, filters, lang})
= "query" := query = "query" := query
~> "databases" := databases ~> "databases" := databases
~> "node_id" := fromMaybe 0 node_id ~> "node_id" := fromMaybe 0 node_id
~> "files_id" := files_id ~> "files_id" := files_id
~> "filters" := filters ~> "filters" := filters
~> "lang" := maybe "EN" show lang
~> jsonEmptyObject ~> jsonEmptyObject
......
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