mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: The NodeShaperUI is now able to generate the colour<-> label list.
This commit is contained in:
parent
2106e5f141
commit
70a5b0c0f9
|
@ -313,7 +313,7 @@
|
|||
|
||||
colorList = shaper.getColourMapping();
|
||||
|
||||
expect(_.keys(colorList)).toEqual(3);
|
||||
expect(_.keys(colorList).length).toEqual(3);
|
||||
_.each(_.values(colorList), function(v) {
|
||||
expect(v).toEqual(jasmine.any(Array));
|
||||
expect(v.length).toEqual(1);
|
||||
|
|
|
@ -50,27 +50,28 @@
|
|||
list.id = "control_node_list";
|
||||
shaperUI = new NodeShaperControls(list, shaper);
|
||||
spyOn(shaper, 'changeTo');
|
||||
spyOn(shaper, 'getColourMapping').andCallFake(function() {
|
||||
return {
|
||||
"blue": ["bl", "ue"],
|
||||
"green": ["gr", "een"]
|
||||
};
|
||||
});
|
||||
this.addMatchers({
|
||||
toBeTag: function(name) {
|
||||
var el = this.actual;
|
||||
this.message = function() {
|
||||
return "Expected " + el.tagName.toLowerCase() + " to be a " + name;
|
||||
};
|
||||
return el.tagName.toLowerCase() === name;
|
||||
},
|
||||
|
||||
toConformToListCSS: function() {
|
||||
var li = this.actual,
|
||||
a = li.firstChild,
|
||||
lbl = a.firstChild,
|
||||
msg = "";
|
||||
this.message = function() {
|
||||
return "Expected " + msg;
|
||||
};
|
||||
if (li === undefined || li.tagName.toLowerCase() !== "li") {
|
||||
msg = "first element to be a li";
|
||||
return false;
|
||||
}
|
||||
if (a === undefined || a.tagName.toLowerCase() !== "a") {
|
||||
msg = "first element to be a a";
|
||||
return false;
|
||||
}
|
||||
if (lbl === undefined || lbl.tagName.toLowerCase() !== "label") {
|
||||
msg = "first element to be a label";
|
||||
return false;
|
||||
}
|
||||
lbl = a.firstChild;
|
||||
expect(li).toBeTag("li");
|
||||
expect(a).toBeTag("a");
|
||||
expect(lbl).toBeTag("label");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -262,7 +263,6 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
it('should be able to add a switch colour on attribute control to the list', function() {
|
||||
runs(function() {
|
||||
shaperUI.addControlOpticLabelAndColour();
|
||||
|
@ -289,7 +289,6 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
it('should be able to add all optic controls to the list', function () {
|
||||
shaperUI.addAllOptics();
|
||||
|
||||
|
@ -318,6 +317,25 @@
|
|||
expect($("#control_node_list #control_node_attributecolour").length).toEqual(1);
|
||||
expect($("#control_node_list #control_node_expandcolour").length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should be able to create a div containing the color <-> label mapping', function() {
|
||||
var div = shaperUI.createColourMappingList(),
|
||||
list = div.firstChild,
|
||||
blue = list.children[0],
|
||||
green = list.children[1];
|
||||
expect(shaper.getColourMapping).wasCalled();
|
||||
expect(div).toBeTag("div");
|
||||
expect(list).toBeTag("ul");
|
||||
expect(blue).toBeTag("li");
|
||||
expect($(blue).text()).toEqual("bl, ue");
|
||||
expect(blue.style.backgroundColor).toEqual("blue");
|
||||
|
||||
expect(green).toBeTag("li");
|
||||
expect($(green).text()).toEqual("gr, een");
|
||||
expect(green.style.backgroundColor).toEqual("green");
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
|
@ -241,4 +241,21 @@ function NodeShaperControls(list, shaper) {
|
|||
self.addAllActions();
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Colour Mapping List
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
this.createColourMappingList = function() {
|
||||
var div = document.createElement("div"),
|
||||
list = document.createElement("ul"),
|
||||
mapping = shaper.getColourMapping();
|
||||
div.appendChild(list);
|
||||
_.each(mapping, function(els, col) {
|
||||
var li = document.createElement("li");
|
||||
li.style.backgroundColor = col;
|
||||
li.appendChild(document.createTextNode(els.join(", ")));
|
||||
list.appendChild(li);
|
||||
});
|
||||
return div;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue