1
0
Fork 0

documentview editable bugfix

This commit is contained in:
Heiko Kernbach 2013-02-22 12:10:11 +01:00
parent 3ecf22cfd6
commit 816e3dd906
3 changed files with 12 additions and 11 deletions

View File

@ -1,4 +1,5 @@
arangoHelper = { arangoHelper = {
CollectionTypes: {},
systemAttributes: function () { systemAttributes: function () {
return { return {
'_id' : true, '_id' : true,
@ -13,6 +14,9 @@ arangoHelper = {
'$id' : true '$id' : true
}; };
}, },
getRandomToken: function () {
return Math.round(new Date().getTime());
},
isSystemAttribute: function (val) { isSystemAttribute: function (val) {
var a = this.systemAttributes(); var a = this.systemAttributes();
@ -25,11 +29,11 @@ arangoHelper = {
}, },
collectionApiType: function (identifier) { collectionApiType: function (identifier) {
if (CollectionTypes[identifier] == undefined) { if (this.CollectionTypes[identifier] == undefined) {
CollectionTypes[identifier] = getCollectionInfo(identifier).type; this.CollectionTypes[identifier] = window.arangoDocumentStore.getCollectionInfo(identifier).type;
} }
if (CollectionTypes[identifier] == 3) { if (this.CollectionTypes[identifier] == 3) {
return "edge"; return "edge";
} }
return "document"; return "document";

View File

@ -2,7 +2,6 @@ window.arangoDocument = Backbone.Collection.extend({
url: '/_api/document/', url: '/_api/document/',
model: arangoDocument, model: arangoDocument,
collectionInfo: {}, collectionInfo: {},
CollectionTypes: {},
deleteDocument: function (collectionID){ deleteDocument: function (collectionID){
var returnval = false; var returnval = false;
try { try {
@ -55,7 +54,7 @@ window.arangoDocument = Backbone.Collection.extend({
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/_api/collection/" + identifier + "?" + self.getRandomToken(), url: "/_api/collection/" + identifier + "?" + arangoHelper.getRandomToken(),
contentType: "application/json", contentType: "application/json",
processData: false, processData: false,
async: false, async: false,
@ -68,9 +67,6 @@ window.arangoDocument = Backbone.Collection.extend({
return self.collectionInfo; return self.collectionInfo;
}, },
getRandomToken: function () {
return Math.round(new Date().getTime());
},
getDocument: function (colid, docid, view) { getDocument: function (colid, docid, view) {
this.clearDocument(); this.clearDocument();
var self = this; var self = this;

View File

@ -63,7 +63,7 @@ var documentView = Backbone.View.extend({
addLine: function () { addLine: function () {
$(this.table).dataTable().fnAddData([ $(this.table).dataTable().fnAddData([
"somekey"+this.counter, "key"+arangoHelper.getRandomToken(),
this.value2html("editme"), this.value2html("editme"),
JSON.stringify("editme"), JSON.stringify("editme"),
'edit', 'edit',
@ -71,7 +71,8 @@ var documentView = Backbone.View.extend({
]); ]);
this.makeEditable(); this.makeEditable();
this.updateLocalDocumentStorage(); this.updateLocalDocumentStorage();
this.counter++; $(this.table).dataTable().fnClearTable();
this.drawTable();
}, },
deleteLine: function (a) { deleteLine: function (a) {
@ -156,7 +157,7 @@ var documentView = Backbone.View.extend({
$('.writeable', documentEditTable.fnGetNodes()).editable(function(value, settings) { $('.writeable', documentEditTable.fnGetNodes()).editable(function(value, settings) {
var aPos = documentEditTable.fnGetPosition(this); var aPos = documentEditTable.fnGetPosition(this);
if (aPos[1] == 0) { if (aPos[1] == 0) {
documentEditTable.fnUpdate(value, aPos[0], aPos[0]); documentEditTable.fnUpdate(value, aPos[0], aPos[1]);
self.updateLocalDocumentStorage(); self.updateLocalDocumentStorage();
return value; return value;
} }