LeafOnly selection of et2-tree now possible

et2-tree-dropdown can now also be leafOnly used e.g. in timezone preferences
This commit is contained in:
milan 2024-08-22 12:54:27 +02:00
parent c08555ee08
commit 0605f6c2f5
2 changed files with 23 additions and 4 deletions

View File

@ -98,7 +98,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
@property({type: Function})
onclick;// description: "JS code which gets executed when clicks on text of a node"
@property({type:String})
selection = "single"
leafOnly = false
//onselect and oncheck only appear in multiselectTree

View File

@ -81,15 +81,34 @@ export class Et2TreeDropdown extends SearchMixin<Constructor<any> & Et2InputWidg
@property({type: Object}) actions = {};
@property()
leafOnly:Boolean;
set leafOnly(_leafOnly: boolean)
{
this.updateComplete.then(() => {
const tree = this._tree
if (tree)
{
tree.leafOnly = _leafOnly;
tree.requestUpdate("leafOnly")
}
}
)
}
@state() currentTag: Et2Tag;
// We show search results in the same dropdown
@state() treeOrSearch : "tree" | "search" = "tree";
private get _popup() : SlPopup { return this.shadowRoot.querySelector("sl-popup")}
private get _tree() : Et2Tree { return this.shadowRoot.querySelector("et2-tree")}
private get _popup(): SlPopup
{
return this.shadowRoot?.querySelector("sl-popup")
}
private get _tree(): Et2Tree
{
return this.shadowRoot?.querySelector("et2-tree")
}
private get _tags() : Et2Tag[] { return Array.from(this.shadowRoot.querySelectorAll("et2-tag"));}