mirror of https://gitee.com/bigwinds/arangodb
Fixed a bug where dragging of nodes was not possible and connecting them with edges made everything even worse
This commit is contained in:
parent
f7735391df
commit
0c62714017
|
@ -118,6 +118,7 @@ function AbstractAdapter(nodes, edges, descendant, viewer, config) {
|
||||||
}
|
}
|
||||||
node.x = x || initialX.getStart();
|
node.x = x || initialX.getStart();
|
||||||
node.y = y || initialY.getStart();
|
node.y = y || initialY.getStart();
|
||||||
|
node.weight = 1;
|
||||||
nodes.push(node);
|
nodes.push(node);
|
||||||
node._outboundCounter = 0;
|
node._outboundCounter = 0;
|
||||||
node._inboundCounter = 0;
|
node._inboundCounter = 0;
|
||||||
|
|
|
@ -181,7 +181,7 @@ function EventDispatcher(nodeShaper, edgeShaper, config) {
|
||||||
}
|
}
|
||||||
if (config.drag !== undefined) {
|
if (config.drag !== undefined) {
|
||||||
if (eventlib.checkDragConfig(config.drag)) {
|
if (eventlib.checkDragConfig(config.drag)) {
|
||||||
self.events.DRAG = new eventlib.Drag(config.drag);
|
self.events.DRAG = eventlib.Drag(config.drag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.nodeEditor !== undefined) {
|
if (config.nodeEditor !== undefined) {
|
||||||
|
|
|
@ -135,7 +135,9 @@ function ArangoAdapterControls(list, adapter) {
|
||||||
idprefix, [{
|
idprefix, [{
|
||||||
type: "extendable",
|
type: "extendable",
|
||||||
id: "attribute",
|
id: "attribute",
|
||||||
objects: prioList
|
objects: function() {
|
||||||
|
adapter.getPrioList();
|
||||||
|
}
|
||||||
}], function () {
|
}], function () {
|
||||||
var list = $("input[id^=" + idprefix + "attribute_]"),
|
var list = $("input[id^=" + idprefix + "attribute_]"),
|
||||||
prios = [];
|
prios = [];
|
||||||
|
|
|
@ -29,10 +29,8 @@
|
||||||
/// @author Michael Hackstein
|
/// @author Michael Hackstein
|
||||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/* Archive
|
|
||||||
function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, dispatcherConfig) {
|
function EventDispatcherControls(list, nodeShaper, edgeShaper, start, dispatcherConfig) {
|
||||||
*/
|
|
||||||
function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig) {
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (list === undefined) {
|
if (list === undefined) {
|
||||||
|
@ -44,6 +42,9 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
|
||||||
if (edgeShaper === undefined) {
|
if (edgeShaper === undefined) {
|
||||||
throw "The EdgeShaper has to be given.";
|
throw "The EdgeShaper has to be given.";
|
||||||
}
|
}
|
||||||
|
if (start === undefined) {
|
||||||
|
throw "The Start callback has to be given.";
|
||||||
|
}
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
icons = {
|
icons = {
|
||||||
|
@ -124,6 +125,7 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
|
||||||
dispatcher.events.CREATENODE(data, function(node) {
|
dispatcher.events.CREATENODE(data, function(node) {
|
||||||
$("#" + idprefix + "modal").modal('hide');
|
$("#" + idprefix + "modal").modal('hide');
|
||||||
nodeShaper.reshapeNodes();
|
nodeShaper.reshapeNodes();
|
||||||
|
start();
|
||||||
}, pos.x, pos.y)();
|
}, pos.x, pos.y)();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -189,6 +191,7 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
|
||||||
nodesUp = dispatcher.events.FINISHCREATEEDGE(function(edge){
|
nodesUp = dispatcher.events.FINISHCREATEEDGE(function(edge){
|
||||||
edgeShaper.removeCursorFollowingEdge();
|
edgeShaper.removeCursorFollowingEdge();
|
||||||
dispatcher.bind("svg", "mousemove", function(){});
|
dispatcher.bind("svg", "mousemove", function(){});
|
||||||
|
start();
|
||||||
}),
|
}),
|
||||||
svgUp = function() {
|
svgUp = function() {
|
||||||
dispatcher.events.CANCELCREATEEDGE();
|
dispatcher.events.CANCELCREATEEDGE();
|
||||||
|
@ -240,6 +243,7 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
|
||||||
$("#control_event_node_delete_modal").modal('hide');
|
$("#control_event_node_delete_modal").modal('hide');
|
||||||
nodeShaper.reshapeNodes();
|
nodeShaper.reshapeNodes();
|
||||||
edgeShaper.reshapeEdges();
|
edgeShaper.reshapeEdges();
|
||||||
|
start();
|
||||||
})(n);
|
})(n);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -254,6 +258,7 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
|
||||||
$("#control_event_edge_delete_modal").modal('hide');
|
$("#control_event_edge_delete_modal").modal('hide');
|
||||||
nodeShaper.reshapeNodes();
|
nodeShaper.reshapeNodes();
|
||||||
edgeShaper.reshapeEdges();
|
edgeShaper.reshapeEdges();
|
||||||
|
start();
|
||||||
})(e);
|
})(e);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -111,9 +111,9 @@ function GraphViewerPreview(container, viewerConfig) {
|
||||||
var toolbox = document.createElement("div");
|
var toolbox = document.createElement("div");
|
||||||
dispatcherUI = new EventDispatcherControls(
|
dispatcherUI = new EventDispatcherControls(
|
||||||
toolbox,
|
toolbox,
|
||||||
// mousePointerBox,
|
|
||||||
viewer.nodeShaper,
|
viewer.nodeShaper,
|
||||||
viewer.edgeShaper,
|
viewer.edgeShaper,
|
||||||
|
viewer.start,
|
||||||
viewer.dispatcherConfig
|
viewer.dispatcherConfig
|
||||||
);
|
);
|
||||||
toolbox.id = "toolbox";
|
toolbox.id = "toolbox";
|
||||||
|
@ -153,6 +153,7 @@ function GraphViewerPreview(container, viewerConfig) {
|
||||||
// mousePointerBox,
|
// mousePointerBox,
|
||||||
viewer.nodeShaper,
|
viewer.nodeShaper,
|
||||||
viewer.edgeShaper,
|
viewer.edgeShaper,
|
||||||
|
viewer.start,
|
||||||
viewer.dispatcherConfig
|
viewer.dispatcherConfig
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -212,4 +213,4 @@ function GraphViewerPreview(container, viewerConfig) {
|
||||||
viewer.loadGraph("1");
|
viewer.loadGraph("1");
|
||||||
parseActions(viewerConfig.actions);
|
parseActions(viewerConfig.actions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,7 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
||||||
toolbox,
|
toolbox,
|
||||||
graphViewer.nodeShaper,
|
graphViewer.nodeShaper,
|
||||||
graphViewer.edgeShaper,
|
graphViewer.edgeShaper,
|
||||||
|
graphViewer.start,
|
||||||
graphViewer.dispatcherConfig
|
graphViewer.dispatcherConfig
|
||||||
);
|
);
|
||||||
toolbox.id = "toolbox";
|
toolbox.id = "toolbox";
|
||||||
|
|
|
@ -112,9 +112,9 @@ function GraphViewerWidget(viewerConfig, startNode) {
|
||||||
var toolbox = document.createElement("div");
|
var toolbox = document.createElement("div");
|
||||||
dispatcherUI = new EventDispatcherControls(
|
dispatcherUI = new EventDispatcherControls(
|
||||||
toolbox,
|
toolbox,
|
||||||
//mousePointerBox,
|
|
||||||
viewer.nodeShaper,
|
viewer.nodeShaper,
|
||||||
viewer.edgeShaper,
|
viewer.edgeShaper,
|
||||||
|
viewer.start,
|
||||||
viewer.dispatcherConfig
|
viewer.dispatcherConfig
|
||||||
);
|
);
|
||||||
toolbox.id = "toolbox";
|
toolbox.id = "toolbox";
|
||||||
|
@ -154,6 +154,7 @@ function GraphViewerWidget(viewerConfig, startNode) {
|
||||||
// mousePointerBox,
|
// mousePointerBox,
|
||||||
viewer.nodeShaper,
|
viewer.nodeShaper,
|
||||||
viewer.edgeShaper,
|
viewer.edgeShaper,
|
||||||
|
viewer.start,
|
||||||
viewer.dispatcherConfig
|
viewer.dispatcherConfig
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -450,8 +450,14 @@ var modalDialogHelper = modalDialogHelper || {};
|
||||||
};
|
};
|
||||||
|
|
||||||
modalDialogHelper.createModalChangeDialog = function(title, idprefix, objects, callback) {
|
modalDialogHelper.createModalChangeDialog = function(title, idprefix, objects, callback) {
|
||||||
var table = modalDialogHelper.modalDivTemplate(title, "Change", idprefix, callback);
|
var table = modalDialogHelper.modalDivTemplate(title, "Change", idprefix, callback),
|
||||||
_.each(objects, function(o) {
|
os;
|
||||||
|
if (_.isFunction(objects)) {
|
||||||
|
os = objects();
|
||||||
|
} else {
|
||||||
|
os = objects;
|
||||||
|
}
|
||||||
|
_.each(os, function(o) {
|
||||||
insertModalRow(table, idprefix, o);
|
insertModalRow(table, idprefix, o);
|
||||||
});
|
});
|
||||||
$("#" + idprefix + "modal").modal('show');
|
$("#" + idprefix + "modal").modal('show');
|
||||||
|
|
|
@ -40,8 +40,9 @@
|
||||||
|
|
||||||
describe('Event Dispatcher UI', function () {
|
describe('Event Dispatcher UI', function () {
|
||||||
var svg, dispatcherUI, list, $list,
|
var svg, dispatcherUI, list, $list,
|
||||||
nodeShaper, edgeShaper, layouter,
|
nodeShaper, edgeShaper, layouter,
|
||||||
nodes, edges, adapter,
|
nodes, edges, adapter,
|
||||||
|
start,
|
||||||
//mousePointerbox,
|
//mousePointerbox,
|
||||||
|
|
||||||
addSpies = function() {
|
addSpies = function() {
|
||||||
|
@ -55,11 +56,15 @@
|
||||||
spyOn(adapter, "loadNode");
|
spyOn(adapter, "loadNode");
|
||||||
spyOn(adapter, "expandCommunity");
|
spyOn(adapter, "expandCommunity");
|
||||||
spyOn(adapter, "explore");
|
spyOn(adapter, "explore");
|
||||||
|
spyOn(start, "cb");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
start = {
|
||||||
|
cb: function() {}
|
||||||
|
};
|
||||||
nodes = [{
|
nodes = [{
|
||||||
_id: 1,
|
_id: 1,
|
||||||
x: 3,
|
x: 3,
|
||||||
|
@ -163,7 +168,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dispatcherUI = new EventDispatcherControls(
|
dispatcherUI = new EventDispatcherControls(
|
||||||
list, nodeShaper, edgeShaper, completeConfig
|
list, nodeShaper, edgeShaper, start.cb, completeConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
spyOn(nodeShaper, "changeTo").andCallThrough();
|
spyOn(nodeShaper, "changeTo").andCallThrough();
|
||||||
|
@ -216,6 +221,10 @@
|
||||||
var e = new EventDispatcherControls(list, nodeShaper);
|
var e = new EventDispatcherControls(list, nodeShaper);
|
||||||
}).toThrow("The EdgeShaper has to be given.");
|
}).toThrow("The EdgeShaper has to be given.");
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
var e = new EventDispatcherControls(list, nodeShaper, edgeShaper);
|
||||||
|
}).toThrow("The Start callback has to be given.");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to add a new node control to the list', function() {
|
it('should be able to add a new node control to the list', function() {
|
||||||
|
@ -600,14 +609,15 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to add a delete control to the list', function() {
|
describe("delete control", function() {
|
||||||
runs(function() {
|
|
||||||
|
beforeEach(function() {
|
||||||
dispatcherUI.addControlDelete();
|
dispatcherUI.addControlDelete();
|
||||||
|
|
||||||
expect($("#control_event_list #control_event_delete").length).toEqual(1);
|
|
||||||
|
|
||||||
helper.simulateMouseEvent("click", "control_event_delete");
|
helper.simulateMouseEvent("click", "control_event_delete");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be added to the list", function() {
|
||||||
|
expect($("#control_event_list #control_event_delete").length).toEqual(1);
|
||||||
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
|
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
|
||||||
actions: {
|
actions: {
|
||||||
reset: true,
|
reset: true,
|
||||||
|
@ -621,24 +631,27 @@
|
||||||
click: jasmine.any(Function)
|
click: jasmine.any(Function)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
//expect(mousePointerbox.className).toEqual("mousepointer icon-trash");
|
|
||||||
|
it("should ask for permission and delete nodes", function() {
|
||||||
helper.simulateMouseEvent("click", "1");
|
var id = "1";
|
||||||
|
helper.simulateMouseEvent("click", id);
|
||||||
|
helper.simulateMouseEvent("click", "control_event_node_delete_submit");
|
||||||
expect(adapter.deleteNode).toHaveBeenCalledWith(
|
expect(adapter.deleteNode).toHaveBeenCalledWith(
|
||||||
nodes[0],
|
nodes[0],
|
||||||
jasmine.any(Function)
|
jasmine.any(Function)
|
||||||
);
|
);
|
||||||
|
});
|
||||||
helper.simulateMouseEvent("click", "1-2");
|
|
||||||
|
it("should ask for permission and delete nodes", function() {
|
||||||
|
var id = "1-2";
|
||||||
|
helper.simulateMouseEvent("click", id);
|
||||||
|
helper.simulateMouseEvent("click", "control_event_edge_delete_submit");
|
||||||
expect(adapter.deleteEdge).toHaveBeenCalledWith(
|
expect(adapter.deleteEdge).toHaveBeenCalledWith(
|
||||||
edges[0],
|
edges[0],
|
||||||
jasmine.any(Function)
|
jasmine.any(Function)
|
||||||
);
|
);
|
||||||
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the connect control', function() {
|
describe('the connect control', function() {
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
cont.offsetWidth,
|
cont.offsetWidth,
|
||||||
cont.offsetHeight,
|
cont.offsetHeight,
|
||||||
{
|
{
|
||||||
type: "preview",
|
type: "preview",
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height
|
||||||
},
|
},
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
ui;
|
ui;
|
||||||
spy.shapes = oldShapes;
|
spy.shapes = oldShapes;
|
||||||
|
|
||||||
ui = new GraphViewerPreview(cont, config);
|
ui = new GraphViewerPreview(cont, config);
|
||||||
expect(window.NodeShaper).wasCalledWith(
|
expect(window.NodeShaper).wasCalledWith(
|
||||||
jasmine.any(Object),
|
jasmine.any(Object),
|
||||||
{
|
{
|
||||||
|
@ -494,4 +494,4 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue