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
c297207e
Commit
c297207e
authored
Nov 08, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SEARCH FORM][WIP] Advanced option tree.
parent
c45116fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
70 deletions
+135
-70
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+91
-49
Types.purs
src/Gargantext/Components/Search/Types.purs
+44
-21
No files found.
src/Gargantext/Components/Search/SearchField.purs
View file @
c297207e
...
@@ -19,7 +19,8 @@ select :: forall props.
...
@@ -19,7 +19,8 @@ select :: forall props.
-> R.Element
-> R.Element
select = R.createElement "select"
select = R.createElement "select"
type Search = { database :: Maybe Database
type Search = { datafield :: Maybe DataField
, database :: Maybe Database
, term :: String
, term :: String
, lang :: Maybe Lang
, lang :: Maybe Lang
, org :: Maybe Org
, org :: Maybe Org
...
@@ -28,9 +29,10 @@ type Search = { database :: Maybe Database
...
@@ -28,9 +29,10 @@ type Search = { database :: Maybe Database
}
}
defaultSearch :: Search
defaultSearch :: Search
defaultSearch = { database: Just Gargantext
defaultSearch = { datafield: Just Gargantext
, database: Just PubMed
, term: ""
, term: ""
, lang:
Nothing
, lang:
Just EN
, org : Nothing
, org : Nothing
, filters: Nothing
, filters: Nothing
, node_id: Nothing
, node_id: Nothing
...
@@ -53,17 +55,25 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -53,17 +55,25 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
where
where
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@(curTerm /\ _) <- R.useState' search.term
db@(curDb /\ setDb) <- R.useState' (Just Gargantext :: Maybe Database)
df@(curDf /\ setDf) <- R.useState' (Just Gargantext :: Maybe DataField)
lang <- R.useState' (Nothing :: Maybe Lang)
db@(curDb /\ setDb) <- R.useState' (Nothing :: Maybe Database)
lang@(curLg /\ _) <- 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)
fi <- R.useState' ""
fi <- R.useState' ""
pure $
pure $
div { className: "search-field-group" }
div { className: "search-field-group" }
[ searchInput term
[ searchInput term
, langInput lang props.langs
, if curTerm == ""
, databaseInput db filters org props.databases
then div {}[]
else div {} [ langNav lang props.langs
, if curLg == Nothing
then div {}[]
else div {} [ dataFieldNav df dataFields
, if curDf == Just (External Nothing)
then databaseInput db filters org props.databases
else div {} []
, if isHAL curDb
, if isHAL curDb
then orgInput org allOrgs
then orgInput org allOrgs
...
@@ -99,6 +109,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -99,6 +109,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div {} []
div {} []
, 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 )
|| (p.langs /= p'.langs )
|| (p.langs /= p'.langs )
...
@@ -128,14 +140,18 @@ updateFilter org (Just (HAL_IMT {imtOrgs})) =
...
@@ -128,14 +140,18 @@ updateFilter org (Just (HAL_IMT {imtOrgs})) =
then Set.fromFoldable allIMTorgs
then Set.fromFoldable allIMTorgs
else Set.insert org imtOrgs
else Set.insert org imtOrgs
updateFilter org _ = Just $ HAL_IMT { imtOrgs: imtOrgs', structIds: Set.empty}
updateFilter org _ = Just $ HAL_IMT { imtOrgs: imtOrgs'
, structIds: Set.empty
}
where
where
imtOrgs' = if org == All_IMT
imtOrgs' = if org == All_IMT
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 =
------------------------------------------------------------------------
langList :: R.State (Maybe Lang) -> Array Lang -> R.Element
langList (lang /\ setLang) langs =
div { className: "form-group" }
div { className: "form-group" }
[ div {className: "text-primary center"} [text "with lang"]
[ div {className: "text-primary center"} [text "with lang"]
, R2.select { className: "form-control"
, R2.select { className: "form-control"
...
@@ -150,7 +166,33 @@ langInput (lang /\ setLang) langs =
...
@@ -150,7 +166,33 @@ langInput (lang /\ setLang) langs =
liItem :: Lang -> R.Element
liItem :: Lang -> R.Element
liItem lang = option {className : "text-primary center"} [ text (show lang) ]
liItem lang = option {className : "text-primary center"} [ text (show lang) ]
langNav :: R.State (Maybe Lang) -> Array Lang -> R.Element
langNav (lang /\ setLang) langs =
R.fragment [ div {className: "text-primary center"} [text "with lang"]
, div { className: "nav nav-tabs"} (liItem <$> langs)
]
where
liItem :: Lang -> R.Element
liItem lang' = div { className : "nav-item nav-link" <> if (Just lang') == lang then " active" else ""
, on: { click: \_ -> setLang $ const $ Just lang' }
} [ text (show lang') ]
------------------------------------------------------------------------
dataFieldNav :: R.State (Maybe DataField) -> Array DataField -> R.Element
dataFieldNav (df /\ setDf) datafields =
R.fragment [ div {className: "text-primary center"} [text "with DataField"]
, div { className: "nav nav-tabs"} (liItem <$> dataFields)
]
where
liItem :: DataField -> R.Element
liItem df' = div { className : "nav-item nav-link" <> if (Just df') == df then " active" else ""
, on: { click: \_ -> setDf $ const $ Just df'
}
} [ text (show df') ]
------------------------------------------------------------------------
databaseInput :: R.State (Maybe Database)
databaseInput :: R.State (Maybe Database)
-> R.State (Maybe HAL_Filters)
-> R.State (Maybe HAL_Filters)
-> R.State (Maybe Org)
-> R.State (Maybe Org)
...
@@ -238,4 +280,4 @@ submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /
...
@@ -238,4 +280,4 @@ submitButton node_id (database /\ _) (term /\ _) (lang /\ _) (org/\_) (filters /
doSearch = \_ -> do
doSearch = \_ -> do
case term of
case term of
"" -> setSearch $ const Nothing
"" -> setSearch $ const Nothing
_ -> setSearch $ const $ Just { database, lang, filters, term, org, node_id}
_ -> setSearch $ const $ Just {
datafield: Nothing,
database, lang, filters, term, org, node_id}
src/Gargantext/Components/Search/Types.purs
View file @
c297207e
...
@@ -22,6 +22,10 @@ import Gargantext.Utils (id)
...
@@ -22,6 +22,10 @@ import Gargantext.Utils (id)
import URI.Extra.QueryPairs as QP
import URI.Extra.QueryPairs as QP
import URI.Query as Q
import URI.Query as Q
------------------------------------------------------------------------
class Doc a where
doc :: a -> String
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Lang search specifications
-- | Lang search specifications
allLangs :: Array Lang
allLangs :: Array Lang
...
@@ -51,11 +55,40 @@ readLang _ = Nothing
...
@@ -51,11 +55,40 @@ readLang _ = Nothing
instance encodeJsonLang :: EncodeJson Lang where
instance encodeJsonLang :: EncodeJson Lang where
encodeJson a = encodeJson (show a)
encodeJson a = encodeJson (show a)
------------------------------------------------------------------------
-- | DataField search specifications
dataFields :: Array DataField
dataFields = [ Gargantext
, External Nothing
, Web
]
data DataField = Gargantext
| External (Maybe Database)
| Web
instance showDataField :: Show DataField where
show Gargantext = "In Gargantext"
show (External _) = "Ext.Database"
show Web = "Web"
instance docDataField :: Doc DataField where
doc Gargantext = "All Gargantext Database"
doc (External _) = "External (scientific) databases"
doc Web = "All the web crawled with meta-search-engine SearX"
instance eqDataField :: Eq DataField where
eq Gargantext Gargantext = true
eq (External _) (External _) = true
eq Web Web = true
eq _ _ = false
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Database search specifications
-- | Database search specifications
allDatabases :: Array Database
allDatabases :: Array Database
allDatabases = [ Gargantext
allDatabases = [ PubMed
, PubMed
, HAL
, HAL
, IsTex
, IsTex
, Isidore
, Isidore
...
@@ -65,50 +98,40 @@ allDatabases = [ Gargantext
...
@@ -65,50 +98,40 @@ allDatabases = [ Gargantext
]
]
data Database = All_Databases
data Database = All_Databases
| Gargantext
| PubMed
| PubMed
| HAL
| HAL
| IsTex
| IsTex
| Isidore
| Isidore
| Web
-- | News
| News
-- | SocialNetworks
| SocialNetworks
instance showDatabase :: Show Database where
instance showDatabase :: Show Database where
show All_Databases= "All Databases"
show All_Databases= "All Databases"
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"
-- show News = "News"
show News = "News"
-- show SocialNetworks = "Social Networks"
show SocialNetworks = "Social Networks"
class Doc a where
doc :: a -> String
instance docDatabase :: Doc Database where
instance docDatabase :: Doc Database where
doc All_Databases = "All databases"
doc All_Databases = "All databases"
doc Gargantext = "All Gargantext Database"
doc PubMed = "All Medical publications"
doc PubMed = "All Medical publications"
doc HAL = "All open science (archives ouvertes)"
doc HAL = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc Isidore = "All (French) Social Sciences"
doc Isidore = "All (French) Social Sciences"
doc Web = "All the web crawled with meta-search-engine SearX"
-- doc News = "Web filtered by News"
doc News = "Web filtered by News"
-- doc SocialNetworks = "Web filtered by MicroBlogs"
doc SocialNetworks = "Web filtered by MicroBlogs"
readDatabase :: String -> Maybe Database
readDatabase :: String -> Maybe Database
readDatabase "All Databases" = Just All_Databases
readDatabase "All Databases" = Just All_Databases
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 "Web" = Just Web
readDatabase "News" = Just News
--
readDatabase "News" = Just News
readDatabase "Social Networks" = Just SocialNetworks
--
readDatabase "Social Networks" = Just SocialNetworks
readDatabase _ = Nothing
readDatabase _ = Nothing
derive instance eqDatabase :: Eq Database
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