Commit 613e9cc4 authored by Yoelis Acourt's avatar Yoelis Acourt

feat: add filters explanations

parent 664bec88
...@@ -62,12 +62,13 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt ...@@ -62,12 +62,13 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt
cpt { dispatch, id, langs, session } _ = do cpt { dispatch, id, langs, session } _ = do
{ errors } <- Store.use { errors } <- Store.use
search <- T.useBox $ defaultSearch { node_id = id } search <- T.useBox $ defaultSearch { node_id = id }
pure $ R.fragment pure $ H.div { className: "m-2" }
[ H.p { className: "action-search mx-2" } [ H.p { className: "action-search child" }
[ 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."
] ]
, H.form { className: "search-bar m-2" }
, H.form { className: "search-bar child" }
[ searchFormContent [ searchFormContent
{ databases: allDatabases { databases: allDatabases
, errors , errors
...@@ -79,6 +80,7 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt ...@@ -79,6 +80,7 @@ actionSearchWithLangsCpt = here.component "actionSearchWithLangs" cpt
[] []
] ]
] ]
where where
searchOn searchOn
:: (Action -> Aff Unit) :: (Action -> Aff Unit)
......
...@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchForm where ...@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchForm where
import Gargantext.Prelude import Gargantext.Prelude
import Affjax.RequestHeader (value) import Affjax.RequestHeader (value)
import CSS.Elements (thead)
import Data.Array as A 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)
...@@ -28,6 +29,7 @@ import Gargantext.Sessions (Session(..)) ...@@ -28,6 +29,7 @@ import Gargantext.Sessions (Session(..))
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import React.DOM.Dynamic (blockquote)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
...@@ -613,17 +615,34 @@ type SearchInputProps = ...@@ -613,17 +615,34 @@ type SearchInputProps =
) )
filtersExplanation :: R.Element filtersExplanation :: R.Element
filtersExplanation = H.div { className: "container mt-5" } filtersExplanation = H.details { display: "inline-block", width: "100%", className: "flex-fill" }
[ H.div { className: "alert alert-info" } [ H.summary { style: { cursor: "pointer", backgroundColor: "0.3s" }, className: "flex-fill" }
[ H.text "To apply multiple filters in OpenAlex, separate each condition with commas. For example, to find works authored by \"John Doe\" from \"Harvard University\" published in 2023, the query would be structured as:" ] [ H.i { className: "fa fa-question-circle-o" } []
, H.pre { className: "bg-light-2" } , H.text " How to add filters ?"
[ H.code {} ]
, H.div { className: "alert alert-info" }
[ H.p {}
[ H.text
"""
To apply filters, the first thing to do is to define your search query using the OpenAlex search bar
"""
, H.a { href: "https://openalex.org/works", className: "alert-link" } [ H.text "available at this address. " ]
]
, H.p {}
[ H.text
"""
Once you are done, copy and paste here the filter parameters you'll find in the url (after the 'filter='). It should look like that:
"""
]
, H.code {}
[ H.text "authorships.author.id%3Aa5109346276,authorships.institutions.lineage%3Ai57206974" [ H.text "authorships.author.id%3Aa5109346276,authorships.institutions.lineage%3Ai57206974"
] ]
, H.p {}
[ H.a { href: "https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/filter-entity-lists", className: "alert-link" }
[ H.text "Click here to learn more about filters composition."
]
]
] ]
, H.text "This syntax allows you to combine multiple filters as an "
, H.strong {} [ H.text "AND" ]
, H.text " query, ensuring all conditions are met in the results."
] ]
filtersInput :: R2.Component SearchInputProps filtersInput :: R2.Component SearchInputProps
...@@ -634,9 +653,9 @@ filtersInputCpt = ...@@ -634,9 +653,9 @@ filtersInputCpt =
let let
cpt { search } _ = do cpt { search } _ = do
state <- T.useLive T.unequal search state <- T.useLive T.unequal search
pure $ H.div { className: "form-group px-1" } pure $ H.div { className: "form-group px-1 flex-fill" }
[ H.label { className: "form-group__label", htmlFor: "filters-openalex-input" } [ H.label { className: "form-group__label", htmlFor: "filters-openalex-input" }
[ filtersExplanation [
] ]
, H.input , H.input
{ id: "filters-openalex-input" { id: "filters-openalex-input"
...@@ -645,15 +664,14 @@ filtersInputCpt = ...@@ -645,15 +664,14 @@ filtersInputCpt =
, on: { change: (\e -> T.modify_ (_ { filters = e.target.value }) search) } , on: { change: (\e -> T.modify_ (_ { filters = e.target.value }) search) }
, placeholder: "Add filters" , placeholder: "Add filters"
, type: "text" , type: "text"
, ariaDescribedBy: "filters-help-block"
} }
, H.span { className: "form-text text-muted", id: "filters-help-block" } [ filtersExplanation ]
] ]
in in
here.component "filtersInput" cpt here.component "filtersInput" cpt
-- Je veux un composant input qui apparait quand on click sur le datasource openalex
-- quand un texte est entré je veux qu'il soit enregistré dans
searchInput :: R2.Component SearchInputProps searchInput :: R2.Component SearchInputProps
searchInput = R.createElement searchInputCpt searchInput = R.createElement searchInputCpt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment