mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Etemplate: Fix some load bugs
- tabs got doLoadingFinished() multiple times if tablist was modified by data - selectbox with cached options did not load correctly first time
This commit is contained in:
parent
a41865209c
commit
9128d15bb2
@ -24,6 +24,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_menulist = exports.et2_selectbox_ro = exports.et2_selectbox = void 0;
|
||||
/*egw:uses
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
/api/js/jquery/chosen/chosen.jquery.js;
|
||||
@ -497,6 +498,7 @@ var et2_selectbox = /** @class */ (function (_super) {
|
||||
}
|
||||
else if (jQuery.isEmptyObject(this.options.select_options)) {
|
||||
this.egw().debug("warn", "Can't set value to '%s', widget has no options set", _value, this);
|
||||
this.value = null;
|
||||
}
|
||||
else {
|
||||
var debug_value = _value;
|
||||
@ -769,13 +771,13 @@ 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.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) {
|
||||
if (this.value === null && this.options.value) {
|
||||
// Null means it tried to set the value, and it got stripped by missing options
|
||||
this.set_value(this.options.value, true);
|
||||
}
|
||||
else 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
|
||||
}
|
||||
};
|
||||
et2_selectbox.prototype.getValue = function () {
|
||||
var value = [];
|
||||
|
@ -688,6 +688,7 @@ export class et2_selectbox extends et2_inputWidget
|
||||
else if (jQuery.isEmptyObject(this.options.select_options))
|
||||
{
|
||||
this.egw().debug("warn", "Can't set value to '%s', widget has no options set",_value, this);
|
||||
this.value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1031,15 +1032,15 @@ 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.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)
|
||||
if (this.value === null && this.options.value)
|
||||
{
|
||||
// Null means it tried to set the value, and it got stripped by missing options
|
||||
this.set_value(this.options.value, true);
|
||||
}
|
||||
else 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
|
||||
}
|
||||
}
|
||||
|
||||
getValue() : string[] | string
|
||||
|
@ -202,6 +202,9 @@ var et2_tabbox = /** @class */ (function (_super) {
|
||||
var tabs = this;
|
||||
// Specially process the selected index so it shows up right away
|
||||
this._loadTab(this.selected_index, promises);
|
||||
// Avoid reloading if tabs were modified by data
|
||||
if (this.isInTree() && this.isAttached())
|
||||
return;
|
||||
// Apply parent now, which actually puts into the DOM
|
||||
// This has to be before loading the child, so the dom sub-tree is not
|
||||
// disconnected, which causes problems for things like CKEditor
|
||||
@ -233,6 +236,8 @@ var et2_tabbox = /** @class */ (function (_super) {
|
||||
var tabData = this.tabData[index];
|
||||
if (!tabData || tabData.loaded)
|
||||
return;
|
||||
// Set loaded flag to not do this again, even if not fully done
|
||||
tabData.loaded = true;
|
||||
if (tabData.XMLNode != null) {
|
||||
if (tabData.hidden) {
|
||||
// Set hidden tab to readonly, so widgets aren't active
|
||||
@ -247,8 +252,6 @@ var et2_tabbox = /** @class */ (function (_super) {
|
||||
else if (tabData.widget_options) {
|
||||
tabData.widget = et2_core_widget_1.et2_createWidget('template', tabData.widget_options, this);
|
||||
}
|
||||
// Set loaded flag to not do this again, even if not fully done
|
||||
tabData.loaded = true;
|
||||
// loadingFinished() will be called either when the promise from doLoadingFinished is resolved,
|
||||
// or during the normal execution
|
||||
};
|
||||
|
@ -256,6 +256,9 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e
|
||||
// Specially process the selected index so it shows up right away
|
||||
this._loadTab(this.selected_index,promises);
|
||||
|
||||
// Avoid reloading if tabs were modified by data
|
||||
if(this.isInTree() && this.isAttached()) return;
|
||||
|
||||
// Apply parent now, which actually puts into the DOM
|
||||
// This has to be before loading the child, so the dom sub-tree is not
|
||||
// disconnected, which causes problems for things like CKEditor
|
||||
@ -291,6 +294,10 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e
|
||||
{
|
||||
var tabData = this.tabData[index];
|
||||
if(!tabData || tabData.loaded) return;
|
||||
|
||||
// Set loaded flag to not do this again, even if not fully done
|
||||
tabData.loaded = true;
|
||||
|
||||
if(tabData.XMLNode != null)
|
||||
{
|
||||
if(tabData.hidden)
|
||||
@ -311,8 +318,6 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e
|
||||
tabData.widget = et2_createWidget('template',tabData.widget_options,this);
|
||||
}
|
||||
|
||||
// Set loaded flag to not do this again, even if not fully done
|
||||
tabData.loaded = true;
|
||||
|
||||
// loadingFinished() will be called either when the promise from doLoadingFinished is resolved,
|
||||
// or during the normal execution
|
||||
|
Loading…
Reference in New Issue
Block a user