diff --git a/CHANGELOG b/CHANGELOG index e9897bf4bd..2ac7d7d1a3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js index c530b68373..efafd82a80 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js @@ -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 () { diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/collections/arangoDocument.js b/js/apps/system/_admin/aardvark/APP/frontend/js/collections/arangoDocument.js index c7c25b737b..3e1b45ccea 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/collections/arangoDocument.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/collections/arangoDocument.js @@ -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, diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/documentView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/documentView.js index 1c702b9897..258abd1f82 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/documentView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/documentView.js @@ -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); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js index 04aad5c804..4746087d2c 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js @@ -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); },