return empty array if end point cant find any property editor configs + show message

This commit is contained in:
Mads Rasmussen
2022-09-23 09:15:13 +02:00
parent ceb5392201
commit 9adfb4bbf1
3 changed files with 23 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ export class UmbPropertyEditorConfigElement extends UmbContextConsumerMixin(LitE
public data: Array<any> = [];
@state()
private _properties?: Array<any> = [];
private _properties: Array<any> = [];
private _propertyEditorConfigStore?: UmbPropertyEditorConfigStore;
private _propertyEditorConfigSubscription?: Subscription;
@@ -49,22 +49,29 @@ export class UmbPropertyEditorConfigElement extends UmbContextConsumerMixin(LitE
this._propertyEditorConfigSubscription = this._propertyEditorConfigStore
?.getByAlias(this.propertyEditorAlias)
.subscribe((propertyEditorConfig) => {
if (!propertyEditorConfig) return;
this._properties = propertyEditorConfig?.properties;
});
}
render() {
return html`
${this._properties?.map(
(property) => html`
<umb-entity-property
label="${property.label}"
description="${property.description}"
alias="${property.alias}"
property-editor-ui-alias="${property.propertyEditorUI}"
.value=${this.data.find((data) => data.alias === property.alias)?.value}></umb-entity-property>
`
)}
<uui-box headline="Config">
${this._properties.length > 0
? html`
${this._properties?.map(
(property) => html`
<umb-entity-property
label="${property.label}"
description="${property.description}"
alias="${property.alias}"
property-editor-ui-alias="${property.propertyEditorUI}"
.value=${this.data.find((data) => data.alias === property.alias)?.value}></umb-entity-property>
`
)}
`
: html` <div>No configuration</div> `}
</uui-box>
`;
}
}

View File

@@ -279,11 +279,9 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li
return html`
${this._propertyEditorAlias
? html`
<uui-box headline="Config">
<umb-property-editor-config
property-editor-alias="${this._propertyEditorAlias}"
.data="${this._data}"></umb-property-editor-config>
</uui-box>
<umb-property-editor-config
property-editor-alias="${this._propertyEditorAlias}"
.data="${this._data}"></umb-property-editor-config>
`
: nothing}
`;

View File

@@ -27,7 +27,7 @@ export const handlers = [
if (!alias) return;
const propertyEditorConfig = umbPropertyEditorConfigData.getByAlias(alias);
return res(ctx.status(200), ctx.json([propertyEditorConfig]));
const response = propertyEditorConfig ? [propertyEditorConfig] : [];
return res(ctx.status(200), ctx.json(response));
}),
];