Fix splitter widget did not restore size from preference

Two problems:
1.  Preference was stored as percent which splitter did not like to load directly
2.  Etemplate was triggering the final finish-up, which triggered resize(), which stored the default as preference before the splitter got to its _init_splitter(),
This commit is contained in:
nathan 2022-03-29 09:16:19 -06:00
parent 632ab571db
commit 763ed85668
2 changed files with 91 additions and 80 deletions

View File

@ -161,10 +161,12 @@ export class et2_split extends et2_DOMWidget implements et2_IResizeable, et2_IPr
super.doLoadingFinished();
// Not done yet, but widget will let you know
return new Promise((resolve) => {
let p = new Promise((resolve) =>
{
// Use a timeout to give the children a chance to finish
window.setTimeout(() => this._init_splitter(resolve), 1);
});
return p;
}
/**
@ -216,13 +218,18 @@ export class et2_split extends et2_DOMWidget implements et2_IResizeable, et2_IPr
let pref = this.egw().preference('splitter-size-' + this.id, this.egw().getAppName());
if(pref)
{
if(this.orientation == "v" && pref['sizeLeft'] < this.dynheight.outerNode.width() ||
this.orientation == "h" && pref['sizeTop'] < this.dynheight.outerNode.height())
// Change from percent back to numeric
if(typeof pref.sizeLeft !== "undefined")
{
pref.sizeLeft = ((parseFloat(pref.sizeLeft) / 100) * widget.dynheight.outerNode.width());
}
if(typeof pref.sizeTop !== "undefined")
{
pref.sizeTop = ((parseFloat(pref.sizeTop) / 100) * widget.dynheight.outerNode.height());
}
options = jQuery.extend(options, pref);
this.prefSize = pref[this.orientation == "v" ? 'sizeLeft' : 'sizeTop'];
}
}
// If there is no preference yet, set it to half size
// Otherwise the right pane gets the fullsize
if (typeof this.prefSize == 'undefined' || !this.prefSize)

View File

@ -646,7 +646,10 @@ export class etemplate2
egw.window.console.groupEnd();
}
// Wait for everything to be loaded, then finish it up
// Wait for everything to be loaded, then finish it up. Use timeout to give anything else a chance
// to run.
setTimeout(() =>
{
Promise.all(deferred).then(() =>
{
egw.debug("log", "Finished loading %s, triggering load event", _name);
@ -734,6 +737,7 @@ export class etemplate2
gen_time_div.append('<span class="et2RenderTime">' + egw.lang('eT2 rendering took %1s', '' + ((end_time - start_time) / 1000)) + '</span>');
}
});
});
};