From f05c0880c00a45ffd09510c65b61364bf7208ce9 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 12 Nov 2024 13:59:19 -0700 Subject: [PATCH] Api: Fix Et2TreeDropdown lazy-load / initial load still conflicted after 2e469a00de3b0326a59066866bb6668dd92256f9 --- api/js/etemplate/Et2Tree/Et2Tree.ts | 21 ++++++++++++++++++--- api/js/etemplate/Et2Tree/Et2TreeDropdown.ts | 11 +++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 34a9dae462..44498d3545 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -42,8 +42,23 @@ export type TreeItemData = SelectOption & { nocheckbox: number | Boolean, 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, userdata: 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; this.requestUpdate("lazy", "true"); } - this.getDomNode(parentNode.id).loading = false + this.getDomNode(parentNode.id ?? parentNode.value).loading = false this.requestUpdate("_selectOptions") }) diff --git a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts index b46a973e6c..da23ce1606 100644 --- a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts +++ b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts @@ -161,6 +161,17 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg 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 = options; + this._tree.requestUpdate("_selectOptions"); + } + disconnectedCallback() { super.disconnectedCallback();