Hide add button when max 1 Co-authored-by: Lan Nguyen Thuy <lnt@umbraco.dk>
This commit is contained in:
@@ -198,6 +198,9 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
|
||||
@state()
|
||||
private _isReadOnly: boolean = false;
|
||||
|
||||
@state()
|
||||
private _limitMax?: number;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -294,6 +297,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
|
||||
}
|
||||
|
||||
async #setupRangeValidation(rangeLimit: UmbNumberRangeValueType | undefined) {
|
||||
this._limitMax = rangeLimit?.max;
|
||||
if (this.#rangeUnderflowValidator) {
|
||||
this.removeValidator(this.#rangeUnderflowValidator);
|
||||
this.#rangeUnderflowValidator = undefined;
|
||||
@@ -408,6 +412,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
|
||||
}
|
||||
|
||||
#renderCreateButtonGroup() {
|
||||
if (this._limitMax === 1 && this._layoutEntries.length > 0) return nothing;
|
||||
if (this._areaKey === null || this._layoutEntries.length === 0) {
|
||||
return html` <uui-button-group id="createButton">
|
||||
${this.#renderCreateButton()} ${this.#renderPasteButton()}
|
||||
|
||||
@@ -394,11 +394,8 @@ export class UmbPropertyEditorUIBlockListElement
|
||||
}
|
||||
|
||||
#renderCreateButtonGroup() {
|
||||
if (this.readonly && this._layouts.length > 0) {
|
||||
return nothing;
|
||||
} else {
|
||||
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
|
||||
}
|
||||
if (this._layouts.length > 0 && (this._limitMax === 1 || this.readonly)) return nothing;
|
||||
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
|
||||
}
|
||||
|
||||
#renderInlineCreateButton(index: number) {
|
||||
|
||||
@@ -221,6 +221,7 @@ export class UmbInputMultipleTextStringElement extends UmbFormControlMixin<undef
|
||||
|
||||
#renderAddButton() {
|
||||
if (this.disabled || this.readonly) return nothing;
|
||||
if (this.max === 1 && this._items.length > 0) return nothing;
|
||||
return html`
|
||||
<uui-button
|
||||
color="default"
|
||||
|
||||
@@ -214,7 +214,7 @@ export class UmbInputDocumentElement extends UmbFormControlMixin<string | undefi
|
||||
}
|
||||
|
||||
#renderAddButton() {
|
||||
if (this.selection.length >= this.max) return nothing;
|
||||
if (this.selection.length > 0 && this.max === 1) return nothing;
|
||||
if (this.readonly && this.selection.length > 0) {
|
||||
return nothing;
|
||||
} else {
|
||||
|
||||
@@ -388,6 +388,7 @@ export class UmbInputRichMediaElement extends UmbFormControlMixin<
|
||||
|
||||
#renderAddButton() {
|
||||
if (this.readonly) return nothing;
|
||||
if (this.max === 1 && this._cards.length > 0) return nothing;
|
||||
return html`
|
||||
<uui-button
|
||||
id="btn-add"
|
||||
|
||||
Reference in New Issue
Block a user