Bugfix: umb-input-entity to support min/max

This commit is contained in:
leekelleher
2024-04-12 10:25:22 +01:00
parent 5fcd39d3e2
commit 42d82ea342

View File

@@ -23,26 +23,30 @@ export class UmbInputEntityElement extends UUIFormControlMixin(UmbLitElement, ''
}
@property({ type: Number })
public set min(value: number) {
this.#min = value;
if (this.#pickerContext) {
this.#pickerContext.min = value;
}
}
public get min(): number {
return this.#pickerContext?.min ?? 0;
return this.#min;
}
#min: number = 0;
@property({ type: String, attribute: 'min-message' })
minMessage = 'This field need more items';
@property({ type: Number })
public set max(value: number) {
this.#max = value;
if (this.#pickerContext) {
this.#pickerContext.max = value;
}
}
public get max(): number {
return this.#pickerContext?.max ?? Infinity;
return this.#max;
}
#max: number = Infinity;
@property({ attribute: false })
getIcon?: (item: any) => string;
@@ -102,6 +106,9 @@ export class UmbInputEntityElement extends UUIFormControlMixin(UmbLitElement, ''
async #observePickerContext() {
if (!this.#pickerContext) return;
this.#pickerContext.min = this.min;
this.#pickerContext.max = this.max;
this.observe(
this.#pickerContext.selection,
(selection) => (this.value = selection?.join(',') ?? ''),