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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
796e8e18
Commit
796e8e18
authored
Sep 27, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Ngrams table] reset to first page when searching
parent
4eb82bba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+8
-4
Search.purs
src/Gargantext/Components/NgramsTable/Search.purs
+9
-3
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
796e8e18
...
...
@@ -43,6 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (changePage)
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types (Params)
import Gargantext.Components.Table.Types as TT
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)
...
...
@@ -406,13 +407,13 @@ type Props =
| PropsNoReload )
type LoadedNgramsTableHeaderProps =
( searchQuery :: T.Box SearchQuery )
( searchQuery :: T.Box SearchQuery
, params :: T.Box Params
)
loadedNgramsTableHeader :: R2.Leaf LoadedNgramsTableHeaderProps
loadedNgramsTableHeader = R2.leaf loadedNgramsTableHeaderCpt
loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
cpt { searchQuery } _ = pure $
cpt { searchQuery
, params
} _ = pure $
R.fragment
[
...
...
@@ -434,6 +435,7 @@ loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
NTS.searchInput
{ key: "search-input"
, searchQuery
, params
}
]
...
...
@@ -540,6 +542,7 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
performAction
$ CoreAction
$ Synchronize { afterSync: afterSync' }
changePage 1 params
-- autoUpdate :: Array R.Element
...
...
@@ -752,6 +755,7 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
where
cpt props@{ cacheState, path, treeEdit } _ = do
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
-- onCancelRef <- R.useRef Nothing
-- onNgramsClickRef <- R.useRef Nothing
...
...
@@ -773,12 +777,12 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
case cacheState' of
NT.CacheOn -> pure $ R.fragment
[ loadedNgramsTableHeader { searchQuery }
[ loadedNgramsTableHeader { searchQuery
, params
}
, ngramsTreeEdit (treeEdit)
, mainNgramsTableCacheOn (Record.merge props { state })
]
NT.CacheOff -> pure $ R.fragment
[loadedNgramsTableHeader { searchQuery
}
[loadedNgramsTableHeader { searchQuery
, params
}
, ngramsTreeEdit (treeEdit)
, mainNgramsTableCacheOff (Record.merge props { state })
]
...
...
src/Gargantext/Components/NgramsTable/Search.purs
View file @
796e8e18
...
...
@@ -7,6 +7,8 @@ import Data.Foldable (intercalate)
import Data.Nullable (Nullable, null)
import Gargantext.Components.Bootstrap as B
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 Reactix as R
import Reactix.DOM.HTML as H
...
...
@@ -18,6 +20,7 @@ here = R2.here "Gargantext.Components.NgramsTable.Search"
type SearchInputProps =
( searchQuery :: T.Box String
, params :: T.Box Params
)
-- "key": to prevent refreshing & losing input
...
...
@@ -26,14 +29,14 @@ searchInput = R2.leafComponent searchInputCpt
searchInputCpt :: R.Component ( key :: String | SearchInputProps )
searchInputCpt = here.component "searchInput" cpt
where
cpt { searchQuery } _ = do
cpt { searchQuery
, params
} _ = do
inputRef <- R.useRef null
pure $ R2.row
[ H.div { className: "col-12" }
[ H.div { className: "input-group" }
[ searchFieldInput { inputRef, searchQuery } []
, searchButton { inputRef, searchQuery } []
, searchButton { inputRef, searchQuery
, params
} []
]
]
]
...
...
@@ -41,6 +44,7 @@ searchInputCpt = here.component "searchInput" cpt
type SearchButtonProps =
( inputRef :: R.Ref (Nullable DOM.Element)
, searchQuery :: T.Box String
, params :: T.Box Params
)
searchButton :: R2.Component SearchButtonProps
...
...
@@ -48,7 +52,7 @@ searchButton = R.createElement searchButtonCpt
searchButtonCpt :: R.Component SearchButtonProps
searchButtonCpt = here.component "searchButton" cpt where
cpt { inputRef, searchQuery } _ = do
cpt { inputRef, searchQuery
, params
} _ = do
-- | States
-- |
searchQuery' <- T.useLive T.unequal searchQuery
...
...
@@ -59,9 +63,11 @@ searchButtonCpt = here.component "searchButton" cpt where
onReset _ = do
R2.setInputValue inputRef ""
T.write_ "" searchQuery
changePage 1 params
onSubmit _ = do
T.write_ (R2.getInputValue inputRef) searchQuery
changePage 1 params
-- | Render
-- |
...
...
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