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
( 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.String (length)
import Data.Set as Set
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
...
...
@@ -65,14 +66,18 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
pure $
div { className: "search-field-group" }
[ searchInput term
, if curTerm == ""
then div {}[]
else div {} [ langNav lang props.langs
, if length curTerm < 3
then
div {}[]
else
div {} [ langNav lang props.langs
, if curLg == Nothing
then div {}[]
else div {} [ dataFieldNav df dataFields
then
div {}[]
else
div {} [ dataFieldNav df dataFields
, if curDf == Just (External Nothing)
then databaseInput
db filters org props.databases
then databaseInput df
db filters org props.databases
else div {} []
, if isHAL curDb
...
...
@@ -87,9 +92,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
[ ul {} $ map ( \org' -> li {}
[ input { type: "checkbox"
, checked: isInFilters org' curFilters
, on: {change: \_ ->
setFilters
, on: {change: \_ -> (
setFilters
$ const
$ updateFilter org' curFilters
$ updateFilter org' curFilters)
}
}
, if org' == All_IMT
...
...
@@ -107,9 +112,9 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
div {} []
else
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)
|| (p.databases /= p'.databases )
...
...
@@ -183,6 +188,7 @@ 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)
, div {className:"center"} [ text $ maybe "" doc df ]
]
where
liItem :: DataField -> R.Element
...
...
@@ -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 Org)
-> Array Database
-> R.Element
databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
databaseInput (d
f /\ setDf) (d
b /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
div { className: "form-group" }
[ div {className: "text-primary center"} [text "in database"]
, R2.select { className: "form-control"
...
...
@@ -208,6 +215,7 @@ databaseInput (db /\ setDB) (_ /\ setFilters) (_ /\ setOrg) dbs =
$ e .. "target" .. "value")
*> (setOrg $ const Nothing)
*> (setFilters $ const Nothing)
*> (setDf $ const $ Just $ External db)
}
} (liItem <$> dbs)
, 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
dataFields :: Array DataField
dataFields = [ Gargantext
, External Nothing
, Web
, External Nothing
, Files
]
data DataField = Gargantext
| External (Maybe Database)
| Web
| Files
instance showDataField :: Show DataField where
show Gargantext = "In Gargantext"
show (External _) = "Ext.Database"
show Web = "Web"
show Files = "Files"
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"
doc Files = "Zip files with formats.."
instance eqDataField :: Eq DataField where
eq Gargantext Gargantext = true
eq (External _) (External _) = true
eq Web Web = true
eq Files Files = true
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