tree picker disable pick
This commit is contained in:
@@ -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>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user