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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
55b2a8c9
Commit
55b2a8c9
authored
Apr 01, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev-hal-notebook' into dev-merge
parents
cc26a5ef
4fbe4915
Pipeline
#2668
failed with stage
in 0 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
9 deletions
+59
-9
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+58
-9
Types.purs
...text/Components/Forest/Tree/Node/Action/Search/Types.purs
+1
-0
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
55b2a8c9
...
...
@@ -40,6 +40,7 @@ defaultSearch = { databases: Empty
, lang : Nothing
, term : ""
, url : ""
, year : ""
}
type Props =
...
...
@@ -77,6 +78,18 @@ searchFieldCpt = here.component "searchField" cpt
type ComponentProps =
( search :: T.Box Search )
componentYear :: R2.Component ComponentProps
componentYear = R.createElement componentYearCpt
componentYearCpt :: R.Component ComponentProps
componentYearCpt = here.component "componentYear" cpt where
cpt { search } _ = do
pure $ H.div {}
[ H.input { on: { blur: modify
, change: modify
, input: modify } } ]
where
modify e = T.modify_ (_ { year = R.unsafeEventValue e }) search
type ComponentIMTProps =
( session :: Session
| ComponentProps )
...
...
@@ -404,6 +417,10 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
, if isIMT search'.datafield
then componentIMT { search, session } []
else H.div {} []
, if isHAL search'.datafield
then componentYear { search } []
else H.div {} []
, if isCNRS search'.datafield
then componentCNRS { search } []
...
...
@@ -510,17 +527,18 @@ triggerSearch { onSearch, errors, session, selection, search } =
launchAff_ $ do
liftEffect $ do
let here' = "[triggerSearch] Searching "
log2 (here' <> "databases: ") (show search.databases)
log2 (here' <> "datafield: ") (show search.datafield)
log2 (here' <> "term: ") search.term
log2 (here' <> "lang: ") (show search.lang)
here.
log2 (here' <> "databases: ") (show search.databases)
here.
log2 (here' <> "datafield: ") (show search.datafield)
here.
log2 (here' <> "term: ") search.term
here.
log2 (here' <> "lang: ") (show search.lang)
case search.node_id of
Nothing -> liftEffect $ log "[triggerSearch] node_id is Nothing, don't know what to do"
Nothing -> liftEffect $
here.
log "[triggerSearch] node_id is Nothing, don't know what to do"
Just id -> do
liftEffect $ here.log2 "[triggerSearch] search" search
eTask <- performSearch session id $ searchQuery selection search
handleRESTError errors eTask $ \task -> liftEffect $ do
log2 "[triggerSearch] task" task
here.
log2 "[triggerSearch] task" task
onSearch task
--liftEffect $ do
...
...
@@ -531,22 +549,53 @@ searchQuery :: ListSelection.Selection -> Search -> SearchQuery
searchQuery selection { datafield: Nothing, term } =
over SearchQuery (_ { query = term
, selection = selection }) defaultSearchQuery
searchQuery selection { databases, datafield: datafield@(Just (External (Just (HAL (Just (IMT imtOrgs)))))), lang, term, node_id } =
-- TODO Simplify both HAL Nothing and HAL (Just IMT) cases
searchQuery selection { databases
, datafield: datafield@(Just (External (Just (HAL Nothing))))
, lang
, term
, node_id
, year } =
over SearchQuery (_ { databases = databases
, datafield = datafield
, lang = lang
, node_id = node_id
, query = query
, selection = selection
}) defaultSearchQuery
where
query = "(en_title_t:\"" <> termEscaped <> "\" OR en_abstract_t:\"" <> termEscaped <> "\")" <> yearQuery
-- TODO: Escape double quotes
termEscaped = term
yearQuery = if year == "" then
""
else
" AND producedDateY_i:" <> year
searchQuery selection { databases
, datafield: datafield@(Just (External (Just (HAL (Just (IMT imtOrgs))))))
, lang
, term
, node_id
, year } =
over SearchQuery (_ { databases = databases
, datafield = datafield
, lang = lang
, node_id = node_id
, query =
term'
, query =
query
, selection = selection
}) defaultSearchQuery
where
term' = "(en_title_t:\"" <> termEscaped <> "\" OR en_abstract_t:\"" <> termEscaped <> "\")" <> struct
Query
query = "(en_title_t:\"" <> termEscaped <> "\" OR en_abstract_t:\"" <> termEscaped <> "\")" <> structQuery <> year
Query
-- TODO: Escape double quotes
termEscaped = term
structQuery = if Set.isEmpty imtOrgs then
""
else
" AND (" <> structIds <> ")"
yearQuery = if year == "" then
""
else
" AND producedDateY_i:" <> year
joinFunc :: IMT_org -> String
joinFunc All_IMT = ""
joinFunc (IMT_org { school_id }) = "structId_i:" <> school_id
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Types.purs
View file @
55b2a8c9
...
...
@@ -29,6 +29,7 @@ type Search = { databases :: Database
, lang :: Maybe Lang
, node_id :: Maybe Int
, term :: String
, year :: String -- TODO Array Int
}
isIsTex_Advanced :: Maybe DataField -> Boolean
...
...
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