mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-27 23:51:30 +01:00
Fix some legacy parent issues where parent DOM node was not found when needed
- Checking & waiting for promises - Could not get DOM nodes from nm header sub-templates
This commit is contained in:
parent
ed66beaf8f
commit
7b11a25b8d
@ -603,32 +603,42 @@ const Et2WidgetMixin = (superClass) =>
|
|||||||
*
|
*
|
||||||
* @param {Promise[]} promises List of promises from widgets that are not done. Pass an empty array, it will be filled if needed.
|
* @param {Promise[]} promises List of promises from widgets that are not done. Pass an empty array, it will be filled if needed.
|
||||||
*/
|
*/
|
||||||
loadingFinished(promises)
|
loadingFinished(promises : Promise<any>[])
|
||||||
{
|
{
|
||||||
/**
|
// Note that WebComponents don't do anything here, their lifecycle is different
|
||||||
* This is needed mostly as a bridge between non-WebComponent widgets and
|
// This is just to support legacy widgets
|
||||||
* connectedCallback(). It's not really needed if the whole tree is WebComponent.
|
let doLoadingFinished = () =>
|
||||||
* WebComponents can be added as children immediately after creation, and they handle the
|
|
||||||
* rest themselves with their normal lifecycle (especially connectedCallback(), which is kind
|
|
||||||
* of the equivalent of doLoadingFinished()
|
|
||||||
*/
|
|
||||||
if(this.getParent() instanceof et2_widget && (<et2_DOMWidget>this.getParent()).getDOMNode(this) != this.parentNode)
|
|
||||||
{
|
{
|
||||||
this.getParent().getDOMNode(this).append(this);
|
/**
|
||||||
}
|
* This is needed mostly as a bridge between non-WebComponent widgets and
|
||||||
|
* connectedCallback(). It's not really needed if the whole tree is WebComponent.
|
||||||
|
* WebComponents can be added as children immediately after creation, and they handle the
|
||||||
|
* rest themselves with their normal lifecycle (especially connectedCallback(), which is kind
|
||||||
|
* of the equivalent of doLoadingFinished()
|
||||||
|
*/
|
||||||
|
if(this.getParent() instanceof et2_widget && (<et2_DOMWidget>this.getParent()).getDOMNode(this) != this.parentNode)
|
||||||
|
{
|
||||||
|
this.getParent().getDOMNode(this).append(this);
|
||||||
|
}
|
||||||
|
|
||||||
// An empty text node causes problems with legacy widget children
|
// An empty text node causes problems with legacy widget children
|
||||||
// It throws off their insertion indexing, making them get added in the wrong place
|
// It throws off their insertion indexing, making them get added in the wrong place
|
||||||
if(this.childNodes[0]?.nodeType == this.TEXT_NODE)
|
if(this.childNodes[0]?.nodeType == this.TEXT_NODE)
|
||||||
{
|
{
|
||||||
this.removeChild(this.childNodes[0]);
|
this.removeChild(this.childNodes[0]);
|
||||||
}
|
}
|
||||||
for(let i = 0; i < this.getChildren().length; i++)
|
for(let i = 0; i < this.getChildren().length; i++)
|
||||||
{
|
{
|
||||||
let child = this.getChildren()[i];
|
let child = this.getChildren()[i];
|
||||||
|
|
||||||
child.loadingFinished(promises);
|
child.loadingFinished(promises);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if(typeof promises === "undefined")
|
||||||
|
{
|
||||||
|
return doLoadingFinished();
|
||||||
}
|
}
|
||||||
|
Promise.all(promises).then(doLoadingFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWidgetById(_id)
|
getWidgetById(_id)
|
||||||
|
@ -3848,14 +3848,31 @@ export class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INext
|
|||||||
return this.filter_div[0];
|
return this.filter_div[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_sender == this.et2_searchbox) return this.search_box[0];
|
if(_sender == this.et2_searchbox)
|
||||||
if(_sender.id == 'export') return this.right_div[0];
|
{
|
||||||
|
return this.search_box[0];
|
||||||
|
}
|
||||||
|
if(_sender.id == 'export')
|
||||||
|
{
|
||||||
|
return this.right_div[0];
|
||||||
|
}
|
||||||
|
|
||||||
if(_sender && _sender._type == "template")
|
if(_sender && _sender._type == "template")
|
||||||
{
|
{
|
||||||
for(let i = 0; i < this.headers.length; i++)
|
for(let i = 0; i < this.headers.length; i++)
|
||||||
{
|
{
|
||||||
if(_sender.id == this.headers[i].id && _sender._parent == this) return i == 2 ? this.header_row[0] : this.header_div[0];
|
if(_sender.id == this.headers[i].id && _sender._parent == this)
|
||||||
|
{
|
||||||
|
return i == 2 ? this.header_row[0] : this.header_div[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let header of this.headers)
|
||||||
|
{
|
||||||
|
if(header && header.getDOMNode && header.getDOMNode(this))
|
||||||
|
{
|
||||||
|
return header.getDOMNode(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -945,6 +945,7 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
|
|||||||
const cell = this.managementArray[i];
|
const cell = this.managementArray[i];
|
||||||
if(cell.widget)
|
if(cell.widget)
|
||||||
{
|
{
|
||||||
|
this.removeChild(cell.widget);
|
||||||
cell.widget.destroy();
|
cell.widget.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user