Api: Fix Et2TreeDropdown lazy-load / initial load still conflicted after 2e469a00de

This commit is contained in:
nathan 2024-11-12 13:59:19 -07:00
parent 5be31ead6c
commit f05c0880c0
2 changed files with 29 additions and 3 deletions

View File

@ -42,8 +42,23 @@ export type TreeItemData = SelectOption & {
nocheckbox: number | Boolean, nocheckbox: number | Boolean,
open: 0 | 1, open: 0 | 1,
parent: String, /**
text: String, * @deprecated Use "value"
*/
id : string,
/**
* @deprecated No longer used, the nested data structure is used instead
*/
parent : string,
/**
* @deprecated Use "label"
*/
text : string,
/**
* @deprecated Use "children"
*/
item : object[],
tooltip: String, tooltip: String,
userdata: any[] userdata: any[]
//here we can store the number of unread messages, if there are any //here we can store the number of unread messages, if there are any
@ -1028,7 +1043,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
parentNode.open = false; parentNode.open = false;
this.requestUpdate("lazy", "true"); this.requestUpdate("lazy", "true");
} }
this.getDomNode(parentNode.id).loading = false this.getDomNode(parentNode.id ?? parentNode.value).loading = false
this.requestUpdate("_selectOptions") this.requestUpdate("_selectOptions")
}) })

View File

@ -161,6 +161,17 @@ export class Et2TreeDropdown extends SearchMixin<Constructor<any> & Et2InputWidg
document.addEventListener("click", this.handleDocumentClick); document.addEventListener("click", this.handleDocumentClick);
} }
firstUpdated()
{
let options = this.multiple || !this.emptyLabel ? this.select_options : [{
value: "",
label: this.emptyLabel
}, ...this.select_options];
this._tree._selectOptions = <TreeItemData[]>options;
this._tree.requestUpdate("_selectOptions");
}
disconnectedCallback() disconnectedCallback()
{ {
super.disconnectedCallback(); super.disconnectedCallback();