Jquery edit enhancements

This commit is contained in:
Romain Neutron
2012-01-20 18:48:04 +01:00
parent 7d98dc7f27
commit f4e03610cc

View File

@@ -33,6 +33,7 @@
},
remove : function() {
this.datas.value = '';
this.datas.VocabularyId = null;
return this;
}
@@ -182,6 +183,13 @@
this.datas.push(new recordFieldValue(null, value, VocabularyId));
this.options.dirty = true;
}
else
{
if(window.console)
{
console.log('already have ',value);
}
}
}
else
{
@@ -226,6 +234,7 @@
},
hasValue : function(value, VocabularyId) {
console.log('has value ', value, VocabularyId);
if(typeof value === 'undefined')
{
if(window.console)
@@ -237,19 +246,29 @@
for(d in this.datas)
{
if(this.datas[d].getVocabularyId() !== null && VocabularyId !== null)
if(VocabularyId !== null)
{
if(this.datas[d].getVocabularyId() === VocabularyId)
{
if(window.console)
{
console.log('already got the vocab ID');
}
return true;
}
}
else if(this.datas[d].getValue() == value)
else if(this.datas[d].getVocabularyId() === null && this.datas[d].getValue() == value)
{
if(window.console)
{
console.log('already got this value');
}
return true;
}
}
return false;
},
removeValue : function(value) {
removeValue : function(value, vocabularyId) {
if(this.databoxField.isReadonly())
{
@@ -258,10 +277,38 @@
return;
}
if(typeof VocabularyId === 'undefined')
VocabularyId = null;
if(window.console)
{
console.log('Try to remove value ', value, vocabularyId, this.datas);
}
for(d in this.datas)
{
if(this.datas[d].getValue() == value)
if(window.console)
{
console.log('loopin... ', this.datas[d].getValue());
}
if(this.datas[d].getVocabularyId() !== null)
{
if(this.datas[d].getVocabularyId() == vocabularyId)
{
if(window.console)
{
console.log('Found within the vocab ! removing... ');
}
this.datas[d].remove();
this.options.dirty = true;
}
}
else if(this.datas[d].getValue() == value)
{
if(window.console)
{
console.log('Found ! removing... ');
}
this.datas[d].remove();
this.options.dirty = true;
}
@@ -326,6 +373,11 @@
return arrayValues;
},
sort : function(algo) {
this.datas.sort(algo);
return this;
},
getSerializedValues : function() {
var arrayValues = [];