mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: New attribtues can now be added in the dialog
This commit is contained in:
parent
efbd8c673f
commit
2c56f211f3
|
@ -360,6 +360,53 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be possible to add new attributes to nodes', function() {
|
||||||
|
|
||||||
|
runs(function() {
|
||||||
|
var nested = JSON.stringify(edges[0]._data.nested);
|
||||||
|
helper.simulateMouseEvent("click", id);
|
||||||
|
helper.simulateMouseEvent("click", "1");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", nodeId + "_new");
|
||||||
|
|
||||||
|
expect($("#" + nodeId + "_new_1_delete").length).toEqual(1);
|
||||||
|
expect($("#" + nodeId + "_new_1_key").length).toEqual(1);
|
||||||
|
expect($("#" + nodeId + "_new_1_value").length).toEqual(1);
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", nodeId + "_new");
|
||||||
|
|
||||||
|
expect($("#" + nodeId + "_new_2_delete").length).toEqual(1);
|
||||||
|
expect($("#" + nodeId + "_new_2_key").length).toEqual(1);
|
||||||
|
expect($("#" + nodeId + "_new_2_value").length).toEqual(1);
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", nodeId + "_new_2_delete");
|
||||||
|
|
||||||
|
expect($("#" + nodeId + "_new_2_delete").length).toEqual(0);
|
||||||
|
expect($("#" + nodeId + "_new_2_key").length).toEqual(0);
|
||||||
|
expect($("#" + nodeId + "_new_2_value").length).toEqual(0);
|
||||||
|
|
||||||
|
$("#" + nodeId + "_new_1_key").val("newKey");
|
||||||
|
$("#" + nodeId + "_new_1_value").val("newVal");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", nodeId + "_submit");
|
||||||
|
|
||||||
|
expect(adapter.patchNode).toHaveBeenCalledWith(
|
||||||
|
nodes[0],
|
||||||
|
{
|
||||||
|
name: "Alice",
|
||||||
|
newKey: "newVal"
|
||||||
|
},
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function() {
|
||||||
|
return $("#" + nodeId + "_modal").length === 0;
|
||||||
|
}, 2000, "The modal dialog should disappear.");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should be possible to delete values from nodes', function() {
|
it('should be possible to delete values from nodes', function() {
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
|
@ -439,6 +486,53 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be possible to add new attributes to edges', function() {
|
||||||
|
|
||||||
|
runs(function() {
|
||||||
|
var nested = JSON.stringify(edges[0]._data.nested);
|
||||||
|
helper.simulateMouseEvent("click", id);
|
||||||
|
helper.simulateMouseEvent("click", "1-2");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", edgeId + "_new");
|
||||||
|
|
||||||
|
expect($("#" + edgeId + "_new_1_delete").length).toEqual(1);
|
||||||
|
expect($("#" + edgeId + "_new_1_key").length).toEqual(1);
|
||||||
|
expect($("#" + edgeId + "_new_1_value").length).toEqual(1);
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", edgeId + "_new");
|
||||||
|
|
||||||
|
expect($("#" + edgeId + "_new_2_delete").length).toEqual(1);
|
||||||
|
expect($("#" + edgeId + "_new_2_key").length).toEqual(1);
|
||||||
|
expect($("#" + edgeId + "_new_2_value").length).toEqual(1);
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", edgeId + "_new_2_delete");
|
||||||
|
|
||||||
|
expect($("#" + edgeId + "_new_2_delete").length).toEqual(0);
|
||||||
|
expect($("#" + edgeId + "_new_2_key").length).toEqual(0);
|
||||||
|
expect($("#" + edgeId + "_new_2_value").length).toEqual(0);
|
||||||
|
|
||||||
|
$("#" + edgeId + "_new_1_key").val("newKey");
|
||||||
|
$("#" + edgeId + "_new_1_value").val("newVal");
|
||||||
|
|
||||||
|
helper.simulateMouseEvent("click", edgeId + "_submit");
|
||||||
|
|
||||||
|
expect(adapter.patchEdge).toHaveBeenCalledWith(
|
||||||
|
edges[0],
|
||||||
|
{
|
||||||
|
label: "oldLabel",
|
||||||
|
nested: nested,
|
||||||
|
newKey: "newVal"
|
||||||
|
},
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function() {
|
||||||
|
return $("#" + edgeId + "_modal").length === 0;
|
||||||
|
}, 2000, "The modal dialog should disappear.");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should be possible to remove attributes from edges', function() {
|
it('should be possible to remove attributes from edges', function() {
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
|
|
|
@ -38,18 +38,41 @@ var modalDialogHelper = modalDialogHelper || {};
|
||||||
callbackCapsule = function() {
|
callbackCapsule = function() {
|
||||||
callback(tableToJSON);
|
callback(tableToJSON);
|
||||||
},
|
},
|
||||||
table = modalDialogHelper.modalDivTemplate(title, buttonTitle, idprefix, callbackCapsule);
|
table = modalDialogHelper.modalDivTemplate(title, buttonTitle, idprefix, callbackCapsule),
|
||||||
|
firstRow = document.createElement("tr"),
|
||||||
|
firstCell = document.createElement("th"),
|
||||||
|
addRow = document.createElement("button"),
|
||||||
|
addImg = document.createElement("img"),
|
||||||
|
newCounter = 1,
|
||||||
|
insertRow;
|
||||||
|
|
||||||
tableToJSON = function() {
|
tableToJSON = function() {
|
||||||
var result = {};
|
var result = {};
|
||||||
_.each($("#" + idprefix + "table tr"), function(tr) {
|
_.each($("#" + idprefix + "table tr:not(#first_row)"), function(tr) {
|
||||||
var key = tr.children[1].children[0].value,
|
var key = tr.children[1].children[0].value,
|
||||||
value = tr.children[2].children[0].value;
|
value = tr.children[2].children[0].value;
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
_.each(object, function(value, key) {
|
|
||||||
|
table.appendChild(firstRow);
|
||||||
|
firstRow.className = "collectionTh";
|
||||||
|
firstRow.id = "first_row";
|
||||||
|
firstRow.appendChild(firstCell);
|
||||||
|
firstCell.colSpan = "3";
|
||||||
|
firstCell.appendChild(addRow);
|
||||||
|
|
||||||
|
addRow.id = idprefix + "new";
|
||||||
|
addRow.className = "enabled";
|
||||||
|
|
||||||
|
addRow.appendChild(addImg);
|
||||||
|
addImg.className = "plusIcon";
|
||||||
|
addImg.src = "img/plus_icon.png";
|
||||||
|
addImg.width = "16";
|
||||||
|
addImg.height = "16";
|
||||||
|
|
||||||
|
insertRow = function(value, key) {
|
||||||
var internalRegex = /^_(id|rev|key|from|to)/,
|
var internalRegex = /^_(id|rev|key|from|to)/,
|
||||||
tr = document.createElement("tr"),
|
tr = document.createElement("tr"),
|
||||||
actTh = document.createElement("th"),
|
actTh = document.createElement("th"),
|
||||||
|
@ -59,7 +82,6 @@ var modalDialogHelper = modalDialogHelper || {};
|
||||||
keyInput,
|
keyInput,
|
||||||
valueInput,
|
valueInput,
|
||||||
delImg;
|
delImg;
|
||||||
|
|
||||||
if (internalRegex.test(key)) {
|
if (internalRegex.test(key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,10 +118,21 @@ var modalDialogHelper = modalDialogHelper || {};
|
||||||
valueInput = document.createElement("input");
|
valueInput = document.createElement("input");
|
||||||
valueInput.type = "text";
|
valueInput.type = "text";
|
||||||
valueInput.id = idprefix + key + "_value";
|
valueInput.id = idprefix + key + "_value";
|
||||||
valueInput.value = JSON.stringify(value);
|
if ("object" === typeof value) {
|
||||||
valueTh.appendChild(valueInput);
|
valueInput.value = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
valueInput.value = value;
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
valueTh.appendChild(valueInput);
|
||||||
|
};
|
||||||
|
|
||||||
|
addRow.onclick = function() {
|
||||||
|
insertRow("", "new_" + newCounter);
|
||||||
|
newCounter++;
|
||||||
|
};
|
||||||
|
|
||||||
|
_.each(object, insertRow);
|
||||||
$("#" + idprefix + "modal").modal('show');
|
$("#" + idprefix + "modal").modal('show');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue