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
4fbe4915
Commit
4fbe4915
authored
Apr 01, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HAL] add simple year implementation to HAL search
parent
07b5ffa8
Changes
2
Show 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 @
4fbe4915
...
@@ -40,6 +40,7 @@ defaultSearch = { databases: Empty
...
@@ -40,6 +40,7 @@ defaultSearch = { databases: Empty
, lang : Nothing
, lang : Nothing
, term : ""
, term : ""
, url : ""
, url : ""
, year : ""
}
}
type Props =
type Props =
...
@@ -77,6 +78,18 @@ searchFieldCpt = here.component "searchField" cpt
...
@@ -77,6 +78,18 @@ searchFieldCpt = here.component "searchField" cpt
type ComponentProps =
type ComponentProps =
( search :: T.Box Search )
( 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 =
type ComponentIMTProps =
( session :: Session
( session :: Session
| ComponentProps )
| ComponentProps )
...
@@ -405,6 +418,10 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
...
@@ -405,6 +418,10 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
then componentIMT { search, session } []
then componentIMT { search, session } []
else H.div {} []
else H.div {} []
, if isHAL search'.datafield
then componentYear { search } []
else H.div {} []
, if isCNRS search'.datafield
, if isCNRS search'.datafield
then componentCNRS { search } []
then componentCNRS { search } []
else H.div {} []
else H.div {} []
...
@@ -510,17 +527,18 @@ triggerSearch { onSearch, errors, session, selection, search } =
...
@@ -510,17 +527,18 @@ triggerSearch { onSearch, errors, session, selection, search } =
launchAff_ $ do
launchAff_ $ do
liftEffect $ do
liftEffect $ do
let here' = "[triggerSearch] Searching "
let here' = "[triggerSearch] Searching "
log2 (here' <> "databases: ") (show search.databases)
here.
log2 (here' <> "databases: ") (show search.databases)
log2 (here' <> "datafield: ") (show search.datafield)
here.
log2 (here' <> "datafield: ") (show search.datafield)
log2 (here' <> "term: ") search.term
here.
log2 (here' <> "term: ") search.term
log2 (here' <> "lang: ") (show search.lang)
here.
log2 (here' <> "lang: ") (show search.lang)
case search.node_id of
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
Just id -> do
liftEffect $ here.log2 "[triggerSearch] search" search
eTask <- performSearch session id $ searchQuery selection search
eTask <- performSearch session id $ searchQuery selection search
handleRESTError errors eTask $ \task -> liftEffect $ do
handleRESTError errors eTask $ \task -> liftEffect $ do
log2 "[triggerSearch] task" task
here.
log2 "[triggerSearch] task" task
onSearch task
onSearch task
--liftEffect $ do
--liftEffect $ do
...
@@ -531,22 +549,53 @@ searchQuery :: ListSelection.Selection -> Search -> SearchQuery
...
@@ -531,22 +549,53 @@ searchQuery :: ListSelection.Selection -> Search -> SearchQuery
searchQuery selection { datafield: Nothing, term } =
searchQuery selection { datafield: Nothing, term } =
over SearchQuery (_ { query = term
over SearchQuery (_ { query = term
, selection = selection }) defaultSearchQuery
, 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
over SearchQuery (_ { databases = databases
, datafield = datafield
, datafield = datafield
, lang = lang
, lang = lang
, node_id = node_id
, node_id = node_id
, query =
term'
, query =
query
, selection = selection
, selection = selection
}) defaultSearchQuery
}) defaultSearchQuery
where
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
-- TODO: Escape double quotes
termEscaped = term
termEscaped = term
structQuery = if Set.isEmpty imtOrgs then
structQuery = if Set.isEmpty imtOrgs then
""
""
else
else
" AND (" <> structIds <> ")"
" AND (" <> structIds <> ")"
yearQuery = if year == "" then
""
else
" AND producedDateY_i:" <> year
joinFunc :: IMT_org -> String
joinFunc :: IMT_org -> String
joinFunc All_IMT = ""
joinFunc All_IMT = ""
joinFunc (IMT_org { school_id }) = "structId_i:" <> school_id
joinFunc (IMT_org { school_id }) = "structId_i:" <> school_id
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Types.purs
View file @
4fbe4915
...
@@ -29,6 +29,7 @@ type Search = { databases :: Database
...
@@ -29,6 +29,7 @@ type Search = { databases :: Database
, lang :: Maybe Lang
, lang :: Maybe Lang
, node_id :: Maybe Int
, node_id :: Maybe Int
, term :: String
, term :: String
, year :: String -- TODO Array Int
}
}
isIsTex_Advanced :: Maybe DataField -> Boolean
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