mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-30 11:53:57 +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
121008379b
commit
b74e44ca6f
@ -752,7 +752,7 @@ var et2_selectbox = /** @class */ (function (_super) {
|
|||||||
this.input.trigger("liszt:updated");
|
this.input.trigger("liszt:updated");
|
||||||
}
|
}
|
||||||
// Sometimes value gets set before options
|
// 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
|
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) {
|
else if (this.value === null && this.options.value) {
|
||||||
@ -761,18 +761,17 @@ var et2_selectbox = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
et2_selectbox.prototype.getValue = function () {
|
et2_selectbox.prototype.getValue = function () {
|
||||||
|
var value = [];
|
||||||
if (this.input == null) {
|
if (this.input == null) {
|
||||||
var value = [];
|
|
||||||
jQuery("input:checked", this.multiOptions).each(function () { value.push(this.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
|
// 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 {
|
else {
|
||||||
this.value = _super.prototype.getValue.call(this);
|
value = _super.prototype.getValue.call(this);
|
||||||
if (this.value === null)
|
if (value === null)
|
||||||
this.value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
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 () {
|
et2_selectbox.prototype.isDirty = function () {
|
||||||
if (this.input == null) {
|
if (this.input == null) {
|
||||||
|
@ -1010,7 +1010,7 @@ export class et2_selectbox extends et2_inputWidget
|
|||||||
this.input.trigger("liszt:updated");
|
this.input.trigger("liszt:updated");
|
||||||
}
|
}
|
||||||
// Sometimes value gets set before options
|
// 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
|
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)
|
if(this.input == null)
|
||||||
{
|
{
|
||||||
var value = [];
|
|
||||||
jQuery("input:checked",this.multiOptions).each(function(){value.push(this.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
|
// 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
|
else
|
||||||
{
|
{
|
||||||
this.value = super.getValue();
|
value = super.getValue();
|
||||||
if (this.value === null) this.value = this.options.multiple ? [] : ""; // do NOT return null, as it does not get transmitted to server
|
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()
|
isDirty()
|
||||||
|
Loading…
Reference in New Issue
Block a user