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