diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 01d49413ad..dbf299a973 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -1366,7 +1366,9 @@ export const Et2WithSearchMixin = dedupeMixin( */ protected searchMatch(search : string, option : SelectOption) : boolean { - if(!option || !option.value) + if(!option || !option.value || + // do NOT return folders, if leafOnly is set + this.leafOnly && typeof option.children === 'undefined') { return false; } diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 8b40b34eb5..0c90515986 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -97,7 +97,10 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin openIcon: String; @property({type: Function}) onclick;// description: "JS code which gets executed when clicks on text of a node" - @property({type:String}) + /** + * If true, only leafs (NOT folders) are selectable + */ + @property({type:Boolean}) leafOnly = false diff --git a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts index 95a35036f6..23151b4957 100644 --- a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts +++ b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts @@ -47,7 +47,6 @@ type Constructor = new (...args : any[]) => T; export class Et2TreeDropdown extends SearchMixin & Et2InputWidgetInterface & typeof LitElement, TreeSearchResult, TreeSearchResults>(Et2WidgetWithSelectMixin(LitElement)) { - static get styles() { return [ @@ -65,8 +64,9 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg /** The component's help text. If you need to display HTML, use the `help-text` slot instead. */ @property({attribute: 'help-text'}) helpText = ""; + /** "JSON URL or menuaction to be called for nodes marked with child=1, but not having children, getSelectedNode() contains node-id" */ @property({type: String}) - autoloading: string = "" //description: "JSON URL or menuaction to be called for nodes marked with child=1, but not having children, getSelectedNode() contains node-id" + autoloading: string = ""; /** * Indicates whether the dropdown is open. You can toggle this attribute to show and hide the tree, or you can @@ -80,6 +80,9 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg */ @property({type: Object}) actions = {}; + /** + * If true, only leafs (NOT folders) are selectable + */ @property() set leafOnly(_leafOnly: boolean) { @@ -94,6 +97,10 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg } ) } + get leafOnly() + { + return this._tree?.leafOnly; + } @state() currentTag: Et2Tag; diff --git a/api/js/etemplate/Et2Widget/SearchMixin.ts b/api/js/etemplate/Et2Widget/SearchMixin.ts index fb298bda5f..65b2245377 100644 --- a/api/js/etemplate/Et2Widget/SearchMixin.ts +++ b/api/js/etemplate/Et2Widget/SearchMixin.ts @@ -297,7 +297,9 @@ export const SearchMixin = (search : string, searchOptions : Object, option : DataType) : boolean { - if(!option || !option.value) + if(!option || !option.value || + // do NOT return folders, if leafOnly is set + this.leafOnly && typeof option.children !== 'undefined') { return false; }