Add method to check vocabulary / export datas

This commit is contained in:
Romain Neutron
2012-02-08 16:09:57 +01:00
parent 8443514b68
commit 9b9026b173

View File

@@ -1,12 +1,20 @@
(function( window ) { (function( window ) {
function checkVocabId(VocabularyId)
{
if(typeof VocabularyId === 'undefined')
VocabularyId = null;
if(VocabularyId === '')
VocabularyId = null;
return VocabularyId;
}
var recordFieldValue = function(meta_id, value, VocabularyId) { var recordFieldValue = function(meta_id, value, VocabularyId) {
if(typeof VocabularyId === 'undefined') VocabularyId = checkVocabId(VocabularyId);
{
VocabularyId = null;
}
this.datas = { this.datas = {
meta_id:meta_id, meta_id:meta_id,
@@ -28,11 +36,9 @@
return this.datas.VocabularyId; return this.datas.VocabularyId;
}, },
setValue : function(value, VocabularyId) { setValue : function(value, VocabularyId) {
if(typeof VocabularyId === 'undefined')
VocabularyId = null;
this.datas.value = value; this.datas.value = value;
this.datas.VocabularyId = VocabularyId; this.datas.VocabularyId = checkVocabId(VocabularyId);
return this; return this;
}, },
remove : function() { remove : function() {
@@ -179,8 +185,7 @@
}, },
addValue : function(value, merge, VocabularyId) { addValue : function(value, merge, VocabularyId) {
if(typeof VocabularyId === 'undefined') VocabularyId = checkVocabId(VocabularyId);
VocabularyId = null;
merge = !!merge; merge = !!merge;
@@ -279,8 +284,7 @@
} }
} }
if(typeof VocabularyId === 'undefined') VocabularyId = checkVocabId(VocabularyId);
VocabularyId = null;
for(d in this.datas) for(d in this.datas)
{ {
@@ -318,8 +322,7 @@
return; return;
} }
if(typeof VocabularyId === 'undefined') vocabularyId = checkVocabId(vocabularyId);
VocabularyId = null;
if(window.console) if(window.console)
{ {
@@ -475,6 +478,27 @@
*/ */
return this; return this;
},
exportDatas : function() {
var returnValue = new Array();
for(d in this.datas)
{
var temp = {
meta_id : this.datas[d].getMetaId() ? this.datas[d].getMetaId() : '',
meta_struct_id : this.getMetaStructId(),
value : this.datas[d].getValue()
};
if(this.datas[d].getVocabularyId())
{
temp.vocabularyId = this.datas[d].getVocabularyId();
}
returnValue.push(temp);
}
return returnValue;
} }
}; };