umb-tree, adds flags to hide the tree-item's entity actions

This commit is contained in:
leekelleher
2024-04-12 11:42:01 +01:00
parent 545c613289
commit da4c5f4661
3 changed files with 19 additions and 3 deletions

View File

@@ -16,6 +16,9 @@ export class UmbDefaultTreeElement extends UmbLitElement {
@property({ type: Object, attribute: false })
selectionConfiguration: UmbTreeSelectionConfiguration = this._selectionConfiguration;
@property({ type: Boolean, attribute: false })
hideTreeItemActions: boolean = false;
@property({ type: Boolean, attribute: false })
hideTreeRoot: boolean = false;
@@ -94,7 +97,9 @@ export class UmbDefaultTreeElement extends UmbLitElement {
#renderTreeRoot() {
if (this.hideTreeRoot || this._treeRoot === undefined) return nothing;
return html`
<umb-tree-item .entityType=${this._treeRoot.entityType} .props=${{ item: this._treeRoot }}></umb-tree-item>
<umb-tree-item
.entityType=${this._treeRoot.entityType}
.props=${{ hideActions: this.hideTreeItemActions, item: this._treeRoot }}></umb-tree-item>
`;
}
@@ -105,7 +110,10 @@ export class UmbDefaultTreeElement extends UmbLitElement {
${repeat(
this._rootItems,
(item, index) => item.name + '___' + index,
(item) => html`<umb-tree-item .entityType=${item.entityType} .props=${{ item }}></umb-tree-item>`,
(item) =>
html`<umb-tree-item
.entityType=${item.entityType}
.props=${{ hideActions: this.hideTreeItemActions, item }}></umb-tree-item>`,
)}
${this.#renderPaging()}
`;

View File

@@ -16,6 +16,9 @@ export abstract class UmbTreeItemElementBase<TreeItemModelType extends UmbTreeIt
this.#initTreeItem();
}
@property({ type: Boolean, attribute: false })
hideActions: boolean = false;
@state()
private _isActive = false;
@@ -162,6 +165,7 @@ export abstract class UmbTreeItemElementBase<TreeItemModelType extends UmbTreeIt
}
#renderActions() {
if (this.hideActions) return;
return this.#treeItemContext && this._item
? html`<umb-entity-actions-bundle
slot="actions"
@@ -178,7 +182,10 @@ export abstract class UmbTreeItemElementBase<TreeItemModelType extends UmbTreeIt
? repeat(
this._childItems,
(item, index) => item.name + '___' + index,
(item) => html`<umb-tree-item .entityType=${item.entityType} .props=${{ item }}></umb-tree-item>`,
(item) =>
html`<umb-tree-item
.entityType=${item.entityType}
.props=${{ hideActions: this.hideActions, item }}></umb-tree-item>`,
)
: ''}
`;

View File

@@ -54,6 +54,7 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
<umb-tree
alias=${ifDefined(this.data?.treeAlias)}
.props=${{
hideTreeItemActions: true,
hideTreeRoot: this.data?.hideTreeRoot,
selectionConfiguration: this._selectionConfiguration,
filter: this.data?.filter,