delete event possibility

This commit is contained in:
Lone Iversen
2024-01-23 15:36:58 +01:00
parent dc7d2110ec
commit d67f71b7ff
3 changed files with 12 additions and 4 deletions

View File

@@ -68,6 +68,7 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
this._mappedValuesAndGroups = [{ blocks: valuesWithNoGroup }, ...valuesWithGroup];
}
/*
#onChange(e: CustomEvent, group?: UmbBlockGridGroupTypeConfiguration) {
const groupValues = (e.target as UmbInputBlockTypeElement).value;
const newValues = groupValues.map((value) => ({ ...value, groupKey: group?.key }));
@@ -75,6 +76,12 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
this.value = [...filteredValues, ...newValues];
this.dispatchEvent(new CustomEvent('property-value-change'));
}
*/
#deleteItem(e: CustomEvent) {
this.value = this._value.filter((block) => block.contentElementTypeKey !== e.detail.contentElementTypeKey);
this.dispatchEvent(new CustomEvent('property-value-change'));
}
render() {
return html`${repeat(
@@ -85,7 +92,7 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
<umb-input-block-type
entity-type="block-grid-type"
.value="${group.blocks}"
@change=${(e: CustomEvent) => this.#onChange(e, group)}></umb-input-block-type>`,
@delete=${this.#deleteItem}></umb-input-block-type>`,
)}`;
}
@@ -112,7 +119,7 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
auto-width
label="Group"
.value=${groupName ?? ''}
@change=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>
@delete=${(e: UUIInputEvent) => this.#changeGroupName(e, groupKey)}>
<uui-button compact slot="append" label="delete" @click=${() => this.#deleteGroup(groupKey)}>
<uui-icon name="icon-trash"></uui-icon>
</uui-button>

View File

@@ -1,2 +1,2 @@
export * from './input-block-type/index.js';
export * from './block-type-card/index.js';
export * from './input-block-type/index.js';

View File

@@ -101,7 +101,8 @@ export class UmbInputBlockTypeElement<
deleteItem(contentElementTypeKey: string) {
this.value = this._items.filter((x) => x.contentElementTypeKey !== contentElementTypeKey);
this.dispatchEvent(new UmbChangeEvent());
this.dispatchEvent(new CustomEvent('delete', { detail: { contentElementTypeKey } }));
//this.dispatchEvent(new UmbChangeEvent());
}
protected getFormElement() {