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
360cb569
Commit
360cb569
authored
Nov 08, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SEARCH FORM][WIP] Before Fun with Types.
parent
c297207e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
47 deletions
+60
-47
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+54
-46
Types.purs
src/Gargantext/Components/Search/Types.purs
+6
-1
No files found.
src/Gargantext/Components/Search/SearchField.purs
View file @
360cb569
module Gargantext.Components.Search.SearchField
module Gargantext.Components.Search.SearchField
( Search, Props, searchField, searchFieldComponent )where
( Search, Props, searchField, searchFieldComponent )where
import Prelude (bind, const, identity, pure, show, ($), (/=), (<$>), (||), (==), map, (<>), (&&), (*>), (>>=), (>=>))
import Prelude (bind, const, identity, pure, show, ($), (/=), (<$>), (||), (==), map, (<>), (&&), (*>), (>>=), (>=>)
, (<)
)
import Data.Maybe (Maybe(..), maybe, isJust)
import Data.Maybe (Maybe(..), maybe, isJust)
import Data.String (length)
import Data.Set as Set
import Data.Set as Set
import Data.Tuple (fst)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
...
@@ -65,14 +66,18 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -65,14 +66,18 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
pure $
pure $
div { className: "search-field-group" }
div { className: "search-field-group" }
[ searchInput term
[ searchInput term
, if curTerm == ""
, if length curTerm < 3
then div {}[]
then
else div {} [ langNav lang props.langs
div {}[]
else
div {} [ langNav lang props.langs
, if curLg == Nothing
, if curLg == Nothing
then div {}[]
then
else div {} [ dataFieldNav df dataFields
div {}[]
else
div {} [ dataFieldNav df dataFields
, if curDf == Just (External Nothing)
, if curDf == Just (External Nothing)
then databaseInput
db filters org props.databases
then databaseInput df
db filters org props.databases
else div {} []
else div {} []
, if isHAL curDb
, if isHAL curDb
...
@@ -87,9 +92,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -87,9 +92,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
[ ul {} $ map ( \org' -> li {}
[ ul {} $ map ( \org' -> li {}
[ input { type: "checkbox"
[ input { type: "checkbox"
, checked: isInFilters org' curFilters
, checked: isInFilters org' curFilters
, on: {change: \_ ->
setFilters
, on: {change: \_ -> (
setFilters
$ const
$ const
$ updateFilter org' curFilters
$ updateFilter org' curFilters)
}
}
}
}
, if org' == All_IMT
, if org' == All_IMT
...
@@ -107,9 +112,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -107,9 +112,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div {} []
div {} []
else
else
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 )
...
@@ -183,6 +188,7 @@ dataFieldNav :: R.State (Maybe DataField) -> Array DataField -> R.Element
...
@@ -183,6 +188,7 @@ dataFieldNav :: R.State (Maybe DataField) -> Array DataField -> R.Element
dataFieldNav (df /\ setDf) datafields =
dataFieldNav (df /\ setDf) datafields =
R.fragment [ div {className: "text-primary center"} [text "with DataField"]
R.fragment [ div {className: "text-primary center"} [text "with DataField"]
, div { className: "nav nav-tabs"} (liItem <$> dataFields)
, div { className: "nav nav-tabs"} (liItem <$> dataFields)
, div {className:"center"} [ text $ maybe "" doc df ]
]
]
where
where
liItem :: DataField -> R.Element
liItem :: DataField -> R.Element
...
@@ -193,12 +199,13 @@ dataFieldNav (df /\ setDf) datafields =
...
@@ -193,12 +199,13 @@ dataFieldNav (df /\ setDf) datafields =
------------------------------------------------------------------------
------------------------------------------------------------------------
databaseInput :: R.State (Maybe Database)
databaseInput :: R.State (Maybe DataField)
-> R.State (Maybe Database)
-> R.State (Maybe HAL_Filters)
-> R.State (Maybe HAL_Filters)
-> R.State (Maybe Org)
-> R.State (Maybe Org)
-> Array Database
-> Array Database
-> R.Element
-> R.Element
databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
databaseInput (d
f /\ setDf) (d
b /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
div { className: "form-group" }
div { className: "form-group" }
[ div {className: "text-primary center"} [text "in database"]
[ div {className: "text-primary center"} [text "in database"]
, R2.select { className: "form-control"
, R2.select { className: "form-control"
...
@@ -208,6 +215,7 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
...
@@ -208,6 +215,7 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
$ e .. "target" .. "value")
$ e .. "target" .. "value")
*> (setOrg $ const Nothing)
*> (setOrg $ const Nothing)
*> (setFilters $ const Nothing)
*> (setFilters $ const Nothing)
*> (setDf $ const $ Just $ External db)
}
}
} (liItem <$> dbs)
} (liItem <$> dbs)
, div {className:"center"} [ text $ maybe "" doc db ]
, div {className:"center"} [ text $ maybe "" doc db ]
...
...
src/Gargantext/Components/Search/Types.purs
View file @
360cb569
...
@@ -60,28 +60,33 @@ instance encodeJsonLang :: EncodeJson Lang where
...
@@ -60,28 +60,33 @@ instance encodeJsonLang :: EncodeJson Lang where
dataFields :: Array DataField
dataFields :: Array DataField
dataFields = [ Gargantext
dataFields = [ Gargantext
, External Nothing
, Web
, Web
, External Nothing
, Files
]
]
data DataField = Gargantext
data DataField = Gargantext
| External (Maybe Database)
| External (Maybe Database)
| Web
| Web
| Files
instance showDataField :: Show DataField where
instance showDataField :: Show DataField where
show Gargantext = "In Gargantext"
show Gargantext = "In Gargantext"
show (External _) = "Ext.Database"
show (External _) = "Ext.Database"
show Web = "Web"
show Web = "Web"
show Files = "Files"
instance docDataField :: Doc DataField where
instance docDataField :: Doc DataField where
doc Gargantext = "All Gargantext Database"
doc Gargantext = "All Gargantext Database"
doc (External _) = "External (scientific) databases"
doc (External _) = "External (scientific) databases"
doc Web = "All the web crawled with meta-search-engine SearX"
doc Web = "All the web crawled with meta-search-engine SearX"
doc Files = "Zip files with formats.."
instance eqDataField :: Eq DataField where
instance eqDataField :: Eq DataField where
eq Gargantext Gargantext = true
eq Gargantext Gargantext = true
eq (External _) (External _) = true
eq (External _) (External _) = true
eq Web Web = true
eq Web Web = true
eq Files Files = true
eq _ _ = false
eq _ _ = false
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
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