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