mirror of https://gitee.com/bigwinds/arangodb
cleanup + arangoHelper
This commit is contained in:
parent
c9a15b5ad5
commit
205ed128c0
|
@ -1,61 +1,60 @@
|
|||
/*global functions */
|
||||
arangoHelper = {
|
||||
systemAttributes: function () {
|
||||
return {
|
||||
'_id' : true,
|
||||
'_rev' : true,
|
||||
'_key' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'_bidirectional' : true,
|
||||
'_vertices' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'$id' : true
|
||||
};
|
||||
},
|
||||
|
||||
function systemAttributes () {
|
||||
return {
|
||||
'_id' : true,
|
||||
'_rev' : true,
|
||||
'_key' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'_bidirectional' : true,
|
||||
'_vertices' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'$id' : true
|
||||
};
|
||||
}
|
||||
isSystemAttribute: function (val) {
|
||||
var a = this.systemAttributes();
|
||||
return a[val];
|
||||
},
|
||||
|
||||
function isSystemAttribute (val) {
|
||||
var a = systemAttributes();
|
||||
return a[val];
|
||||
}
|
||||
isSystemCollection: function (val) {
|
||||
return val && val.name && val.name.substr(0, 1) === '_';
|
||||
},
|
||||
|
||||
function isSystemCollection (val) {
|
||||
return val && val.name && val.name.substr(0, 1) === '_';
|
||||
}
|
||||
collectionApiType: function (identifier) {
|
||||
if (CollectionTypes[identifier] == undefined) {
|
||||
CollectionTypes[identifier] = getCollectionInfo(identifier).type;
|
||||
}
|
||||
|
||||
function collectionApiType (identifier) {
|
||||
if (CollectionTypes[identifier] == undefined) {
|
||||
CollectionTypes[identifier] = getCollectionInfo(identifier).type;
|
||||
if (CollectionTypes[identifier] == 3) {
|
||||
return "edge";
|
||||
}
|
||||
return "document";
|
||||
},
|
||||
|
||||
collectionType: function (val) {
|
||||
if (! val || val.name == '') {
|
||||
return "-";
|
||||
}
|
||||
|
||||
var type;
|
||||
if (val.type == 2) {
|
||||
type = "document";
|
||||
}
|
||||
else if (val.type == 3) {
|
||||
type = "edge";
|
||||
}
|
||||
else {
|
||||
type = "unknown";
|
||||
}
|
||||
|
||||
if (isSystemCollection(val)) {
|
||||
type += " (system)";
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
if (CollectionTypes[identifier] == 3) {
|
||||
return "edge";
|
||||
}
|
||||
return "document";
|
||||
}
|
||||
|
||||
function collectionType (val) {
|
||||
if (! val || val.name == '') {
|
||||
return "-";
|
||||
}
|
||||
|
||||
var type;
|
||||
if (val.type == 2) {
|
||||
type = "document";
|
||||
}
|
||||
else if (val.type == 3) {
|
||||
type = "edge";
|
||||
}
|
||||
else {
|
||||
type = "unknown";
|
||||
}
|
||||
|
||||
if (isSystemCollection(val)) {
|
||||
type += " (system)";
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -7,10 +7,6 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
return model.get('name').toLowerCase();
|
||||
},
|
||||
|
||||
isSystemCollection : function (name) {
|
||||
return name.substr(0, 1) === '_';
|
||||
},
|
||||
|
||||
translateStatus : function (status) {
|
||||
if (status == 2) {
|
||||
return 'unloaded';
|
||||
|
@ -23,7 +19,7 @@ window.arangoCollections = Backbone.Collection.extend({
|
|||
var that = this;
|
||||
|
||||
$.each(response.collections, function(key, val) {
|
||||
val.isSystem = that.isSystemCollection(val.name);
|
||||
val.isSystem = arangoHelper.isSystemCollection(val.name);
|
||||
val.status = that.translateStatus(val.status);
|
||||
});
|
||||
return response.collections;
|
||||
|
|
|
@ -26,7 +26,7 @@ window.arangoDocument = Backbone.Collection.extend({
|
|||
},
|
||||
addDocument: function (collectionID) {
|
||||
var self = this;
|
||||
var doctype = self.collectionApiType(collectionID);
|
||||
var doctype = arangoHelper.collectionApiType(collectionID);
|
||||
if (doctype === 'edge') {
|
||||
alert("adding edge not implemented");
|
||||
return false;
|
||||
|
@ -50,16 +50,6 @@ window.arangoDocument = Backbone.Collection.extend({
|
|||
}
|
||||
});
|
||||
},
|
||||
collectionApiType: function (identifier) {
|
||||
if (this.CollectionTypes[identifier] == undefined) {
|
||||
this.CollectionTypes[identifier] = this.getCollectionInfo(identifier).type;
|
||||
}
|
||||
|
||||
if (this.CollectionTypes[identifier] == 3) {
|
||||
return "edge";
|
||||
}
|
||||
return "document";
|
||||
},
|
||||
getCollectionInfo: function (identifier) {
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ var documentSourceView = Backbone.View.extend({
|
|||
var data = arangoDocumentStore.models[0].attributes;
|
||||
var model = [];
|
||||
$.each(data, function(key, val) {
|
||||
if (isSystemAttribute(key) === true) {
|
||||
if (arangoHelper.isSystemAttribute(key) === true) {
|
||||
delete data[key];
|
||||
}
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ var documentView = Backbone.View.extend({
|
|||
drawTable: function () {
|
||||
var self = this;
|
||||
$.each(window.arangoDocumentStore.models[0].attributes, function(key, value) {
|
||||
if (self.isSystemAttribute(key)) {
|
||||
if (arangoHelper.isSystemAttribute(key)) {
|
||||
$(self.table).dataTable().fnAddData([
|
||||
key,
|
||||
self.value2html(value, true),
|
||||
|
@ -101,30 +101,6 @@ var documentView = Backbone.View.extend({
|
|||
});
|
||||
},
|
||||
|
||||
systemAttributes: function () {
|
||||
return {
|
||||
'_id' : true,
|
||||
'_rev' : true,
|
||||
'_key' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'_bidirectional' : true,
|
||||
'_vertices' : true,
|
||||
'_from' : true,
|
||||
'_to' : true,
|
||||
'$id' : true
|
||||
};
|
||||
},
|
||||
|
||||
isSystemAttribute: function (val) {
|
||||
var a = this.systemAttributes();
|
||||
return a[val];
|
||||
},
|
||||
|
||||
isSystemCollection: function (val) {
|
||||
return val && val.name && val.name.substr(0, 1) === '_';
|
||||
},
|
||||
|
||||
value2html: function (value, isReadOnly) {
|
||||
var self = this;
|
||||
var typify = function (value) {
|
||||
|
@ -172,7 +148,7 @@ var documentView = Backbone.View.extend({
|
|||
$(this).removeClass('writeable');
|
||||
i = 0;
|
||||
}
|
||||
if (self.isSystemAttribute(this.innerHTML)) {
|
||||
if (arangoHelper.isSystemAttribute(this.innerHTML)) {
|
||||
$(this).removeClass('writeable');
|
||||
i = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue