Commit c19be9fd authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev-corpus-search-query-fix' into dev-bootstrap-v4-upgrade

parents f44dbf5e 23924ac5
...@@ -41,10 +41,10 @@ type SearchIFramesProps = ( ...@@ -41,10 +41,10 @@ type SearchIFramesProps = (
searchIframes :: Record SearchIFramesProps -> R.Element searchIframes :: Record SearchIFramesProps -> R.Element
searchIframes props = R.createElement searchIframesCpt props [] searchIframes props = R.createElement searchIframesCpt props []
searchIframesCpt :: R.Component SearchIFramesProps
searchIframesCpt = R.hooksComponentWithModule thisModule "searchIframes" cpt
where where
searchIframesCpt :: R.Component SearchIFramesProps
searchIframesCpt = R.hooksComponentWithModule thisModule "searchIframes" cpt
cpt { iframeRef, search: search@(search' /\ _) } _ = do cpt { iframeRef, search: search@(search' /\ _) } _ = do
pure $ if isIsTex_Advanced search'.datafield pure $ if isIsTex_Advanced search'.datafield
then divIframe { frameSource: Istex, iframeRef, search } then divIframe { frameSource: Istex, iframeRef, search }
...@@ -62,10 +62,10 @@ type IFrameProps = ( ...@@ -62,10 +62,10 @@ type IFrameProps = (
divIframe :: Record IFrameProps -> R.Element divIframe :: Record IFrameProps -> R.Element
divIframe props = R.createElement divIframeCpt props [] divIframe props = R.createElement divIframeCpt props []
divIframeCpt :: R.Component IFrameProps
divIframeCpt = R.hooksComponentWithModule thisModule "divIframe" cpt
where where
divIframeCpt :: R.Component IFrameProps
divIframeCpt = R.hooksComponentWithModule thisModule "divIframe" cpt
cpt { frameSource, iframeRef, search: search@(search' /\ _) } _ = do cpt { frameSource, iframeRef, search: search@(search' /\ _) } _ = do
pure $ H.div { className: "frame-search panel panel-default" } pure $ H.div { className: "frame-search panel panel-default" }
[ iframeWith { frameSource, iframeRef, search } ] [ iframeWith { frameSource, iframeRef, search } ]
...@@ -77,10 +77,10 @@ frameUrl Searx = "https://searx.frame.gargantext.org" -- 192.168.1.4:8080" ...@@ -77,10 +77,10 @@ frameUrl Searx = "https://searx.frame.gargantext.org" -- 192.168.1.4:8080"
iframeWith :: Record IFrameProps -> R.Element iframeWith :: Record IFrameProps -> R.Element
iframeWith props = R.createElement iframeWithCpt props [] iframeWith props = R.createElement iframeWithCpt props []
iframeWithCpt :: R.Component IFrameProps
iframeWithCpt = R.hooksComponentWithModule thisModule "iframeWith" cpt
where where
iframeWithCpt :: R.Component IFrameProps
iframeWithCpt = R.hooksComponentWithModule thisModule "iframeWith" cpt
cpt { frameSource, iframeRef, search: (search /\ setSearch) } _ = cpt { frameSource, iframeRef, search: (search /\ setSearch) } _ =
pure $ H.iframe { src: src frameSource search.term pure $ H.iframe { src: src frameSource search.term
, width: "100%" , width: "100%"
......
...@@ -13,10 +13,12 @@ import Effect.Class (liftEffect) ...@@ -13,10 +13,12 @@ import Effect.Class (liftEffect)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.Forest.Tree.Node.Tools (panel) 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.InputWithEnter (inputWithEnter)
import Gargantext.Components.Lang (Lang) import Gargantext.Components.Lang (Lang)
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
...@@ -62,7 +64,7 @@ searchField p = R.createElement searchFieldComponent p [] ...@@ -62,7 +64,7 @@ searchField p = R.createElement searchFieldComponent p []
H.div {} [ dataFieldNav search dataFields H.div {} [ dataFieldNav search dataFields
, if isExternal s.datafield , if isExternal s.datafield
then databaseInput search props.databases then databaseInput { databases: props.databases, search } []
else H.div {} [] else H.div {} []
, if isHAL s.datafield , if isHAL s.datafield
...@@ -236,7 +238,7 @@ dataFieldNav ({datafield} /\ setSearch) datafields = ...@@ -236,7 +238,7 @@ dataFieldNav ({datafield} /\ setSearch) datafields =
liItem :: DataField -> R.Element liItem :: DataField -> R.Element
liItem df' = liItem df' =
H.div { className : "nav-item nav-link" H.div { className : "nav-item nav-link"
<> if (Just df') == datafield <> if isActive --(Just df') == datafield
then " active" then " active"
else "" else ""
, on: { click: \_ -> setSearch $ _ { datafield = Just df' , on: { click: \_ -> setSearch $ _ { datafield = Just df'
...@@ -246,6 +248,8 @@ dataFieldNav ({datafield} /\ setSearch) datafields = ...@@ -246,6 +248,8 @@ dataFieldNav ({datafield} /\ setSearch) datafields =
-- just one database query for now -- just one database query for now
-- a list a selected database needs more ergonomy -- a list a selected database needs more ergonomy
} [ H.text (show df') ] } [ H.text (show df') ]
where
isActive = show (Just df') == show datafield
------------------------------------------------------------------------ ------------------------------------------------------------------------
{- {-
...@@ -270,24 +274,38 @@ databaseNav ({datafield} /\ setSearch) dbs = ...@@ -270,24 +274,38 @@ databaseNav ({datafield} /\ setSearch) dbs =
} [ H.text (show df') ] } [ H.text (show df') ]
-} -}
databaseInput :: R.State Search type DatabaseInputProps = (
-> Array Database databases :: Array Database
-> R.Element , search :: R.State Search
databaseInput (search /\ setSearch) dbs = )
H.div { className: "form-group" }
[ H.div {className: "text-primary center"} [H.text "in database"] databaseInput :: R2.Component DatabaseInputProps
databaseInput = R.createElement databaseInputCpt
where
databaseInputCpt :: R.Component DatabaseInputProps
databaseInputCpt = R.hooksComponentWithModule thisModule "databaseInput" cpt
cpt { databases
, search: (search /\ setSearch) } _ = do
pure $
H.div { className: "form-group" } [
H.div {className: "text-primary center"} [ H.text "in database" ]
, R2.select { className: "form-control" , R2.select { className: "form-control"
, defaultValue: defaultValue search.datafield
, on: { change: onChange } , on: { change: onChange }
} (liItem <$> dbs) } (liItem <$> databases)
, H.div {className:"center"} [ H.text $ maybe "" doc db ] , H.div {className:"center"} [ H.text $ maybe "" doc db ]
] ]
where where
defaultValue datafield = show $ maybe Empty datafield2database datafield
db = case search.datafield of db = case search.datafield of
(Just (External (Just x))) -> Just x (Just (External (Just x))) -> Just x
_ -> Nothing _ -> Nothing
liItem :: Database -> R.Element liItem :: Database -> R.Element
liItem db' = H.option {className : "text-primary center"} [ H.text (show db') ] liItem db' = H.option { className : "text-primary center"
, value: show db' } [ H.text (show db') ]
onChange e = do onChange e = do
let value = read $ R.unsafeEventValue e let value = read $ R.unsafeEventValue e
...@@ -335,23 +353,38 @@ type SearchInputProps = ...@@ -335,23 +353,38 @@ type SearchInputProps =
searchInput :: Record SearchInputProps -> R.Element searchInput :: Record SearchInputProps -> R.Element
searchInput p = R.createElement searchInputComponent p [] searchInput p = R.createElement searchInputComponent p []
searchInputComponent :: R.Component SearchInputProps
searchInputComponent = R.hooksComponentWithModule thisModule "searchInput" cpt
where where
cpt {search: (search /\ setSearch)} _ = do searchInputComponent :: R.Component SearchInputProps
pure $ searchInputComponent = R.hooksComponentWithModule thisModule "searchInput" cpt
H.div { className : "" }
[ H.input { className: "form-control" cpt {search: (search@{ term } /\ setSearch)} _ = do
, defaultValue: search.term valueRef <- R.useRef term
, on: { change : onChange setSearch }
, placeholder: "Your Query here" pure $ H.div { className: "" } [
, type: "text" inputWithEnter { onEnter: onEnter valueRef setSearch
} , onValueChanged: onValueChanged valueRef
, autoFocus: false
, className: "form-control"
, defaultValue: R.readRef valueRef
, placeholder: "Your query here"
, type: "text" }
] ]
onChange setSearch e = do
let value = R.unsafeEventValue e -- pure $
setSearch $ _ { term = value } -- H.div { className : "" }
-- [ H.input { className: "form-control"
-- , defaultValue: search.term
-- , on: { input : onInput valueRef setSearch }
-- , placeholder: "Your Query here"
-- , type: "text"
-- }
-- ]
onEnter valueRef setSearch _ = do
setSearch $ _ { term = R.readRef valueRef }
onValueChanged valueRef value = do
R.setRef valueRef value
-- setSearch $ _ { term = value }
type SubmitButtonProps = type SubmitButtonProps =
( onSearch :: GT.AsyncTaskWithType -> Effect Unit ( onSearch :: GT.AsyncTaskWithType -> Effect Unit
......
...@@ -24,13 +24,14 @@ type Props a = ( ...@@ -24,13 +24,14 @@ type Props a = (
inputWithEnter :: forall a. Record (Props a) -> R.Element inputWithEnter :: forall a. Record (Props a) -> R.Element
inputWithEnter props = R.createElement inputWithEnterCpt props [] inputWithEnter props = R.createElement inputWithEnterCpt props []
inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = R.hooksComponentWithModule thisModule "inputWithEnter" cpt
where where
inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = R.hooksComponentWithModule thisModule "inputWithEnter" cpt
cpt props@{ onEnter, onValueChanged cpt props@{ onEnter, onValueChanged
, autoFocus, className, defaultValue, placeholder } _ = do , autoFocus, className, defaultValue, placeholder } _ = do
pure $ H.input { on: { input: onInput pure $ H.input { on: { blur: \_ -> onEnter unit
, input: onInput
, keyPress: onKeyPress } , keyPress: onKeyPress }
, autoFocus , autoFocus
, className , className
......
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