mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Fixed several tests that did fail
This commit is contained in:
parent
70996d3401
commit
a2a9194b1e
|
@ -28,9 +28,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
svg.graphViewer text {
|
svg.graphViewer text {
|
||||||
font: 11px Arial;
|
font: 12px Arial;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
stroke: #000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.capitalize {
|
.capitalize {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||||
/*global _, $, window*/
|
/*global _, $, window, d3*/
|
||||||
/*global EventLibrary*/
|
/*global EventLibrary*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Graph functionality
|
/// @brief Graph functionality
|
||||||
|
|
|
@ -214,14 +214,14 @@ function NodeShaper(parent, flags, idfunc) {
|
||||||
if (_.isFunction(width)) {
|
if (_.isFunction(width)) {
|
||||||
translateX = function(d) {
|
translateX = function(d) {
|
||||||
return -(width(d) / 2);
|
return -(width(d) / 2);
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
translateX = -(width / 2);
|
translateX = -(width / 2);
|
||||||
}
|
}
|
||||||
if (_.isFunction(height)) {
|
if (_.isFunction(height)) {
|
||||||
translateY = function(d) {
|
translateY = function(d) {
|
||||||
return -(height(d) / 2);
|
return -(height(d) / 2);
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
translateY = -(height / 2);
|
translateY = -(height / 2);
|
||||||
}
|
}
|
||||||
|
@ -245,14 +245,16 @@ function NodeShaper(parent, flags, idfunc) {
|
||||||
addLabel = function (node) {
|
addLabel = function (node) {
|
||||||
node.append("text") // Append a label for the node
|
node.append("text") // Append a label for the node
|
||||||
.attr("text-anchor", "middle") // Define text-anchor
|
.attr("text-anchor", "middle") // Define text-anchor
|
||||||
.attr("stroke", "black") // Foce a black color20*75)
|
.attr("fill", "black") // Force a black color
|
||||||
|
.attr("stroke", "none") // Make it readable
|
||||||
.text(label);
|
.text(label);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
addLabel = function (node) {
|
addLabel = function (node) {
|
||||||
node.append("text") // Append a label for the node
|
node.append("text") // Append a label for the node
|
||||||
.attr("text-anchor", "middle") // Define text-anchor
|
.attr("text-anchor", "middle") // Define text-anchor
|
||||||
.attr("stroke", "black") // Foce a black color20*75)
|
.attr("fill", "black") // Force a black color
|
||||||
|
.attr("stroke", "none") // Make it readable
|
||||||
.text(function(d) {
|
.text(function(d) {
|
||||||
return d._data[label] !== undefined ? d._data[label] : "";
|
return d._data[label] !== undefined ? d._data[label] : "";
|
||||||
});
|
});
|
||||||
|
|
|
@ -291,8 +291,6 @@
|
||||||
expect(adapter.patchEdge).toHaveBeenCalledWith(
|
expect(adapter.patchEdge).toHaveBeenCalledWith(
|
||||||
edges[0],
|
edges[0],
|
||||||
{
|
{
|
||||||
_from: "1",
|
|
||||||
_to: "2",
|
|
||||||
label: "newLabel"
|
label: "newLabel"
|
||||||
},
|
},
|
||||||
jasmine.any(Function));
|
jasmine.any(Function));
|
||||||
|
@ -425,22 +423,27 @@
|
||||||
helper.simulateMouseEvent("mousedown", "2");
|
helper.simulateMouseEvent("mousedown", "2");
|
||||||
|
|
||||||
expect(edgeShaper.addAnEdgeFollowingTheCursor).toHaveBeenCalledWith(
|
expect(edgeShaper.addAnEdgeFollowingTheCursor).toHaveBeenCalledWith(
|
||||||
0, 0
|
-$("svg").offset().left, -$("svg").offset().top
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('the cursor-line should follow the cursor on mousemove over svg', function() {
|
it('the cursor-line should follow the cursor on mousemove over svg', function() {
|
||||||
dispatcherUI.addControlConnect();
|
dispatcherUI.addControlConnect();
|
||||||
|
var x = 40,
|
||||||
|
y= 50,
|
||||||
|
line;
|
||||||
|
|
||||||
helper.simulateMouseEvent("click", "control_event_connect");
|
helper.simulateMouseEvent("click", "control_event_connect");
|
||||||
helper.simulateMouseEvent("mousedown", "2");
|
helper.simulateMouseEvent("mousedown", "2");
|
||||||
|
|
||||||
helper.simulateMouseMoveEvent("svg", 40, 50);
|
helper.simulateMouseMoveEvent("svg", x, y);
|
||||||
|
|
||||||
var line = $("#connectionLine");
|
line = $("#connectionLine");
|
||||||
expect(line.attr("x1")).toEqual(String(nodes[1].x));
|
//The Helper event triggers at (0,0) no matter where the node is.
|
||||||
expect(line.attr("y1")).toEqual(String(nodes[1].y));
|
expect(line.attr("x1")).toEqual(String(- $("svg").offset().left));
|
||||||
expect(line.attr("x2")).toEqual("40");
|
expect(line.attr("y1")).toEqual(String(- $("svg").offset().top));
|
||||||
expect(line.attr("y2")).toEqual("50");
|
expect(line.attr("x2")).toEqual(String(x - $("svg").offset().left));
|
||||||
|
expect(line.attr("y2")).toEqual(String(y - $("svg").offset().top));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('the cursor-line should disappear on mouseup on svg', function() {
|
it('the cursor-line should disappear on mouseup on svg', function() {
|
||||||
|
|
|
@ -679,6 +679,23 @@
|
||||||
expect($("svg .node text")[0].textContent).toEqual("MyLabel");
|
expect($("svg .node text")[0].textContent).toEqual("MyLabel");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set up the text element correctly', function() {
|
||||||
|
var node = [{
|
||||||
|
_id: 1,
|
||||||
|
_data: {
|
||||||
|
"label": "MyLabel"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
textEl;
|
||||||
|
shaper.drawNodes(node);
|
||||||
|
textEl = $("svg .node text");
|
||||||
|
expect(textEl.attr("fill")).toEqual("black");
|
||||||
|
expect(textEl.attr("stroke")).toEqual("none");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should ignore other attributes', function () {
|
it('should ignore other attributes', function () {
|
||||||
var nodes = [
|
var nodes = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -225,8 +225,8 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
||||||
setCursorIcon(icon);
|
setCursorIcon(icon);
|
||||||
rebindNodes({
|
rebindNodes({
|
||||||
mousedown: dispatcher.events.STARTCREATEEDGE(function(startNode, ev) {
|
mousedown: dispatcher.events.STARTCREATEEDGE(function(startNode, ev) {
|
||||||
var pos = getCursorPositionInSVG(ev);
|
var pos = getCursorPositionInSVG(ev),
|
||||||
var moveCB = edgeShaper.addAnEdgeFollowingTheCursor(pos.x, pos.y);
|
moveCB = edgeShaper.addAnEdgeFollowingTheCursor(pos.x, pos.y);
|
||||||
dispatcher.bind("svg", "mousemove", function(ev) {
|
dispatcher.bind("svg", "mousemove", function(ev) {
|
||||||
var pos = getCursorPositionInSVG(ev);
|
var pos = getCursorPositionInSVG(ev);
|
||||||
moveCB(pos.x, pos.y);
|
moveCB(pos.x, pos.y);
|
||||||
|
|
|
@ -169,20 +169,26 @@ var modalDialogHelper = modalDialogHelper || {};
|
||||||
|
|
||||||
tableToJSON = function() {
|
tableToJSON = function() {
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
||||||
_.each($("#" + idprefix + "table tr"), function(tr) {
|
_.each($("#" + idprefix + "table tr"), function(tr) {
|
||||||
var key = tr.children[0].children[0].value,
|
var key = tr.children[0].children[0].value,
|
||||||
value = tr.children[1].children[0].value;
|
value = tr.children[1].children[0].value;
|
||||||
|
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
_.each(object, function(value, key) {
|
_.each(object, function(value, key) {
|
||||||
var tr = document.createElement("tr"),
|
var internalRegex = /^_(id|rev|key|from|to)/,
|
||||||
|
tr = document.createElement("tr"),
|
||||||
keyTh = document.createElement("th"),
|
keyTh = document.createElement("th"),
|
||||||
valueTh = document.createElement("th"),
|
valueTh = document.createElement("th"),
|
||||||
keyInput,
|
keyInput,
|
||||||
valueInput;
|
valueInput;
|
||||||
|
|
||||||
|
if (internalRegex.test(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
table.appendChild(tr);
|
table.appendChild(tr);
|
||||||
tr.appendChild(keyTh);
|
tr.appendChild(keyTh);
|
||||||
keyTh.className = "collectionTh";
|
keyTh.className = "collectionTh";
|
||||||
|
|
Loading…
Reference in New Issue