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
138
Issues
138
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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)
...
@@ -7,7 +7,6 @@ import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (over)
import Data.Newtype (over)
import Data.Nullable (null)
import Data.Nullable (null)
import Data.Set as Set
import Data.Set as Set
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)
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
80d60b84
...
@@ -35,7 +35,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
...
@@ -35,7 +35,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.REST (RESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader
, useLoaderBox
)
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get)
import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...
@@ -543,90 +543,104 @@ mainNgramsTable = R.createElement mainNgramsTableCpt
...
@@ -543,90 +543,104 @@ mainNgramsTable = R.createElement mainNgramsTableCpt
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = here.component "mainNgramsTable" cpt
mainNgramsTableCpt = here.component "mainNgramsTable" cpt
where
where
cpt { afterSync
cpt props@{ cacheState } _ = do
, boxes
, cacheState
, defaultListId
, path
, tabNgramType
, withAutoUpdate } _ = do
cacheState' <- T.useLive T.unequal cacheState
cacheState' <- T.useLive T.unequal cacheState
path' <- T.useLive T.unequal path
-- let path = initialPageParams session nodeId [defaultListId] tabType
-- let path = initialPageParams session nodeId [defaultListId] tabType
case cacheState' of
case cacheState' of
NT.CacheOn -> do
NT.CacheOn -> pure $ mainNgramsTableCacheOn props []
let render versioned = mainNgramsTablePaint { afterSync
NT.CacheOff -> pure $ mainNgramsTableCacheOff props []
, boxes
, cacheState: cacheState'
mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps
, path
mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt
, tabNgramType
mainNgramsTableCacheOnCpt :: R.Component MainNgramsTableProps
, versioned
mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
, withAutoUpdate } []
cpt { afterSync
useLoaderWithCacheAPI {
, boxes
cacheEndpoint: versionEndpoint { defaultListId, path: path' }
, defaultListId
, errorHandler
, path
, handleResponse
, tabNgramType
, mkRequest
, withAutoUpdate } _ = do
, path: path'
, renderer: render
-- let path = initialPageParams session nodeId [defaultListId] tabType
}
NT.CacheOff -> do
path' <- T.useLive T.unequal path
-- path <- R.useState' path
let render versioned = mainNgramsTablePaint { afterSync
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, boxes
, boxes
, cacheState: NT.CacheOn
, cacheState: cacheState'
, path
, path
, tabNgramType
, tabNgramType
, versioned
, versionedWithCount
, withAutoUpdate } []
, withAutoUpdate } []
useLoaderWithCacheAPI {
useLoader { errorHandler
cacheEndpoint: versionEndpoint { defaultListId, path: path' }
, loader
, errorHandler
, path: path'
, handleResponse
, render }
, mkRequest
, path: path'
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
, renderer: render
}
-- NOTE With cache on
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
-- versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
mkRequest :: PageParams -> GUC.Request
mkRequest path@{ session } = GUC.makeGetRequest session $ url path
-- NOTE With cache off
where
loader :: PageParams -> Aff (Either RESTError VersionedWithCountNgramsTable)
url { listIds
loader { listIds
, nodeId
, nodeId
, tabType
, params: { limit, offset }
} = R.GetNgramsTableAll { listIds
, searchQuery
, tabType } (Just nodeId)
, session
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
, tabType
handleResponse v = v
, termListFilter
, termSizeFilter
mainNgramsTableCacheOff :: R2.Component MainNgramsTableProps
} =
mainNgramsTableCacheOff = R.createElement mainNgramsTableCacheOnCpt
get session $ R.GetNgrams params (Just nodeId)
mainNgramsTableCacheOffCpt :: R.Component MainNgramsTableProps
where
mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
params = { limit
cpt { afterSync
, listIds
, boxes
, offset: Just offset
, defaultListId
, orderBy: Nothing -- TODO
, path
, searchQuery
, tabNgramType
, tabType
, withAutoUpdate } _ = do
, termListFilter
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, termSizeFilter
, boxes
}
, cacheState: NT.CacheOff
, path
-- NOTE With cache on
, tabNgramType
mkRequest :: PageParams -> GUC.Request
, versionedWithCount
mkRequest path@{ session } = GUC.makeGetRequest session $ url path
, withAutoUpdate } []
where
useLoaderBox { errorHandler
url { listIds
, loader
, nodeId
, path
, tabType
, render }
} = R.GetNgramsTableAll { listIds
, tabType } (Just nodeId)
errorHandler err = here.log2 "[mainNgramsTable] RESTError" err
handleResponse :: VersionedNgramsTable -> VersionedNgramsTable
-- NOTE With cache off
handleResponse v = v
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 = (
type MainNgramsTablePaintProps = (
cacheState :: NT.CacheState
cacheState :: NT.CacheState
...
...
src/Gargantext/Hooks/Loader.purs
View file @
80d60b84
...
@@ -21,7 +21,6 @@ import Gargantext.Utils.Crypto (Hash)
...
@@ -21,7 +21,6 @@ import Gargantext.Utils.Crypto (Hash)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix as R
import Simple.JSON as JSON
import Simple.JSON as JSON
import Toestand (Box)
import Toestand as T
import Toestand as T
here :: R2.Here
here :: R2.Here
...
@@ -48,17 +47,16 @@ useLoader { errorHandler, loader: loader', path, render } = do
...
@@ -48,17 +47,16 @@ useLoader { errorHandler, loader: loader', path, render } = do
useLoaderEffect { errorHandler, loader: loader', path, state: state }
useLoaderEffect { errorHandler, loader: loader', path, state: state }
pure $ loader {
path,
render, state } []
pure $ loader { render, state } []
type LoaderProps path st =
type LoaderProps st =
( path :: path
( render :: st -> R.Element
, render :: st -> R.Element
, state :: T.Box (Maybe st) )
, 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
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
loaderCpt = here.component "loader" cpt
where
where
cpt { render, state } _ = do
cpt { render, state } _ = do
...
@@ -93,6 +91,44 @@ useLoaderEffect { errorHandler, loader: loader', path, state } = do
...
@@ -93,6 +91,44 @@ useLoaderEffect { errorHandler, loader: loader', path, state } = do
Right l' -> liftEffect $ T.write_ (Just l') state
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 }
newtype HashedResponse a = HashedResponse { hash :: Hash, value :: a }
derive instance Generic (HashedResponse a) _
derive instance Generic (HashedResponse a) _
derive instance Newtype (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