Bugfix: Tags amends

The config was replacing the `value` with the non-existent `items`,
meaning that the editor would always appear empty.

Added the `storageType` field, unsure if this will be used on the client yet.
This commit is contained in:
leekelleher
2024-03-19 10:15:58 +00:00
parent 31e70928bd
commit 5e6a7d04aa

View File

@@ -5,6 +5,8 @@ import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import '../../components/tags-input/tags-input.element.js';
/**
* @element umb-property-editor-ui-tags
*/
@@ -23,17 +25,21 @@ export class UmbPropertyEditorUITagsElement extends UmbLitElement implements Umb
@state()
private _group?: string;
@state()
private _storageType?: string;
@state()
private _culture?: string | null;
//TODO: Use type from VariantID
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
this._group = config?.getValueByAlias('group');
this.value = config?.getValueByAlias('items') ?? [];
this._storageType = config?.getValueByAlias('storageType');
}
constructor() {
super();
this.consumeContext(UMB_PROPERTY_CONTEXT, (context) => {
this.observe(context.variantId, (id) => {
if (id && id.culture !== undefined) {
@@ -43,7 +49,7 @@ export class UmbPropertyEditorUITagsElement extends UmbLitElement implements Umb
});
}
private _onChange(event: CustomEvent) {
#onChange(event: CustomEvent) {
this.value = ((event.target as UmbTagsInputElement).value as string).split(',');
this.dispatchEvent(new CustomEvent('property-value-change'));
}
@@ -53,7 +59,7 @@ export class UmbPropertyEditorUITagsElement extends UmbLitElement implements Umb
group="${ifDefined(this._group)}"
.culture=${this._culture}
.items=${this.value}
@change=${this._onChange}></umb-tags-input>`;
@change=${this.#onChange}></umb-tags-input>`;
}
}