mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Etemplate: Fix multi-select / tags value sometimes got lost if we had to fetch options from the server
This commit is contained in:
parent
1ef16c9c55
commit
0df6306dc2
@ -752,7 +752,7 @@ var et2_selectbox = /** @class */ (function (_super) {
|
||||
this.input.trigger("liszt:updated");
|
||||
}
|
||||
// Sometimes value gets set before options
|
||||
if (this.value || this.options.empty_label || this.value === '' && this.input && this.input.children('[value=""]').length === 1) {
|
||||
if (this.value || (this.options.empty_label && !this.options.multiple) || this.value === '' && this.input && this.input.children('[value=""]').length === 1) {
|
||||
this.set_value(this.value, true); // true = dont try to set_options, to avoid an infinit recursion
|
||||
}
|
||||
else if (this.value === null && this.options.value) {
|
||||
@ -761,18 +761,17 @@ var et2_selectbox = /** @class */ (function (_super) {
|
||||
}
|
||||
};
|
||||
et2_selectbox.prototype.getValue = function () {
|
||||
var value = [];
|
||||
if (this.input == null) {
|
||||
var value = [];
|
||||
jQuery("input:checked", this.multiOptions).each(function () { value.push(this.value); });
|
||||
// we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side
|
||||
this.value = value;
|
||||
}
|
||||
else {
|
||||
this.value = _super.prototype.getValue.call(this);
|
||||
if (this.value === null)
|
||||
this.value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
||||
value = _super.prototype.getValue.call(this);
|
||||
if (value === null)
|
||||
value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
||||
}
|
||||
return this.value;
|
||||
return value;
|
||||
};
|
||||
et2_selectbox.prototype.isDirty = function () {
|
||||
if (this.input == null) {
|
||||
|
@ -1010,7 +1010,7 @@ export class et2_selectbox extends et2_inputWidget
|
||||
this.input.trigger("liszt:updated");
|
||||
}
|
||||
// Sometimes value gets set before options
|
||||
if(this.value || this.options.empty_label || this.value === '' && this.input && this.input.children('[value=""]').length === 1)
|
||||
if(this.value || (this.options.empty_label && !this.options.multiple) || this.value === '' && this.input && this.input.children('[value=""]').length === 1)
|
||||
{
|
||||
this.set_value(this.value, true); // true = dont try to set_options, to avoid an infinit recursion
|
||||
}
|
||||
@ -1021,21 +1021,20 @@ export class et2_selectbox extends et2_inputWidget
|
||||
}
|
||||
}
|
||||
|
||||
getValue()
|
||||
getValue() : string[] | string
|
||||
{
|
||||
let value: string[] | string = [];
|
||||
if(this.input == null)
|
||||
{
|
||||
var value = [];
|
||||
jQuery("input:checked",this.multiOptions).each(function(){value.push(this.value);});
|
||||
// we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side
|
||||
this.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.value = super.getValue();
|
||||
if (this.value === null) this.value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
||||
value = super.getValue();
|
||||
if (value === null) value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
||||
}
|
||||
return this.value;
|
||||
return value;
|
||||
}
|
||||
|
||||
isDirty()
|
||||
|
Loading…
Reference in New Issue
Block a user