1
0
Fork 0

edit graph

This commit is contained in:
gschwab 2014-06-26 11:07:35 +02:00
parent 1d53c8841f
commit c941cfa76c
1 changed files with 78 additions and 19 deletions

View File

@ -58,7 +58,7 @@
this.collection.fetch(); this.collection.fetch();
this.graphToEdit = this.evaluateGraphName($(e.currentTarget).attr("id"), '_settings'); this.graphToEdit = this.evaluateGraphName($(e.currentTarget).attr("id"), '_settings');
var graph = this.collection.findWhere({_key: this.graphToEdit}); var graph = this.collection.findWhere({_key: this.graphToEdit});
this.createEditGraphModal(this.graphToEdit, graph.get("vertices"), graph.get("edges")); this.createEditGraphModal(this.graphToEdit, graph.get("edgeDefinitions"), graph.get("orphanCollections"));
}, },
info : function(e) { info : function(e) {
@ -73,6 +73,10 @@
); );
}, },
saveEditedGraph: function() {
},
evaluateGraphName : function(str, substr) { evaluateGraphName : function(str, substr) {
var index = str.lastIndexOf(substr); var index = str.lastIndexOf(substr);
return str.substring(0, index); return str.substring(0, index);
@ -171,9 +175,13 @@
}); });
}, },
createEditGraphModal: function(name, vertices, edges) { createEditGraphModal: function(name, edgeDefinitions, orphanCollections) {
var buttons = [], var buttons = [],
tableContent = []; tableContent = [],
maxIndex;
this.counter = 0;
window.modalView.disableSubmitOnEnter = true;
tableContent.push( tableContent.push(
window.modalView.createReadOnlyEntry( window.modalView.createReadOnlyEntry(
@ -183,28 +191,79 @@
false false
) )
); );
tableContent.push(
window.modalView.createReadOnlyEntry( edgeDefinitions.forEach(
"editVertices", function(edgeDefinition, index) {
"Vertices", maxIndex = index;
vertices, tableContent.push(
false window.modalView.createSelect2Entry(
) "newEdgeDefinitions" + index,
); "Edge definitions",
tableContent.push( edgeDefinition.collection,
window.modalView.createReadOnlyEntry( "Some info for edge definitions",
"editEdges", "Edge definitions",
"Edges", true,
edges, false,
false true,
) 1
)
);
tableContent.push(
window.modalView.createSelect2Entry(
"newFromCollections" + index,
"fromCollections",
edgeDefinition.from,
"The collection that contain the start vertices of the relation.",
"fromCollections",
true,
false,
false,
10
)
);
tableContent.push(
window.modalView.createSelect2Entry(
"newToCollections" + index,
"toCollections",
edgeDefinition.to,
"The collection that contain the end vertices of the relation.",
"toCollections",
true,
false,
false,
10
)
);
}
); );
tableContent.push(
window.modalView.createSelect2Entry(
"newVertexCollections",
"Vertex collections",
orphanCollections,
"Some info for vertex collections",
"Vertex Collections",
false
)
);
buttons.push( buttons.push(
window.modalView.createDeleteButton("Delete", this.deleteGraph.bind(this)) window.modalView.createDeleteButton("Delete", this.deleteGraph.bind(this))
); );
buttons.push(
window.modalView.createSuccessButton("Save", this.saveEditedGraph.bind(this))
);
window.modalView.show("modalTable.ejs", "Edit Graph", buttons, tableContent);
window.modalView.show(
"modalGraphTable.ejs", "Add new Graph", buttons, tableContent, null, this.events
);
var i;
for (i = 0; i <= maxIndex; i++) {
$('#row_newFromCollections' + i).hide();
$('#row_newToCollections' + i).hide();
}
}, },