mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: A add new node button is now contained in the toolbox
This commit is contained in:
parent
cbebd8e7ac
commit
8a8dde506f
|
@ -39,7 +39,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe('Event Dispatcher UI', function () {
|
describe('Event Dispatcher UI', function () {
|
||||||
var svg, dispatcher, dispatcherUI, list,
|
var svg, dispatcherUI, list,
|
||||||
nodeShaper, edgeShaper, layouter,
|
nodeShaper, edgeShaper, layouter,
|
||||||
nodes, edges, adapter,
|
nodes, edges, adapter,
|
||||||
mousePointerbox,
|
mousePointerbox,
|
||||||
|
@ -149,6 +149,7 @@
|
||||||
spyOn(nodeShaper, "changeTo").andCallThrough();
|
spyOn(nodeShaper, "changeTo").andCallThrough();
|
||||||
spyOn(edgeShaper, "changeTo").andCallThrough();
|
spyOn(edgeShaper, "changeTo").andCallThrough();
|
||||||
|
|
||||||
|
|
||||||
this.addMatchers({
|
this.addMatchers({
|
||||||
toBeTag: function(name) {
|
toBeTag: function(name) {
|
||||||
var item = this.actual;
|
var item = this.actual;
|
||||||
|
@ -207,6 +208,57 @@
|
||||||
}).toThrow("The EdgeShaper has to be given.");
|
}).toThrow("The EdgeShaper has to be given.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be able to add a new node control to the list', function() {
|
||||||
|
runs(function() {
|
||||||
|
dispatcherUI.addControlNewNode();
|
||||||
|
|
||||||
|
expect($("#control_event_list #control_event_newnode").length).toEqual(1);
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", "control_event_newnode");
|
||||||
|
|
||||||
|
expect(nodeShaper.changeTo).toHaveBeenCalledWith({
|
||||||
|
actions: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(edgeShaper.changeTo).toHaveBeenCalledWith({
|
||||||
|
actions: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mousePointerbox.className).toEqual("mousepointer icon-plus-sign");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", "svg");
|
||||||
|
|
||||||
|
expect($("#control_event_new_node_modal").length).toEqual(1);
|
||||||
|
|
||||||
|
//$("#control_event_node_edit_name_value").val("Bob");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", "control_event_new_node_submit");
|
||||||
|
|
||||||
|
expect(adapter.createNode).toHaveBeenCalledWith(
|
||||||
|
{},
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
/*
|
||||||
|
expect(adapter.createNode).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
name: "Bob"
|
||||||
|
},
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
waitsFor(function() {
|
||||||
|
return $("#control_event_node_edit_modal").length === 0;
|
||||||
|
}, 2000, "The modal dialog should disappear.");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should be able to add a drag control to the list', function() {
|
it('should be able to add a drag control to the list', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
dispatcherUI.addControlDrag();
|
dispatcherUI.addControlDrag();
|
||||||
|
@ -476,6 +528,7 @@
|
||||||
expect($("#control_event_list #control_event_expand").length).toEqual(1);
|
expect($("#control_event_list #control_event_expand").length).toEqual(1);
|
||||||
expect($("#control_event_list #control_event_delete").length).toEqual(1);
|
expect($("#control_event_list #control_event_delete").length).toEqual(1);
|
||||||
expect($("#control_event_list #control_event_connect").length).toEqual(1);
|
expect($("#control_event_list #control_event_connect").length).toEqual(1);
|
||||||
|
expect($("#control_event_list #control_event_newnode").length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,32 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
||||||
cursorIconBox.style.display = "block";
|
cursorIconBox.style.display = "block";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addControlNewNode = function() {
|
||||||
|
var prefix = "control_event_newnode",
|
||||||
|
idprefix = prefix + "_",
|
||||||
|
icon = "plus-sign",
|
||||||
|
createCallback = function(n) {
|
||||||
|
modalDialogHelper.createModalEditDialog(
|
||||||
|
"Create New Node",
|
||||||
|
"control_event_new_node_",
|
||||||
|
{},
|
||||||
|
function(data) {
|
||||||
|
dispatcher.events.CREATENODE(data, function() {
|
||||||
|
$("#control_event_new_node_modal").modal('hide');
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
callback = function() {
|
||||||
|
setCursorIcon(icon);
|
||||||
|
rebindNodes();
|
||||||
|
rebindEdges();
|
||||||
|
rebindSVG({click: createCallback});
|
||||||
|
};
|
||||||
|
createIcon(icon, "newnode", callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.addControlDrag = function() {
|
this.addControlDrag = function() {
|
||||||
var prefix = "control_event_drag",
|
var prefix = "control_event_drag",
|
||||||
idprefix = prefix + "_",
|
idprefix = prefix + "_",
|
||||||
|
@ -256,6 +282,7 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
||||||
self.addControlExpand();
|
self.addControlExpand();
|
||||||
self.addControlDelete();
|
self.addControlDelete();
|
||||||
self.addControlConnect();
|
self.addControlConnect();
|
||||||
|
self.addControlNewNode();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue