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
8627e463
Commit
8627e463
authored
Apr 06, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HAL] implement multiple year chooser
parent
1f8edfc9
Pipeline
#2663
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
21 deletions
+45
-21
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+44
-20
Types.purs
...text/Components/Forest/Tree/Node/Action/Search/Types.purs
+1
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
8627e463
...
@@ -2,11 +2,13 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField where
...
@@ -2,11 +2,13 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField where
import Gargantext.Prelude
import Gargantext.Prelude
import Data.Array as A
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (over)
import Data.Newtype (over)
import Data.Nullable (null)
import Data.Nullable (null)
import Data.Set as Set
import Data.Set as Set
import Data.String.Common (joinWith)
import Data.String.Common (joinWith)
import Data.Tuple (Tuple(..))
import DOM.Simple.Console (log, log2)
import DOM.Simple.Console (log, log2)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
...
@@ -40,7 +42,7 @@ defaultSearch = { databases: Empty
...
@@ -40,7 +42,7 @@ defaultSearch = { databases: Empty
, lang : Nothing
, lang : Nothing
, term : ""
, term : ""
, url : ""
, url : ""
, year
: ""
, year
s : []
}
}
type Props =
type Props =
...
@@ -78,17 +80,41 @@ searchFieldCpt = here.component "searchField" cpt
...
@@ -78,17 +80,41 @@ searchFieldCpt = here.component "searchField" cpt
type ComponentProps =
type ComponentProps =
( search :: T.Box Search )
( search :: T.Box Search )
componentYear :: R2.Component ComponentProps
componentYear
s
:: R2.Component ComponentProps
componentYear
= R.createElement componentYear
Cpt
componentYear
s = R.createElement componentYears
Cpt
componentYearCpt :: R.Component ComponentProps
componentYear
s
Cpt :: R.Component ComponentProps
componentYear
Cpt = here.component "componentYear
" cpt where
componentYear
sCpt = here.component "componentYears
" cpt where
cpt { search } _ = do
cpt { search } _ = do
{ years } <- T.useLive T.unequal search
let yearsZ = A.zip (A.range 0 (A.length years)) years
newYear <- T.useBox ""
pure $ H.div {}
pure $ H.div {}
[ H.input { on: { blur: modify
((yearCpt search <$> yearsZ) <>
, change: modify
[ H.div {}
, input: modify } } ]
[ H.input { on: { blur: modify newYear
, change: modify newYear
, input: modify newYear } }
, H.span { className: "btn btn-primary fa fa-check"
, on: { click: clickAdd newYear search }} []
]
])
where
where
modify e = T.modify_ (_ { year = R.unsafeEventValue e }) search
clickAdd newYear search _ = do
newYear' <- T.read newYear
T.modify_ (\s@{ years } -> s { years = A.snoc years newYear' }) search
clickRemove idx search _ =
T.modify_ (\s@{ years } -> s { years = left idx years <> right (A.length years - idx) years }) search
where
left 0 years = []
left idx years = A.take idx years
right 0 years = []
right len years = A.takeEnd (len - 1) years
modify newYear e = T.write_ (R.unsafeEventValue e) newYear
yearCpt search (Tuple idx year) =
H.div {}
[ H.span {} [ H.text year ]
, H.span { className: "btn btn-danger fa fa-times"
, on: { click: clickRemove idx search } } [] ]
type ComponentIMTProps =
type ComponentIMTProps =
( session :: Session
( session :: Session
...
@@ -419,7 +445,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
...
@@ -419,7 +445,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
else H.div {} []
else H.div {} []
, if isHAL search'.datafield
, if isHAL search'.datafield
then componentYear { search } []
then componentYear
s
{ search } []
else H.div {} []
else H.div {} []
, if isCNRS search'.datafield
, if isCNRS search'.datafield
...
@@ -555,12 +581,12 @@ searchQuery selection { databases
...
@@ -555,12 +581,12 @@ searchQuery selection { databases
, lang
, lang
, term
, term
, node_id
, node_id
, year } =
, year
s
} =
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 = queryHAL term Nothing lang year
, query = queryHAL term Nothing lang year
s
, selection = selection
, selection = selection
}) defaultSearchQuery
}) defaultSearchQuery
searchQuery selection { databases
searchQuery selection { databases
...
@@ -568,12 +594,12 @@ searchQuery selection { databases
...
@@ -568,12 +594,12 @@ searchQuery selection { databases
, lang
, lang
, term
, term
, node_id
, node_id
, year } =
, year
s
} =
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 = queryHAL term (Just imtOrgs) lang year
, query = queryHAL term (Just imtOrgs) lang year
s
, selection = selection
, selection = selection
}) defaultSearchQuery
}) defaultSearchQuery
searchQuery selection { databases, datafield, lang, term, node_id } =
searchQuery selection { databases, datafield, lang, term, node_id } =
...
@@ -585,8 +611,8 @@ searchQuery selection { databases, datafield, lang, term, node_id } =
...
@@ -585,8 +611,8 @@ searchQuery selection { databases, datafield, lang, term, node_id } =
, selection = selection
, selection = selection
}) defaultSearchQuery
}) defaultSearchQuery
queryHAL :: String -> Maybe (Set.Set IMT_org) -> Maybe Lang -> String -> String
queryHAL :: String -> Maybe (Set.Set IMT_org) -> Maybe Lang ->
Array
String -> String
queryHAL term mIMTOrgs lang year =
queryHAL term mIMTOrgs lang year
s
=
"(" <> langPrefix <> "_title_t:\"" <> termEscaped <>
"(" <> langPrefix <> "_title_t:\"" <> termEscaped <>
"\" OR " <> langPrefix <> "_abstract_t:\"" <> termEscaped <> "\")" <>
"\" OR " <> langPrefix <> "_abstract_t:\"" <> termEscaped <> "\")" <>
structQuery <> yearQuery
structQuery <> yearQuery
...
@@ -602,10 +628,8 @@ queryHAL term mIMTOrgs lang year =
...
@@ -602,10 +628,8 @@ queryHAL term mIMTOrgs lang year =
""
""
else
else
" AND (" <> (structIds imtOrgs) <> ")"
" AND (" <> (structIds imtOrgs) <> ")"
yearQuery = if year == "" then
yearQuery' = joinWith " AND " $ (\year -> "producedDateY_i:" <> year) <$> years
""
yearQuery = if yearQuery' == "" then "" else " AND " <> yearQuery'
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 @
8627e463
...
@@ -29,7 +29,7 @@ type Search = { databases :: Database
...
@@ -29,7 +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
, year
s :: Array String
}
}
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