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

Merge remote-tracking branch 'origin/425-dev-terms-page-reset' into dev-merge

parents fb6f33c4 796e8e18
...@@ -43,6 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre ...@@ -43,6 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (changePage) import Gargantext.Components.Table (changePage)
import Gargantext.Components.Table as TT import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types (Params)
import Gargantext.Components.Table.Types as TT import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError)
import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned) import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned)
...@@ -407,13 +408,13 @@ type Props = ...@@ -407,13 +408,13 @@ type Props =
| PropsNoReload ) | PropsNoReload )
type LoadedNgramsTableHeaderProps = type LoadedNgramsTableHeaderProps =
( searchQuery :: T.Box SearchQuery ) ( searchQuery :: T.Box SearchQuery, params :: T.Box Params )
loadedNgramsTableHeader :: R2.Leaf LoadedNgramsTableHeaderProps loadedNgramsTableHeader :: R2.Leaf LoadedNgramsTableHeaderProps
loadedNgramsTableHeader = R2.leaf loadedNgramsTableHeaderCpt loadedNgramsTableHeader = R2.leaf loadedNgramsTableHeaderCpt
loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
cpt { searchQuery } _ = pure $ cpt { searchQuery, params } _ = pure $
R.fragment R.fragment
[ [
...@@ -435,6 +436,7 @@ loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where ...@@ -435,6 +436,7 @@ loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
NTS.searchInput NTS.searchInput
{ key: "search-input" { key: "search-input"
, searchQuery , searchQuery
, params
} }
] ]
...@@ -541,6 +543,7 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -541,6 +543,7 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
performAction performAction
$ CoreAction $ CoreAction
$ Synchronize { afterSync: afterSync' } $ Synchronize { afterSync: afterSync' }
changePage 1 params
-- autoUpdate :: Array R.Element -- autoUpdate :: Array R.Element
...@@ -753,6 +756,7 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt ...@@ -753,6 +756,7 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
where where
cpt props@{ cacheState, path, treeEdit } _ = do cpt props@{ cacheState, path, treeEdit } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
-- onCancelRef <- R.useRef Nothing -- onCancelRef <- R.useRef Nothing
-- onNgramsClickRef <- R.useRef Nothing -- onNgramsClickRef <- R.useRef Nothing
...@@ -774,12 +778,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt ...@@ -774,12 +778,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
case cacheState' of case cacheState' of
NT.CacheOn -> pure $ R.fragment NT.CacheOn -> pure $ R.fragment
[ loadedNgramsTableHeader { searchQuery } [ loadedNgramsTableHeader { searchQuery, params }
, ngramsTreeEdit (treeEdit) , ngramsTreeEdit (treeEdit)
, mainNgramsTableCacheOn (Record.merge props { state }) , mainNgramsTableCacheOn (Record.merge props { state })
] ]
NT.CacheOff -> pure $ R.fragment NT.CacheOff -> pure $ R.fragment
[loadedNgramsTableHeader { searchQuery } [loadedNgramsTableHeader { searchQuery, params}
, ngramsTreeEdit (treeEdit) , ngramsTreeEdit (treeEdit)
, mainNgramsTableCacheOff (Record.merge props { state }) , mainNgramsTableCacheOff (Record.merge props { state })
] ]
......
...@@ -7,6 +7,8 @@ import Data.Foldable (intercalate) ...@@ -7,6 +7,8 @@ import Data.Foldable (intercalate)
import Data.Nullable (Nullable, null) import Data.Nullable (Nullable, null)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.Table (changePage)
import Gargantext.Components.Table.Types (Params)
import Gargantext.Utils.Reactix as R2 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
...@@ -18,6 +20,7 @@ here = R2.here "Gargantext.Components.NgramsTable.Search" ...@@ -18,6 +20,7 @@ here = R2.here "Gargantext.Components.NgramsTable.Search"
type SearchInputProps = type SearchInputProps =
( searchQuery :: T.Box String ( searchQuery :: T.Box String
, params :: T.Box Params
) )
-- "key": to prevent refreshing & losing input -- "key": to prevent refreshing & losing input
...@@ -26,14 +29,14 @@ searchInput = R2.leafComponent searchInputCpt ...@@ -26,14 +29,14 @@ searchInput = R2.leafComponent searchInputCpt
searchInputCpt :: R.Component ( key :: String | SearchInputProps ) searchInputCpt :: R.Component ( key :: String | SearchInputProps )
searchInputCpt = here.component "searchInput" cpt searchInputCpt = here.component "searchInput" cpt
where where
cpt { searchQuery } _ = do cpt { searchQuery, params } _ = do
inputRef <- R.useRef null inputRef <- R.useRef null
pure $ R2.row pure $ R2.row
[ H.div { className: "col-12" } [ H.div { className: "col-12" }
[ H.div { className: "input-group" } [ H.div { className: "input-group" }
[ searchFieldInput { inputRef, searchQuery } [] [ searchFieldInput { inputRef, searchQuery } []
, searchButton { inputRef, searchQuery } [] , searchButton { inputRef, searchQuery, params } []
] ]
] ]
] ]
...@@ -41,6 +44,7 @@ searchInputCpt = here.component "searchInput" cpt ...@@ -41,6 +44,7 @@ searchInputCpt = here.component "searchInput" cpt
type SearchButtonProps = type SearchButtonProps =
( inputRef :: R.Ref (Nullable DOM.Element) ( inputRef :: R.Ref (Nullable DOM.Element)
, searchQuery :: T.Box String , searchQuery :: T.Box String
, params :: T.Box Params
) )
searchButton :: R2.Component SearchButtonProps searchButton :: R2.Component SearchButtonProps
...@@ -48,7 +52,7 @@ searchButton = R.createElement searchButtonCpt ...@@ -48,7 +52,7 @@ searchButton = R.createElement searchButtonCpt
searchButtonCpt :: R.Component SearchButtonProps searchButtonCpt :: R.Component SearchButtonProps
searchButtonCpt = here.component "searchButton" cpt where searchButtonCpt = here.component "searchButton" cpt where
cpt { inputRef, searchQuery } _ = do cpt { inputRef, searchQuery, params } _ = do
-- | States -- | States
-- | -- |
searchQuery' <- T.useLive T.unequal searchQuery searchQuery' <- T.useLive T.unequal searchQuery
...@@ -59,9 +63,11 @@ searchButtonCpt = here.component "searchButton" cpt where ...@@ -59,9 +63,11 @@ searchButtonCpt = here.component "searchButton" cpt where
onReset _ = do onReset _ = do
R2.setInputValue inputRef "" R2.setInputValue inputRef ""
T.write_ "" searchQuery T.write_ "" searchQuery
changePage 1 params
onSubmit _ = do onSubmit _ = do
T.write_ (R2.getInputValue inputRef) searchQuery T.write_ (R2.getInputValue inputRef) searchQuery
changePage 1 params
-- | Render -- | Render
-- | -- |
......
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