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
1c46c74a
Commit
1c46c74a
authored
Dec 13, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph explorer] include node children in graph search
parent
4b0605b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
14 deletions
+22
-14
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+1
-0
Search.purs
src/Gargantext/Components/GraphExplorer/Search.purs
+15
-9
InputWithAutocomplete.purs
src/Gargantext/Components/InputWithAutocomplete.purs
+5
-5
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+1
-0
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
1c46c74a
...
...
@@ -260,6 +260,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
nodeFn _i nn@(GET.Node n) =
Seq.singleton {
borderColor: color
, children: n.children
, color : color
, equilateral: { numPoints: 3 }
, gargType
...
...
src/Gargantext/Components/GraphExplorer/Search.purs
View file @
1c46c74a
...
...
@@ -2,9 +2,9 @@ module Gargantext.Components.GraphExplorer.Search
( Props, nodeSearchControl ) where
import Prelude
import Data.Foldable (foldl)
import Data.Sequence as Seq
import Data.Set as Set
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Reactix as R
...
...
@@ -26,32 +26,37 @@ type Props = (
)
-- | Whether a node matches a search string
-- Searches given node and matches it's label or any of the children's labels.
nodeMatchesSearch :: String -> Record SigmaxT.Node -> Boolean
nodeMatchesSearch s n = queryMatchesLabel s n.label
nodeMatchesSearch s n@{ children } =
foldl (\acc childLabel -> queryMatchesLabel s childLabel) initial children
where
initial = queryMatchesLabel s n.label
searchNodes :: String -> Seq.Seq (Record SigmaxT.Node) -> Seq.Seq (Record SigmaxT.Node)
searchNodes "" _ = Seq.empty
searchNodes s nodes = Seq.filter (nodeMatchesSearch s) nodes
nodeSearchControl :: R2.Component Props
nodeSearchControl = R.createElement sizeButtonCpt
sizeButtonCpt :: R.Component Props
sizeButtonCpt = here.component "nodeSearchControl" cpt
nodeSearchControl = R.createElement nodeSearchControlCpt
nodeSearchControlCpt :: R.Component Props
nodeSearchControlCpt = here.component "nodeSearchControl" cpt
where
cpt { graph, multiSelectEnabled, selectedNodeIds } _ = do
search <- T.useBox ""
search' <- T.useLive T.unequal search
multiSelectEnabled' <- T.useLive T.unequal multiSelectEnabled
let doSearch s = triggerSearch graph s multiSelectEnabled' selectedNodeIds
pure $ R.fragment
[ inputWithAutocomplete { autocompleteSearch: autocompleteSearch graph
, classes: "mx-2"
, onAutocompleteClick:
\s -> triggerSearch graph s multiSelectEnabled' selectedNodeIds
, onEnterPress:
\s -> triggerSearch graph s multiSelectEnabled' selectedNodeIds
, onAutocompleteClick:
doSearch
, onEnterPress:
doSearch
, state: search } []
, H.div { className: "btn input-group-addon"
, on: { click: \_ ->
triggerSearch graph search' multiSelectEnabled' selectedNodeIds
}
, on: { click: \_ ->
doSearch search'
}
}
[ H.span { className: "fa fa-search" } [] ]
]
...
...
@@ -74,3 +79,4 @@ triggerSearch graph search multiSelectEnabled selectedNodeIds = do
T.modify_ (\nodes ->
Set.union matching $ if multiSelectEnabled then nodes else SigmaxT.emptyNodeIds) selectedNodeIds
src/Gargantext/Components/InputWithAutocomplete.purs
View file @
1c46c74a
module Gargantext.Components.InputWithAutocomplete where
import Prelude
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null, toMaybe)
import DOM.Simple as DOM
import DOM.Simple.Event as DE
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null, toMaybe)
import Effect (Effect)
import Effect.Timer (setTimeout)
import Gargantext.Utils.Reactix as R2
import React.SyntheticEvent as E
import Reactix as R
import Reactix.DOM.HTML as H
import React.SyntheticEvent as E
import Toestand as T
import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Components.InputWithAutocomplete"
...
...
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
1c46c74a
...
...
@@ -35,6 +35,7 @@ type EdgeId = String
type Node = (
borderColor :: String
, children :: Array String
, color :: String
, equilateral :: { numPoints :: Int }
, gargType :: GT.Mode
...
...
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