Commit 64621176 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] Box search (TODO CSS fix of frame)

parent fe9e6a7a
...@@ -7,14 +7,14 @@ import Data.Nullable (null) ...@@ -7,14 +7,14 @@ import Data.Nullable (null)
import Data.Newtype (over) import Data.Newtype (over)
import Data.Set as Set import Data.Set as Set
import Data.String (length) import Data.String (length)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Tools (panel)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allIMTorgs, allOrgs, dataFields, defaultSearchQuery, doc, performSearch, datafield2database, Search) import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allIMTorgs, allOrgs, dataFields, defaultSearchQuery, doc, performSearch, datafield2database, Search)
import Gargantext.Components.Lang (Lang) import Gargantext.Components.Lang (Lang)
import Gargantext.Prelude (Unit, bind, discard, map, pure, show, ($), (&&), (<), (<$>), (<>), (==), read) import Gargantext.Prelude (Unit, bind, discard, map, pure, show, ($), (<), (<$>), (<>), (==), read)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (searchIframes) import Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (searchIframes)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -22,20 +22,6 @@ import Gargantext.Utils.Reactix as R2 ...@@ -22,20 +22,6 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
select :: forall props.
R.IsComponent String props (Array R.Element)
=> Record props
-> Array R.Element
-> R.Element
select = R.createElement "select"
eqSearch :: Search -> Search -> Boolean
eqSearch s s' = (s.databases == s'.databases)
&& (s.datafield == s'.datafield)
&& (s.lang == s'.lang)
&& (s.node_id == s'.node_id)
&& (s.term == s'.term)
defaultSearch :: Search defaultSearch :: Search
defaultSearch = { databases: Empty defaultSearch = { databases: Empty
, datafield: Nothing , datafield: Nothing
...@@ -65,12 +51,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt ...@@ -65,12 +51,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
where where
cpt props@{onSearch, search: search@(s /\ _)} _ = do cpt props@{onSearch, search: search@(s /\ _)} _ = do
iframeRef <- R.useRef null iframeRef <- R.useRef null
pure $ let body =
H.div { className: "search-field-group", style: { width: "100%" } }
[
H.div { className: "row" }
[
H.div { className: "col-md-12" }
[ searchInput {search} [ searchInput {search}
, if length s.term < 3 -- search with love : <3 , if length s.term < 3 -- search with love : <3
then then
...@@ -96,47 +77,42 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt ...@@ -96,47 +77,42 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
, H.div {} [ searchIframes search iframeRef ] , H.div {} [ searchIframes search iframeRef ]
, if needsLang s.datafield
then langNav search props.langs
else H.div {} []
] ]
] ]
] let footer = H.div {className: "flex-center"}
, H.div { className : "panel-footer" } [submitButton {onSearch, search, session: props.session}]
[ if needsLang s.datafield
then langNav search props.langs pure $ panel body footer
else H.div {} []
, H.div {} []
, H.div {className: "flex-center"} componentIMT (search /\ setSearch) =
[submitButton {onSearch, search, session: props.session}] R.fragment
] [ H.ul {} $ map liCpt allIMTorgs
] --, filterInput fi
eqProps :: Record Props -> Record Props -> Boolean ]
eqProps p p' = (p.databases == p'.databases ) where
&& (p.langs == p'.langs ) liCpt org =
&& (eqSearch (fst p.search) (fst p'.search)) H.li {}
-- && (fst p.filters == fst p'.filters ) [ H.input { type: "checkbox"
componentIMT (search /\ setSearch) = , checked: isIn org search.datafield
R.fragment , on: { change: \_ -> ( setSearch $ _ { datafield = updateFilter org search.datafield })
[ H.ul {} $ map liCpt allIMTorgs }
--, filterInput fi }
] , if org == All_IMT
where then H.i {} [H.text $ " " <> show org]
liCpt org = else H.text $ " " <> show org
H.li {}
[ H.input { type: "checkbox"
, checked: isIn org search.datafield
, on: { change: \_ -> ( setSearch $ _ { datafield = updateFilter org search.datafield })
}
}
, if org == All_IMT
then H.i {} [H.text $ " " <> show org]
else H.text $ " " <> show org
]
componentCNRS (search /\ setSearch) =
R.fragment [
H.div {} []
--, filterInput fi
] ]
componentCNRS (search /\ setSearch) =
R.fragment [
H.div {} []
--, filterInput fi
]
isExternal :: Maybe DataField -> Boolean isExternal :: Maybe DataField -> Boolean
isExternal (Just (External _)) = true isExternal (Just (External _)) = true
......
module Gargantext.Components.Forest.Tree.Node.Action.Upload.Types where module Gargantext.Components.Forest.Tree.Node.Action.Upload.Types where
import Gargantext.Prelude (class Read, class Show, class Eq)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq) import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe, maybe) import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Read, class Show, class Eq)
data FileType = CSV | CSV_HAL | WOS | PresseRIS data FileType = CSV | CSV_HAL | WOS | PresseRIS
......
module Gargantext.Config.REST where module Gargantext.Config.REST where
import Affjax (defaultRequest, printResponseFormatError, request) import Affjax (defaultRequest, printResponseFormatError, request)
import Affjax.RequestBody (RequestBody(..), formData, formURLEncoded, string) import Affjax.RequestBody (RequestBody(..), formData, formURLEncoded)
import Affjax.RequestHeader as ARH import Affjax.RequestHeader as ARH
import Affjax.ResponseFormat as ResponseFormat import Affjax.ResponseFormat as ResponseFormat
import DOM.Simple.Console (log) import DOM.Simple.Console (log)
import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson) import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson)
import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (foldMap) import Data.Foldable (foldMap)
import Data.FormURLEncoded as FormURLEncoded import Data.FormURLEncoded as FormURLEncoded
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData) import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple)
import Effect.Aff (Aff, throwError) import Effect.Aff (Aff, throwError)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Exception (error) import Effect.Exception (error)
import Web.XHR.FormData as XHRFormData
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Web.XHR.FormData as XHRFormData
type Token = String type Token = String
......
module Gargantext.Prelude (module Prelude, logs, id, class Read, read) module Gargantext.Prelude (module Prelude, logs, id, class Read, read)
where where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe)
import Prelude (class Applicative, class Apply, class Bind, class BooleanAlgebra, class Bounded, class Category, class CommutativeRing, class Discard, class DivisionRing, class Eq, class EuclideanRing, class Field, class Functor, class HeytingAlgebra, class Monad, class Monoid, class Ord, class Ring, class Semigroup, class Semigroupoid, class Semiring, class Show, type (~>), Ordering(..), Unit, Void, absurd, add, ap, append, apply, between, bind, bottom, clamp, compare, comparing, compose, conj, const, degree, discard, disj, eq, flap, flip, gcd, identity, ifM, join, lcm, liftA1, liftM1, map, max, mempty, min, mod, mul, negate, not, notEq, one, otherwise, pure, recip, show, sub, top, unit, unless, unlessM, void, when, whenM, zero, (#), ($), ($>), (&&), (*), (*>), (+), (-), (/), (/=), (<), (<#>), (<$), (<$>), (<*), (<*>), (<<<), (<=), (<=<), (<>), (<@>), (=<<), (==), (>), (>=), (>=>), (>>=), (>>>), (||)) import Prelude (class Applicative, class Apply, class Bind, class BooleanAlgebra, class Bounded, class Category, class CommutativeRing, class Discard, class DivisionRing, class Eq, class EuclideanRing, class Field, class Functor, class HeytingAlgebra, class Monad, class Monoid, class Ord, class Ring, class Semigroup, class Semigroupoid, class Semiring, class Show, type (~>), Ordering(..), Unit, Void, absurd, add, ap, append, apply, between, bind, bottom, clamp, compare, comparing, compose, conj, const, degree, discard, disj, eq, flap, flip, gcd, identity, ifM, join, lcm, liftA1, liftM1, map, max, mempty, min, mod, mul, negate, not, notEq, one, otherwise, pure, recip, show, sub, top, unit, unless, unlessM, void, when, whenM, zero, (#), ($), ($>), (&&), (*), (*>), (+), (-), (/), (/=), (<), (<#>), (<$), (<$>), (<*), (<*>), (<<<), (<=), (<=<), (<>), (<@>), (=<<), (==), (>), (>=), (>=>), (>>=), (>>>), (||))
import Effect.Console (log) import Effect.Console (log)
import Effect.Class (class MonadEffect, liftEffect) import Effect.Class (class MonadEffect, liftEffect)
......
module Gargantext.Utils.Popover where module Gargantext.Utils.Popover where
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (maybe)
import Data.Nullable (Nullable, toMaybe) import Data.Nullable (Nullable, toMaybe)
import DOM.Simple as DOM import DOM.Simple as DOM
import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2) import Effect.Uncurried (EffectFn2, runEffectFn2)
import FFI.Simple ((..), (...))
import Reactix as R import Reactix as R
import Gargantext.Prelude import Gargantext.Prelude
......
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