Skip to content

Commit 9b39bde

Browse files
committed
bl: Clearing the "Search" field will now properly unselect all nodes.
1 parent 29c3ecf commit 9b39bde

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

build/app/view/autocompletedemo/autocomplete-logic.js

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22
33
* EVENTS: D3 Graph Updates
44
5-
Mark Node/Edge When a node or edge is higlighted via an AutoComplete
6-
highlight or is selected via AutoComplete selection
7-
or clicked on in NetGraph, it is shown bold (or
8-
outlined) in the D3 graph. This is done by updating
9-
the node or edge in `this.state.data` object, setting
10-
the object's `selected` key to a particular color
11-
corresponding to the node/edge UI control. When
12-
the data is updated, it is passed to `NetGraph.jsx`,
13-
which in turn updates the data in
14-
`D3SimpleNetGraph.js`. `D3SimpleNetGraph` will add
15-
the highlight during its update cycle.
16-
17-
The colors allow us to highlight different fields
18-
simultaneously with each component. For example,
19-
you can highlight both the source and target nodes
20-
with different colors so you know which is which.
21-
This is especially useful when the highlight matches
22-
many objects, e.g. "Ah" matches 7 different nodes.
5+
Mark Node/Edge Nodes in the graph are marked via a stroke around
6+
the circle. There are two types of marks:
7+
8+
1. SEARCH -- when a node matches a search, its
9+
strokeColor is set to green.
10+
11+
2. SELECTION -- when a node is selected by the
12+
user and shown in the NodeSelector either by
13+
directly clicking on it or by clicking on a
14+
item in the search suggestion list, the node
15+
data is marked `selected` and a blue strokeColor
16+
is applied.
17+
18+
The two marks are orthogonal to each other: a
19+
node can be both searched and selected, though
20+
the selection mark will override the search
21+
mark.
22+
23+
The rendering is handled by modifying the
24+
node data in D3DATA. d3-simplenetgraph will
25+
then read any D3DATA updates and redraw
26+
the graph based on the updated data.
2327
2428
Add New Node/Edge When the user adds a new edge or node, handlers in
2529
AutoCompleteDemo will update its `this.state.data`
@@ -185,7 +189,11 @@ const TARGET_COLOR = '#FF0000';
185189
}
186190
}
187191
// SEARCH LABEL UPDATE
188-
if (searchLabel) m_SetStrokeColorThatMatch(searchLabel,SEARCH_COLOR);
192+
if (searchLabel==='') {
193+
m_UnStrokeAllNodes();
194+
} else if (searchLabel!==undefined) {
195+
m_SetStrokeColorThatMatch(searchLabel,SEARCH_COLOR);
196+
}
189197
}); // StateChange SELECTION
190198
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - inside hook
191199
/*/ User has clicked on a suggestion from the AutoCopmlete suggestion list.
@@ -576,6 +584,13 @@ const TARGET_COLOR = '#FF0000';
576584
UDATA.SetAppState('D3DATA',D3DATA);
577585
}
578586
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
587+
/*/ Remove the stroke color. Used to unmark search matches.
588+
/*/ function m_UnStrokeAllNodes() {
589+
let props = { strokeColor : undefined };
590+
m_SetAllObjs(D3DATA.nodes,props);
591+
UDATA.SetAppState('D3DATA',D3DATA);
592+
}
593+
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
579594
/*/ Sets the `node.selected` property to `color` so it is hilited on graph
580595
/*/ function m_MarkNodeById( id, color ) {
581596
let marked = { selected : SOURCE_COLOR };
@@ -590,10 +605,11 @@ const TARGET_COLOR = '#FF0000';
590605
/*/ Sets the `node.selected` property to `color` so it is hilited on graph
591606
/*/ function m_MarkNodeByLabel( label, color ) {
592607
let marked = { selected : color };
608+
let normal = { selected : DESELECTED_COLOR };
593609
// NOTE: this.getSelectedNodeColor(node,color) and
594610
// this.getDeselectedNodeColor(node,color) are not yet implemented
595611
// to override the properties
596-
m_SetMatchingNodesByLabel(label,marked);
612+
m_SetMatchingNodesByLabel(label,marked,normal);
597613
UDATA.SetAppState('D3DATA',D3DATA);
598614
}
599615
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0 commit comments

Comments
 (0)