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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
gargantext
purescript-gargantext
Commits
80d60b84
Commit
80d60b84
authored
Aug 28, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[searchField] fix search input focus not being lost anymore
parent
dae0862b
Pipeline
#1745
failed with stage
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
88 deletions
+137
-88
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+0
-1
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+94
-80
Loader.purs
src/Gargantext/Hooks/Loader.purs
+43
-7
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
80d60b84
...
...
@@ -7,7 +7,6 @@ import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (over)
import Data.Nullable (null)
import Data.Set as Set
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
80d60b84
...
...
@@ -35,7 +35,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader
, useLoaderBox
)
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...
...
@@ -543,90 +543,104 @@ mainNgramsTable = R.createElement mainNgramsTableCpt
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = here.component "mainNgramsTable" cpt
where
cpt { afterSync
, boxes
, cacheState
, defaultListId
, path
, tabNgramType
, withAutoUpdate } _ = do
cpt props@{ cacheState } _ = do
cacheState' <- T.useLive T.unequal cacheState
path' <- T.useLive T.unequal path
-- let path = initialPageParams session nodeId [defaultListId] tabType
case cacheState' of
NT.CacheOn -> do
let render versioned = mainNgramsTablePaint { afterSync
, boxes
, cacheState: cacheState'
, path
, tabNgramType
, versioned
, withAutoUpdate } []
useLoaderWithCacheAPI {
cacheEndpoint: versionEndpoint { defaultListId, path: path' }
, errorHandler
, handleResponse
, mkRequest
, path: path'
, renderer: render
}
NT.CacheOff -> do
-- path <- R.useState' path
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, boxes
, cacheState: cacheState'
, path
, tabNgramType
, versionedWithCount
, withAutoUpdate } []
useLoader { errorHandler
, loader
, path: path'
, render }
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
-- NOTE With cache on
-- versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
-- NOTE With cache off
loader :: PageParams -> Aff (Either RESTError VersionedWithCountNgramsTable)
loader { listIds
, nodeId
, params: { limit, offset }
, searchQuery
, session
, tabType
, termListFilter
, termSizeFilter
} =
get session $ R.GetNgrams params (Just nodeId)
where
params = { limit
, listIds
, offset: Just offset
, orderBy: Nothing -- TODO
, searchQuery
, tabType
, termListFilter
, termSizeFilter
}
-- NOTE With cache on
mkRequest :: PageParams -> GUC.Request
mkRequest path@{ session } = GUC.makeGetRequest session $ url path
where
url { listIds
, nodeId
, tabType
} = R.GetNgramsTableAll { listIds
, tabType } (Just nodeId)
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
handleResponse v = v
NT.CacheOn -> pure $ mainNgramsTableCacheOn props []
NT.CacheOff -> pure $ mainNgramsTableCacheOff props []
mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps
mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt
mainNgramsTableCacheOnCpt :: R.Component MainNgramsTableProps
mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
cpt { afterSync
, boxes
, defaultListId
, path
, tabNgramType
, withAutoUpdate } _ = do
-- let path = initialPageParams session nodeId [defaultListId] tabType
path' <- T.useLive T.unequal path
let render versioned = mainNgramsTablePaint { afterSync
, boxes
, cacheState: NT.CacheOn
, path
, tabNgramType
, versioned
, withAutoUpdate } []
useLoaderWithCacheAPI {
cacheEndpoint: versionEndpoint { defaultListId, path: path' }
, errorHandler
, handleResponse
, mkRequest
, path: path'
, renderer: render
}
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
mkRequest :: PageParams -> GUC.Request
mkRequest path@{ session } = GUC.makeGetRequest session $ url path
where
url { listIds
, nodeId
, tabType
} = R.GetNgramsTableAll { listIds
, tabType } (Just nodeId)
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
handleResponse v = v
mainNgramsTableCacheOff :: R2.Component MainNgramsTableProps
mainNgramsTableCacheOff = R.createElement mainNgramsTableCacheOnCpt
mainNgramsTableCacheOffCpt :: R.Component MainNgramsTableProps
mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
cpt { afterSync
, boxes
, defaultListId
, path
, tabNgramType
, withAutoUpdate } _ = do
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, boxes
, cacheState: NT.CacheOff
, path
, tabNgramType
, versionedWithCount
, withAutoUpdate } []
useLoaderBox { errorHandler
, loader
, path
, render }
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
-- NOTE With cache off
loader :: PageParams -> Aff (Either RESTError VersionedWithCountNgramsTable)
loader { listIds
, nodeId
, params: { limit, offset }
, searchQuery
, session
, tabType
, termListFilter
, termSizeFilter
} =
get session $ R.GetNgrams params (Just nodeId)
where
params = { limit
, listIds
, offset: Just offset
, orderBy: Nothing -- TODO
, searchQuery
, tabType
, termListFilter
, termSizeFilter
}
type MainNgramsTablePaintProps = (
cacheState :: NT.CacheState
...
...
src/Gargantext/Hooks/Loader.purs
View file @
80d60b84
...
...
@@ -21,7 +21,6 @@ import Gargantext.Utils.Crypto (Hash)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Simple.JSON as JSON
import Toestand (Box)
import Toestand as T
here :: R2.Here
...
...
@@ -48,17 +47,16 @@ useLoader { errorHandler, loader: loader', path, render } = do
useLoaderEffect { errorHandler, loader: loader', path, state: state }
pure $ loader {
path,
render, state } []
pure $ loader { render, state } []
type LoaderProps path st =
( path :: path
, render :: st -> R.Element
type LoaderProps st =
( render :: st -> R.Element
, state :: T.Box (Maybe st) )
loader :: forall
path st. Eq path => Eq st => R2.Component (LoaderProps path
st)
loader :: forall
st. Eq st => R2.Component (LoaderProps
st)
loader = R.createElement loaderCpt
loaderCpt :: forall
path st. Eq path => Eq st => R.Component (LoaderProps path
st)
loaderCpt :: forall
st. Eq st => R.Component (LoaderProps
st)
loaderCpt = here.component "loader" cpt
where
cpt { render, state } _ = do
...
...
@@ -93,6 +91,44 @@ useLoaderEffect { errorHandler, loader: loader', path, state } = do
Right l' -> liftEffect $ T.write_ (Just l') state
type UseLoaderBox path state =
( errorHandler :: RESTError -> Effect Unit
, loader :: path -> Aff (Either RESTError state)
, path :: T.Box path
, render :: state -> R.Element
)
useLoaderBox :: forall path st. Eq path => Eq st
=> Record (UseLoaderBox path st)
-> R.Hooks R.Element
useLoaderBox { errorHandler, loader: loader', path, render } = do
state <- T.useBox Nothing
useLoaderBoxEffect { errorHandler, loader: loader', path, state: state }
pure $ loader { render, state } []
type UseLoaderBoxEffect path state =
( errorHandler :: RESTError -> Effect Unit
, loader :: path -> Aff (Either RESTError state)
, path :: T.Box path
, state :: T.Box (Maybe state)
)
useLoaderBoxEffect :: forall st path. Eq path => Eq st
=> Record (UseLoaderBoxEffect path st)
-> R.Hooks Unit
useLoaderBoxEffect { errorHandler, loader: loader', path, state } = do
path' <- T.useLive T.unequal path
R.useEffect' $ do
R2.affEffect "G.H.Loader.useLoaderBoxEffect" $ do
l <- loader' path'
case l of
Left err -> liftEffect $ errorHandler err
Right l' -> liftEffect $ T.write_ (Just l') state
newtype HashedResponse a = HashedResponse { hash :: Hash, value :: a }
derive instance Generic (HashedResponse a) _
derive instance Newtype (HashedResponse a) _
...
...
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