From 816e3dd90622c8890ed8d31433e7f2ba387811d6 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 22 Feb 2013 12:10:11 +0100 Subject: [PATCH] documentview editable bugfix --- frontend/js/arango/arango.js | 10 +++++++--- frontend/js/collections/arangoDocument.js | 6 +----- frontend/js/views/documentView.js | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/js/arango/arango.js b/frontend/js/arango/arango.js index bd3e0ed622..b26451dd51 100644 --- a/frontend/js/arango/arango.js +++ b/frontend/js/arango/arango.js @@ -1,4 +1,5 @@ arangoHelper = { + CollectionTypes: {}, systemAttributes: function () { return { '_id' : true, @@ -13,6 +14,9 @@ arangoHelper = { '$id' : true }; }, + getRandomToken: function () { + return Math.round(new Date().getTime()); + }, isSystemAttribute: function (val) { var a = this.systemAttributes(); @@ -25,11 +29,11 @@ arangoHelper = { }, collectionApiType: function (identifier) { - if (CollectionTypes[identifier] == undefined) { - CollectionTypes[identifier] = getCollectionInfo(identifier).type; + if (this.CollectionTypes[identifier] == undefined) { + this.CollectionTypes[identifier] = window.arangoDocumentStore.getCollectionInfo(identifier).type; } - if (CollectionTypes[identifier] == 3) { + if (this.CollectionTypes[identifier] == 3) { return "edge"; } return "document"; diff --git a/frontend/js/collections/arangoDocument.js b/frontend/js/collections/arangoDocument.js index 1e2e782e2f..90529acd60 100644 --- a/frontend/js/collections/arangoDocument.js +++ b/frontend/js/collections/arangoDocument.js @@ -2,7 +2,6 @@ window.arangoDocument = Backbone.Collection.extend({ url: '/_api/document/', model: arangoDocument, collectionInfo: {}, - CollectionTypes: {}, deleteDocument: function (collectionID){ var returnval = false; try { @@ -55,7 +54,7 @@ window.arangoDocument = Backbone.Collection.extend({ $.ajax({ type: "GET", - url: "/_api/collection/" + identifier + "?" + self.getRandomToken(), + url: "/_api/collection/" + identifier + "?" + arangoHelper.getRandomToken(), contentType: "application/json", processData: false, async: false, @@ -68,9 +67,6 @@ window.arangoDocument = Backbone.Collection.extend({ return self.collectionInfo; }, - getRandomToken: function () { - return Math.round(new Date().getTime()); - }, getDocument: function (colid, docid, view) { this.clearDocument(); var self = this; diff --git a/frontend/js/views/documentView.js b/frontend/js/views/documentView.js index a51114a59b..c80e3ada28 100644 --- a/frontend/js/views/documentView.js +++ b/frontend/js/views/documentView.js @@ -63,7 +63,7 @@ var documentView = Backbone.View.extend({ addLine: function () { $(this.table).dataTable().fnAddData([ - "somekey"+this.counter, + "key"+arangoHelper.getRandomToken(), this.value2html("editme"), JSON.stringify("editme"), 'edit', @@ -71,7 +71,8 @@ var documentView = Backbone.View.extend({ ]); this.makeEditable(); this.updateLocalDocumentStorage(); - this.counter++; + $(this.table).dataTable().fnClearTable(); + this.drawTable(); }, deleteLine: function (a) { @@ -156,7 +157,7 @@ var documentView = Backbone.View.extend({ $('.writeable', documentEditTable.fnGetNodes()).editable(function(value, settings) { var aPos = documentEditTable.fnGetPosition(this); if (aPos[1] == 0) { - documentEditTable.fnUpdate(value, aPos[0], aPos[0]); + documentEditTable.fnUpdate(value, aPos[0], aPos[1]); self.updateLocalDocumentStorage(); return value; }