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 {
|
||||
font: 11px Arial;
|
||||
font: 12px Arial;
|
||||
pointer-events: none;
|
||||
stroke: #000;
|
||||
}
|
||||
|
||||
.capitalize {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global _, $, window*/
|
||||
/*global _, $, window, d3*/
|
||||
/*global EventLibrary*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
|
|
|
@ -214,14 +214,14 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
if (_.isFunction(width)) {
|
||||
translateX = function(d) {
|
||||
return -(width(d) / 2);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
translateX = -(width / 2);
|
||||
}
|
||||
if (_.isFunction(height)) {
|
||||
translateY = function(d) {
|
||||
return -(height(d) / 2);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
translateY = -(height / 2);
|
||||
}
|
||||
|
@ -245,14 +245,16 @@ function NodeShaper(parent, flags, idfunc) {
|
|||
addLabel = function (node) {
|
||||
node.append("text") // Append a label for the node
|
||||
.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);
|
||||
};
|
||||
} else {
|
||||
addLabel = function (node) {
|
||||
node.append("text") // Append a label for the node
|
||||
.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) {
|
||||
return d._data[label] !== undefined ? d._data[label] : "";
|
||||
});
|
||||
|
|
|
@ -291,8 +291,6 @@
|
|||
expect(adapter.patchEdge).toHaveBeenCalledWith(
|
||||
edges[0],
|
||||
{
|
||||
_from: "1",
|
||||
_to: "2",
|
||||
label: "newLabel"
|
||||
},
|
||||
jasmine.any(Function));
|
||||
|
@ -425,22 +423,27 @@
|
|||
helper.simulateMouseEvent("mousedown", "2");
|
||||
|
||||
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() {
|
||||
dispatcherUI.addControlConnect();
|
||||
var x = 40,
|
||||
y= 50,
|
||||
line;
|
||||
|
||||
helper.simulateMouseEvent("click", "control_event_connect");
|
||||
helper.simulateMouseEvent("mousedown", "2");
|
||||
|
||||
helper.simulateMouseMoveEvent("svg", 40, 50);
|
||||
helper.simulateMouseMoveEvent("svg", x, y);
|
||||
|
||||
var line = $("#connectionLine");
|
||||
expect(line.attr("x1")).toEqual(String(nodes[1].x));
|
||||
expect(line.attr("y1")).toEqual(String(nodes[1].y));
|
||||
expect(line.attr("x2")).toEqual("40");
|
||||
expect(line.attr("y2")).toEqual("50");
|
||||
line = $("#connectionLine");
|
||||
//The Helper event triggers at (0,0) no matter where the node is.
|
||||
expect(line.attr("x1")).toEqual(String(- $("svg").offset().left));
|
||||
expect(line.attr("y1")).toEqual(String(- $("svg").offset().top));
|
||||
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() {
|
||||
|
|
|
@ -679,6 +679,23 @@
|
|||
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 () {
|
||||
var nodes = [
|
||||
{
|
||||
|
|
|
@ -225,8 +225,8 @@ function EventDispatcherControls(list, cursorIconBox, nodeShaper, edgeShaper, di
|
|||
setCursorIcon(icon);
|
||||
rebindNodes({
|
||||
mousedown: dispatcher.events.STARTCREATEEDGE(function(startNode, ev) {
|
||||
var pos = getCursorPositionInSVG(ev);
|
||||
var moveCB = edgeShaper.addAnEdgeFollowingTheCursor(pos.x, pos.y);
|
||||
var pos = getCursorPositionInSVG(ev),
|
||||
moveCB = edgeShaper.addAnEdgeFollowingTheCursor(pos.x, pos.y);
|
||||
dispatcher.bind("svg", "mousemove", function(ev) {
|
||||
var pos = getCursorPositionInSVG(ev);
|
||||
moveCB(pos.x, pos.y);
|
||||
|
|
|
@ -169,20 +169,26 @@ var modalDialogHelper = modalDialogHelper || {};
|
|||
|
||||
tableToJSON = function() {
|
||||
var result = {};
|
||||
|
||||
_.each($("#" + idprefix + "table tr"), function(tr) {
|
||||
var key = tr.children[0].children[0].value,
|
||||
value = tr.children[1].children[0].value;
|
||||
|
||||
result[key] = value;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
_.each(object, function(value, key) {
|
||||
var tr = document.createElement("tr"),
|
||||
keyTh = document.createElement("th"),
|
||||
valueTh = document.createElement("th"),
|
||||
keyInput,
|
||||
valueInput;
|
||||
|
||||
var internalRegex = /^_(id|rev|key|from|to)/,
|
||||
tr = document.createElement("tr"),
|
||||
keyTh = document.createElement("th"),
|
||||
valueTh = document.createElement("th"),
|
||||
keyInput,
|
||||
valueInput;
|
||||
|
||||
if (internalRegex.test(key)) {
|
||||
return;
|
||||
}
|
||||
table.appendChild(tr);
|
||||
tr.appendChild(keyTh);
|
||||
keyTh.className = "collectionTh";
|
||||
|
|
Loading…
Reference in New Issue