mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: There was a minor bug in JSONAdapter. Fixed now
This commit is contained in:
parent
cd230cc1cb
commit
192e75716e
|
@ -97,18 +97,13 @@ function JSONAdapter(jsonPath, nodes, edges, width, height) {
|
|||
});
|
||||
_.each(n.children, function(c) {
|
||||
var check = findNode(c);
|
||||
if (check) {
|
||||
insertEdge(n, check);
|
||||
self.requestCentralityChildren(check._id, function(c) {
|
||||
n._centrality = c;
|
||||
});
|
||||
} else {
|
||||
insertNode(c);
|
||||
insertEdge(n, c);
|
||||
self.requestCentralityChildren(c._id, function(c) {
|
||||
n._centrality = c;
|
||||
});
|
||||
if (!check) {
|
||||
check = insertNode(c);
|
||||
}
|
||||
insertEdge(n, check);
|
||||
self.requestCentralityChildren(check._id, function(c) {
|
||||
n._centrality = c;
|
||||
});
|
||||
});
|
||||
if (callback) {
|
||||
callback(n);
|
||||
|
|
|
@ -78,7 +78,6 @@ function EventLibrary() {
|
|||
|
||||
this.Expand = function (config) {
|
||||
self.checkExpandConfig(config);
|
||||
|
||||
var edges = config.edges,
|
||||
nodes = config.nodes,
|
||||
startCallback = config.startCallback,
|
||||
|
|
|
@ -95,13 +95,6 @@ function GraphViewer(svg, width, height,
|
|||
|
||||
if (checkDefs(conf.expand)) {
|
||||
dispatcher.bind(conf.expand.target, conf.expand.type, dispatcher.events.EXPAND);
|
||||
dispatcher.bind("nodes", "update", function(node) {
|
||||
node.selectAll("circle")
|
||||
.attr("class", function(d) {
|
||||
return d._expanded ? "expanded" :
|
||||
d._centrality === 0 ? "single" : "collapsed";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (checkDefs(conf.createNode)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<script type="text/javascript" src="../ui/modalDialogHelper.js"></script>
|
||||
<script type="text/javascript" src="../ui/nodeShaperControls.js"></script>
|
||||
<script type="text/javascript" src="../ui/edgeShaperControls.js"></script>
|
||||
<script type="text/javascript" src="../ui/eventDispatcherControls.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="specColourMapper/colourMapperSpec.js"></script>
|
||||
|
|
|
@ -74,11 +74,14 @@
|
|||
nodes = [];
|
||||
edges = [];
|
||||
|
||||
this.loadNode = function() {};
|
||||
spyOn(this, "loadNode");
|
||||
|
||||
expandConfig = {
|
||||
edges: edges,
|
||||
nodes: nodes,
|
||||
startCallback: function() {},
|
||||
loadNode: function() {},
|
||||
loadNode: this.loadNode,
|
||||
reshapeNode: function() {}
|
||||
};
|
||||
|
||||
|
@ -419,7 +422,29 @@
|
|||
describe('checking different events', function() {
|
||||
|
||||
it('should be able to bind the expand event', function() {
|
||||
runs(function() {
|
||||
nodes = [{_id: 1}];
|
||||
nodeShaper.drawNodes(nodes);
|
||||
dispatcher.bind("nodes", "click", dispatcher.events.EXPAND);
|
||||
helper.simulateMouseEvent("click", "1");
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return this.loadNode.wasCalled;
|
||||
}, 1000, "The loadNode function should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(nodes[0]._expanded).toBeTruthy();
|
||||
helper.simulateMouseEvent("click", "1");
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return !nodes[0]._expanded;
|
||||
}, 1000, "The loadNode function should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to bind the drag event', function() {
|
||||
|
|
|
@ -162,6 +162,57 @@
|
|||
expect(reshapedNodes[0]).toEqual(root);
|
||||
});
|
||||
|
||||
it('should not remove referenced nodes on collapsing ', function() {
|
||||
var root = {
|
||||
_id: 0,
|
||||
_expanded: true,
|
||||
_outboundCounter: 2,
|
||||
_inboundCounter: 0
|
||||
},
|
||||
c1 = {
|
||||
_id: 1,
|
||||
_outboundCounter: 0,
|
||||
_inboundCounter: 2
|
||||
},
|
||||
c2 = {
|
||||
_id: 2,
|
||||
_outboundCounter: 1,
|
||||
_inboundCounter: 0
|
||||
},
|
||||
c3 = {
|
||||
_id: 3,
|
||||
_outboundCounter: 0,
|
||||
_inboundCounter: 1
|
||||
};
|
||||
|
||||
nodes.push(root);
|
||||
nodes.push(c1);
|
||||
nodes.push(c2);
|
||||
nodes.push(c3);
|
||||
edges.push({source: root, target: c1});
|
||||
edges.push({source: root, target: c3});
|
||||
edges.push({source: c2, target: c1});
|
||||
|
||||
testee = eventLib.Expand(config);
|
||||
testee(root);
|
||||
|
||||
expect(root._expanded).toBeFalsy();
|
||||
expect(started).toEqual(1);
|
||||
expect(reshaped).toEqual(1);
|
||||
expect(loaded).toEqual(0);
|
||||
expect(nodes.length).toEqual(3);
|
||||
expect(edges.length).toEqual(1);
|
||||
expect(reshapedNodes.length).toEqual(1);
|
||||
expect(reshapedNodes[0]).toEqual(root);
|
||||
|
||||
expect(root._outboundCounter).toEqual(0);
|
||||
expect(c1._inboundCounter).toEqual(1);
|
||||
expect(c2._outboundCounter).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
describe('setup process', function() {
|
||||
|
||||
var testConfig = {};
|
||||
|
|
|
@ -362,7 +362,7 @@ describe("Graph Viewer", function() {
|
|||
|
||||
// Wait a gentle second for all nodes to expand properly
|
||||
waits(1000);
|
||||
|
||||
|
||||
runs(function() {
|
||||
clickOnNode(1);
|
||||
clickOnNode(4);
|
||||
|
|
Loading…
Reference in New Issue