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
137
Issues
137
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
gargantext
purescript-gargantext
Commits
a2747b50
Commit
a2747b50
authored
Nov 22, 2024
by
Yoelis Acourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: refactor search form for legibility
parent
4868dbf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
179 deletions
+43
-179
Search.purs
...Gargantext/Components/Forest/Tree/Node/Action/Search.purs
+14
-11
SearchBar.purs
.../Components/Forest/Tree/Node/Action/Search/SearchBar.purs
+0
-49
SearchForm.purs
...Components/Forest/Tree/Node/Action/Search/SearchForm.purs
+29
-119
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search.purs
View file @
a2747b50
...
@@ -5,8 +5,8 @@ import Effect (Effect)
...
@@ -5,8 +5,8 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff)
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as Store
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Forest.Tree.Node.Action.Search.Search
Bar (searchBar
)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Search
Form (defaultSearch, searchFormContent
)
import Gargantext.Components.Forest.Tree.Node.Action.Search.
SearchField (defaultSearch
)
import Gargantext.Components.Forest.Tree.Node.Action.Search.
Types (allDatabases
)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Utils (loadLanguages)
import Gargantext.Components.Forest.Tree.Node.Action.Utils (loadLanguages)
import Gargantext.Components.Lang (Lang)
import Gargantext.Components.Lang (Lang)
...
@@ -67,19 +67,22 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt
...
@@ -67,19 +67,22 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt
[ H.text $ "Search and create a private "
[ H.text $ "Search and create a private "
<> "corpus with the search query as corpus name."
<> "corpus with the search query as corpus name."
]
]
, searchBar
, H.form { className: "search-bar m-2" }
{ errors
[ searchFormContent
, langs
{ databases: allDatabases
, onSearch: searchOn dispatch
, errors
, search
, langs
, session
, onSearch: searchOn dispatch
}
, search
[]
, session
}
[]
]
]
]
where
where
searchOn
searchOn
:: (Action -> Aff Unit)
:: (Action -> Aff Unit)
-> G
AT.Task
-> G
T.AsyncTaskWithType
-> Effect Unit
-> Effect Unit
searchOn dispatch' task = do
searchOn dispatch' task = do
_ <- launchAff $ dispatch' (DoSearch task)
_ <- launchAff $ dispatch' (DoSearch task)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchBar.purs
deleted
100644 → 0
View file @
4868dbf0
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar
( Props
, searchBar
) where
import Effect (Effect)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (Search, allDatabases)
import Gargantext.Components.Lang (Lang)
import Gargantext.Prelude (Unit, pure, ($))
import Gargantext.Sessions (Session)
import Gargantext.Types (FrontendError)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"
type Props =
( errors :: T.Box (Array FrontendError)
, langs :: Array Lang
, onSearch :: GAT.Task -> Effect Unit
, search :: T.Box Search
, session :: Session
)
searchBar :: R2.Component Props
searchBar = R.createElement searchBarCpt
searchBarCpt :: R.Component Props
searchBarCpt = here.component "searchBar" cpt
where
cpt { errors, langs, onSearch, search, session } _ = do
--onSearchChange session s
pure $ H.form { className: "search-bar m-2" }
[ searchField
{ databases: allDatabases
, errors
, langs
, onSearch
, search
, session
}
[]
]
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchF
ield
.purs
→
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchF
orm
.purs
View file @
a2747b50
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchF
ield
where
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchF
orm
where
import Gargantext.Prelude
import Gargantext.Prelude
...
@@ -12,7 +12,6 @@ import Data.Tuple (Tuple(..))
...
@@ -12,7 +12,6 @@ import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (searchIframes)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (searchIframes)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allOrgs, dataFields, defaultSearchQuery, doc, performSearch, datafield2database, Search, dbFromInputValue, dbToInputValue)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allOrgs, dataFields, defaultSearchQuery, doc, performSearch, datafield2database, Search, dbFromInputValue, dbToInputValue)
import Gargantext.Components.GraphQL.Endpoints (getIMTSchools, getUser)
import Gargantext.Components.GraphQL.Endpoints (getIMTSchools, getUser)
...
@@ -54,16 +53,16 @@ type Props =
...
@@ -54,16 +53,16 @@ type Props =
, errors :: T.Box (Array FrontendError)
, errors :: T.Box (Array FrontendError)
, langs :: Array Lang
, langs :: Array Lang
-- State hook for a search, how we get data in and out
-- State hook for a search, how we get data in and out
, onSearch :: G
AT.Task
-> Effect Unit
, onSearch :: G
T.AsyncTaskWithType
-> Effect Unit
, search :: T.Box Search
, search :: T.Box Search
, session :: Session
, session :: Session
)
)
searchF
ield
:: R2.Component Props
searchF
ormContent
:: R2.Component Props
searchF
ield = R.createElement searchField
Cpt
searchF
ormContent = R.createElement searchFormContent
Cpt
searchF
ield
Cpt :: R.Component Props
searchF
ormContent
Cpt :: R.Component Props
searchF
ieldCpt = here.component "searchField
" cpt
searchF
ormContentCpt = here.component "searchFormContent
" cpt
where
where
cpt { databases, errors, langs, onSearch, search, session } _ = do
cpt { databases, errors, langs, onSearch, search, session } _ = do
selection <- T.useBox ListSelection.MyListsFirst
selection <- T.useBox ListSelection.MyListsFirst
...
@@ -71,10 +70,6 @@ searchFieldCpt = here.component "searchField" cpt
...
@@ -71,10 +70,6 @@ searchFieldCpt = here.component "searchField" cpt
pure $
pure $
H.div { className: "search-field" }
H.div { className: "search-field" }
[ searchInput { search } []
[ searchInput { search } []
-- , if length s.term < 3 -- search with love : <3
-- then
-- H.div {}[]
-- else
, datafieldInput { databases, langs, search, session } []
, datafieldInput { databases, langs, search, session } []
, ListSelection.selection { selection, session } []
, ListSelection.selection { selection, session } []
, submitButton { errors, onSearch, search, selection, session } []
, submitButton { errors, onSearch, search, selection, session } []
...
@@ -202,76 +197,6 @@ componentCNRSCpt = here.component "componentCNRS" cpt
...
@@ -202,76 +197,6 @@ componentCNRSCpt = here.component "componentCNRS" cpt
--, filterInput fi
--, filterInput fi
]
]
isExternal :: Maybe DataField -> Boolean
isExternal (Just (External _)) = true
isExternal _ = false
isArxiv :: Maybe DataField -> Boolean
isArxiv
( Just
(External Arxiv)
) = true
isArxiv _ = false
isHAL :: Maybe DataField -> Boolean
isHAL
( Just
(External (HAL _))
) = true
isHAL _ = false
isIsTex :: Maybe DataField -> Boolean
isIsTex
( Just
(External (IsTex))
) = true
isIsTex _ = false
isIMT :: Maybe DataField -> Boolean
isIMT
( Just
( External
( HAL
(Just (IMT _))
)
)
) = true
isIMT _ = false
isCNRS :: Maybe DataField -> Boolean
isCNRS
( Just
( External
( HAL
(Just (CNRS _))
)
)
) = true
isCNRS _ = false
isPubmed :: Maybe DataField -> Boolean
isPubmed
( Just
(External PubMed)
) = true
isPubmed _ = false
isEPO :: Maybe DataField -> Boolean
isEPO
( Just
(External EPO)
) = true
isEPO _ = false
needsLang :: Maybe DataField -> Boolean
needsLang (Just Gargantext) = true
needsLang (Just Web) = true
needsLang
( Just
(External (HAL _))
) = true
needsLang _ = false
isIn :: IMT_org -> Maybe DataField -> Boolean
isIn :: IMT_org -> Maybe DataField -> Boolean
isIn
isIn
org
org
...
@@ -386,11 +311,11 @@ type DatabaseInputProps =
...
@@ -386,11 +311,11 @@ type DatabaseInputProps =
, search :: T.Box Search
, search :: T.Box Search
)
)
data
baseInput
:: R2.Component DatabaseInputProps
data
SourceSelection
:: R2.Component DatabaseInputProps
data
baseInput = R.createElement databaseInput
Cpt
data
SourceSelection = R.createElement dataSourceSelection
Cpt
data
baseInput
Cpt :: R.Component DatabaseInputProps
data
SourceSelection
Cpt :: R.Component DatabaseInputProps
data
baseInputCpt = here.component "databaseInput
" cpt
data
SourceSelectionCpt = here.component "dataSourceSelection
" cpt
where
where
cpt
cpt
{ databases
{ databases
...
@@ -649,6 +574,9 @@ type DatafieldInputProps =
...
@@ -649,6 +574,9 @@ type DatafieldInputProps =
, session :: Session
, session :: Session
)
)
empty :: R.Element
empty = H.div {} [ H.text "" ]
datafieldInput :: R2.Component DatafieldInputProps
datafieldInput :: R2.Component DatafieldInputProps
datafieldInput = R.createElement datafieldInputCpt
datafieldInput = R.createElement datafieldInputCpt
...
@@ -659,39 +587,21 @@ datafieldInputCpt = here.component "datafieldInput" cpt
...
@@ -659,39 +587,21 @@ datafieldInputCpt = here.component "datafieldInput" cpt
search' <- T.useLive T.unequal search
search' <- T.useLive T.unequal search
iframeRef <- R.useRef null
iframeRef <- R.useRef null
let
optionalFields = case search'.datafield of
Just (External PubMed) -> pubmedInput { search, session } []
Just (External EPO) -> epoInput { search, session } []
Just (External (HAL (Just (IMT _)))) -> componentIMT { search, session } [ langNav { langs, search } [] ]
Just (External (HAL (Just (CNRS _)))) -> componentCNRS { search } [ langNav { langs, search } [] ]
Just (External (HAL _)) -> orgInput { orgs: allOrgs, search } [ langNav { langs, search } [] ]
Just (External OpenAlex) -> H.div {} [ H.text "Optional filters" ]
Just Web -> langNav { langs, search } []
_ -> empty -- Default for unsupported or missing fields
pure $ H.div {}
pure $ H.div {}
[ dataFieldNav { search } []
[ dataFieldNav { search } []
, dataSourceSelection { databases, search } []
, if isExternal search'.datafield then databaseInput { databases, search } []
, optionalFields
else H.div {} []
, if isPubmed search'.datafield then pubmedInput { search, session } []
else H.div {} []
, if isEPO search'.datafield then epoInput { search, session } []
else H.div {} []
, if isHAL search'.datafield then orgInput { orgs: allOrgs, search } []
else H.div {} []
, if isIMT search'.datafield then componentIMT { search, session } []
else H.div {} []
-- , if isHAL search'.datafield
-- then componentYears { search } []
-- else H.div {} []
, if isCNRS search'.datafield then componentCNRS { search } []
else H.div {} []
, if needsLang search'.datafield then
if search'.datafield == Just Web then
langNav { langs: A.filter (\lang -> lang == FR) langs, search } []
else
langNav { langs, search } []
else
H.div {} []
, H.div {} [ searchIframes { iframeRef, search } [] ]
, H.div {} [ searchIframes { iframeRef, search } [] ]
]
]
...
@@ -745,7 +655,7 @@ searchInputCpt = here.component "searchInput" cpt
...
@@ -745,7 +655,7 @@ searchInputCpt = here.component "searchInput" cpt
type SubmitButtonProps =
type SubmitButtonProps =
( errors :: T.Box (Array FrontendError)
( errors :: T.Box (Array FrontendError)
, onSearch :: G
AT.Task
-> Effect Unit
, onSearch :: G
T.AsyncTaskWithType
-> Effect Unit
, search :: T.Box Search
, search :: T.Box Search
, selection :: T.Box ListSelection.Selection
, selection :: T.Box ListSelection.Selection
, session :: Session
, session :: Session
...
@@ -780,14 +690,14 @@ submitButtonComponent = here.component "submitButton" cpt
...
@@ -780,14 +690,14 @@ submitButtonComponent = here.component "submitButton" cpt
type TriggerSearch =
type TriggerSearch =
( errors :: T.Box (Array FrontendError)
( errors :: T.Box (Array FrontendError)
, onSearch :: G
AT.Task
-> Effect Unit
, onSearch :: G
T.AsyncTaskWithType
-> Effect Unit
, search :: T.Box Search
, search :: T.Box Search
, selection :: T.Box ListSelection.Selection
, selection :: T.Box ListSelection.Selection
, session :: Session
, session :: Session
)
)
triggerSearch
triggerSearch
:: { onSearch :: (G
AT.Task
-> Effect Unit)
:: { onSearch :: (G
T.AsyncTaskWithType
-> Effect Unit)
, errors :: T.Box (Array FrontendError)
, errors :: T.Box (Array FrontendError)
, session :: Session
, session :: Session
, selection :: ListSelection.Selection
, selection :: ListSelection.Selection
...
...
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