From 6129a27ecfd7ca192b0f3507fbeeb50f4ae23fe4 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sun, 11 Dec 2016 16:21:36 -0500 Subject: [PATCH] hit Ctrl+A a second time to select all synapses, too (#968) --- frontend/src/Metamaps/Listeners.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/src/Metamaps/Listeners.js b/frontend/src/Metamaps/Listeners.js index 470e8cbe..756227b1 100644 --- a/frontend/src/Metamaps/Listeners.js +++ b/frontend/src/Metamaps/Listeners.js @@ -2,6 +2,7 @@ import Active from './Active' import Control from './Control' +import DataModel from './DataModel' import JIT from './JIT' import Mobile from './Mobile' import Realtime from './Realtime' @@ -31,14 +32,27 @@ const Listeners = { break case 65: // if a or A is pressed if ((e.ctrlKey || e.metaKey) && onCanvas) { - Control.deselectAllNodes() - Control.deselectAllEdges() - + const nodesCount = Object.keys(Visualize.mGraph.graph.nodes).length + const selectedNodesCount = Selected.Nodes.length e.preventDefault() - Visualize.mGraph.graph.eachNode(function(n) { - Control.selectNode(n, e) + + // Hit Ctrl+A once to select all nodes + Control.deselectAllNodes() + Visualize.mGraph.graph.eachNode(node => { + Control.selectNode(node, e) }) + // Hitting Ctrl+A a second time will select all edges too + Control.deselectAllEdges() + if (nodesCount === selectedNodesCount) { + DataModel.Synapses.models.forEach(synapse => { + const topic1id = synapse.get('topic1_id') + const topic2id = synapse.get('topic2_id') + const edge = Visualize.mGraph.graph.edges[topic1id][topic2id] + Control.selectEdge(edge, e) + }) + } + Visualize.mGraph.plot() }