1
0
Fork 0

the graph viewer now displays updated label values correctly (#3763)

This commit is contained in:
Heiko 2017-11-30 11:49:49 +01:00 committed by Jan
parent a005aca3e7
commit e3277a493c
5 changed files with 68 additions and 6 deletions

View File

@ -1,6 +1,10 @@
devel
-----
* UI: the graph viewer now displays updated label values correctly.
Additionally the included node/edge editor now closes automatically
after a successful node/edge update.
* UI: document/edge editor now remembering their modes (e.g. code or tree)
* UI: optimized error messages for invalid graph definitions. Also fixed a

View File

@ -646,7 +646,13 @@
docFrameView.customDeleteFunction = function () {
window.modalView.hide();
$('.arangoFrame').hide();
// callback()
};
docFrameView.customSaveFunction = function (data) {
self.closeDocEditor();
if (callback) {
callback(data);
}
};
$('.arangoFrame #deleteDocumentButton').click(function () {

View File

@ -184,7 +184,7 @@ window.ArangoDocument = Backbone.Collection.extend({
$.ajax({
cache: false,
type: 'PUT',
url: arangoHelper.databaseUrl('/_api/document/' + encodeURIComponent(colid)),
url: arangoHelper.databaseUrl('/_api/document/' + encodeURIComponent(colid) + '?returnNew=true'),
data: JSON.stringify([model]),
contentType: 'application/json',
processData: false,

View File

@ -121,7 +121,9 @@
deleteDocument: function () {
var successFunction = function () {
if (this.customView) {
this.customDeleteFunction();
if (this.customDeleteFunction) {
this.customDeleteFunction();
}
} else {
var navigateTo = 'collection/' + encodeURIComponent(this.colid) + '/documents/1';
window.modalView.hide();
@ -290,6 +292,7 @@
},
confirmSaveDocument: function () {
var self = this;
window.modalView.hide();
var model;
@ -311,6 +314,12 @@
} else {
this.successConfirmation();
this.disableSaveButton();
if (self.customView) {
if (self.customSaveFunction) {
self.customSaveFunction(data);
}
}
}
}.bind(this);
@ -322,6 +331,12 @@
} else {
this.successConfirmation();
this.disableSaveButton();
if (self.customView) {
if (self.customSaveFunction) {
self.customSaveFunction(data);
}
}
}
}.bind(this);

View File

@ -1729,16 +1729,53 @@
},
editNode: function (id) {
var callback = function (a, b) {
};
var callback = function (data) {
this.updateNodeLabel(data);
}.bind(this);
arangoHelper.openDocEditor(id, 'doc', callback);
},
updateNodeLabel: function (data) {
var id = data[0]._id;
if (this.graphConfig.nodeLabel) {
var oldLabel = this.currentGraph.graph.nodes(id).label;
if (oldLabel !== data[0][this.graphConfig.nodeLabel]) {
var newLabel = data[0]['new'][this.graphConfig.nodeLabel];
if (typeof newLabel === 'string') {
this.currentGraph.graph.nodes(id).label = newLabel;
} else {
this.currentGraph.graph.nodes(id).label = JSON.stringify(newLabel);
}
this.currentGraph.refresh({ skipIndexation: true });
}
}
},
editEdge: function (id) {
var callback = function () {};
var callback = function (data) {
this.updateEdgeLabel(data);
}.bind(this);
arangoHelper.openDocEditor(id, 'edge', callback);
},
updateEdgeLabel: function (data) {
var id = data[0]._id;
if (this.graphConfig.edgeLabel) {
var oldLabel = this.currentGraph.graph.edges(id).label;
if (oldLabel !== data[0][this.graphConfig.edgeLabel]) {
var newLabel = data[0]['new'][this.graphConfig.edgeLabel];
if (typeof newLabel === 'string') {
this.currentGraph.graph.edges(id).label = newLabel;
} else {
this.currentGraph.graph.edges(id).label = JSON.stringify(newLabel);
}
this.currentGraph.refresh({ skipIndexation: true });
}
}
},
reloadGraph: function () {
Backbone.history.loadUrl(Backbone.history.fragment);
},