supannCompositeAttribute: fix clearing value

This commit is contained in:
Benjamin Renard 2021-07-07 16:26:55 +02:00
parent 6e98cfef20
commit 3c02b94085
4 changed files with 231 additions and 219 deletions

View file

@ -19,11 +19,10 @@ var LSformElement_supannCompositeAttribute_field = new Class({
}, },
clearValue: function() { clearValue: function() {
console.log('clear');
console.log(this.values);
if (this.values.length>1) { if (this.values.length>1) {
for(var i=1; i<=this.values.length; i++) { for(var i=1; i<=this.values.length; i++) {
$(this.values[i].li).dispose(); $(this.values[i].li).dispose();
delete this.values[i];
} }
this.values[0].clear(); this.values[0].clear();
} }

View file

@ -4,12 +4,19 @@ var LSformElement_supannCompositeAttribute_field_value_component = new Class({
this.field_name = field_name; this.field_name = field_name;
this.name = name; this.name = name;
this.params = varLSdefault.LSjsConfig[this.field_name]; this.params = varLSdefault.LSjsConfig[this.field_name];
this.cconf = this.params.components[this.name];
if (this.cconf.type == 'select') {
this.select = p.getElement('select');
}
else if (['date', 'text'].includes(this.cconf.type)) {
this.input = p.getElement('input');
}
else if (['table', 'codeEntite', 'parrainDN'].includes(this.cconf.type)) {
this.input = p.getElement('input'); this.input = p.getElement('input');
this.img = p.getElement('img'); this.img = p.getElement('img');
this.span = p.getElement('span'); this.span = p.getElement('span');
if (['table', 'codeEntite', 'parrainDN'].includes(this.params.components[this.name].type)) {
this.inputSearch=new Element( this.inputSearch=new Element(
'input', 'input',
{ {
@ -97,7 +104,6 @@ var LSformElement_supannCompositeAttribute_field_value_component = new Class({
this._possibleValues.injectInside(this.p); this._possibleValues.injectInside(this.p);
} }
var ul=new Element('ul'); var ul=new Element('ul');
possibleValues.each(function(v) { possibleValues.each(function(v) {
var li=new Element( var li=new Element(
@ -161,13 +167,20 @@ var LSformElement_supannCompositeAttribute_field_value_component = new Class({
}, },
clear: function() { clear: function() {
if (this.cconf.type == 'select') {
this.select.set('value', '');
}
else if (['date', 'text'].includes(this.cconf.type)) {
this.input.set('value', '');
}
else if (['table', 'codeEntite', 'parrainDN'].includes(this.cconf.type)) {
this.input.set('value', '');
if (this.img) { if (this.img) {
this.img.dispose(); this.img.dispose();
this.img=null; this.img=null;
} }
this.input.set('value','');
if (this.span) {
this.span.set('html', this.params.noValueLabel); this.span.set('html', this.params.noValueLabel);
this.span.set('title', '');
} }
} }
}); });