tree picker disable pick

This commit is contained in:
Niels Lyngsø
2024-08-29 10:49:37 +02:00
parent 8a5d347b86
commit e52ad54540
2 changed files with 9 additions and 1 deletions

View File

@@ -20,6 +20,9 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
selection: [],
};
@state()
_hasSelection: boolean = false;
@state()
_createPath?: string;
@@ -34,6 +37,9 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
constructor() {
super();
this.#pickerContext.selection.setSelectable(true);
this.observe(this.#pickerContext.selection.hasSelection, (hasSelection) => {
this._hasSelection = hasSelection;
});
this.#observePickerSelection();
this.#observeSearch();
}
@@ -188,7 +194,8 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
label=${this.localize.term('general_choose')}
look="primary"
color="positive"
@click=${this._submitModal}></uui-button>
@click=${this._submitModal}
?disabled=${!this._hasSelection}></uui-button>
</div>
`;
}

View File

@@ -13,6 +13,7 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
#selection = new UmbArrayState(<Array<ValueType>>[], (x) => x);
public readonly selection = this.#selection.asObservable();
public readonly hasSelection = this.#selection.asObservablePart((x) => x.length > 0);
#multiple = new UmbBooleanState(false);
public readonly multiple = this.#multiple.asObservable();