- LSformElement_select_object : Correction bugs

This commit is contained in:
Benjamin Renard 2008-11-06 12:01:55 +00:00
parent 8849d59f5f
commit 6db507ba6c
2 changed files with 21 additions and 9 deletions

View file

@ -57,7 +57,8 @@ class LSformElement_select_object extends LSformElement {
'addBtn' => _('Modifier'), 'addBtn' => _('Modifier'),
'deleteBtns' => _('Supprimer'), 'deleteBtns' => _('Supprimer'),
'multiple' => (($this -> params['multiple'])?1:0), 'multiple' => (($this -> params['multiple'])?1:0),
'noValueLabel' => _('Aucun objet') 'noValueLabel' => _('Aucune valeur definie'),
'noResultLabel' => _('Aucun résultat')
) )
); );

View file

@ -134,9 +134,20 @@ var LSformElement_select_object_field = new Class({
}, },
clearUl: function() { clearUl: function() {
if (this.params.multiple) {
this.ul.getElements('li.LSformElement_select_object').each(function(li){ this.ul.getElements('li.LSformElement_select_object').each(function(li){
li.destroy(); li.destroy();
}); });
}
else {
var a = this.ul.getElement('a.LSformElement_select_object');
if ($type(a)) {
a.set('html',this.params.noValueLabel);
a.removeClass('LSformElement_select_object_deleted');
var input = this.ul.getElement('input.LSformElement_select_object');
input.value = "";
}
}
}, },
clearUlIfNoValue: function() { clearUlIfNoValue: function() {
@ -146,7 +157,7 @@ var LSformElement_select_object_field = new Class({
}, },
addLi: function(name,dn) { addLi: function(name,dn) {
if (this.params.multiple) { if (this.params.multiple) { // Multiple
var li = new Element('li'); var li = new Element('li');
li.addClass('LSformElement_select_object'); li.addClass('LSformElement_select_object');
@ -169,9 +180,9 @@ var LSformElement_select_object_field = new Class({
li.injectInside(this.ul); li.injectInside(this.ul);
} }
else { else { // Non Multiple
var a = this.ul.getElement('a'); var a = this.ul.getElement('a');
if ($type(a)) { if ($type(a)) { // Deja initialise
a.href="view.php?LSobject="+this.params['object_type']+"&dn="+dn; a.href="view.php?LSobject="+this.params['object_type']+"&dn="+dn;
a.set('html',name); a.set('html',name);
a.removeClass('LSformElement_select_object_deleted'); a.removeClass('LSformElement_select_object_deleted');
@ -182,7 +193,7 @@ var LSformElement_select_object_field = new Class({
name: this.name+'[]' name: this.name+'[]'
}); });
} }
else { else { // Non initialise (No Value)
this.ul.empty(); this.ul.empty();
var li = new Element('li'); var li = new Element('li');
@ -361,7 +372,7 @@ var LSformElement_select_object_field = new Class({
if (!$type(this.searchAddUl.getElement('li.LSformElement_select_object_searchAdd'))) { if (!$type(this.searchAddUl.getElement('li.LSformElement_select_object_searchAdd'))) {
var li = new Element('li'); var li = new Element('li');
li.addClass('LSformElement_select_object_searchAdd'); li.addClass('LSformElement_select_object_searchAdd');
li.set('html',this.params.noValueLabel); li.set('html',this.params.noResultLabel);
li.injectInside(this.searchAddUl); li.injectInside(this.searchAddUl);
} }
}, },