Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI updates: Bug fix for add attribute dialog (Fixes #340)

Rich Turner87e345fc8a97
diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
index 6bb798d91..5b4900d1d 100644
--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
@@ -129,6 +129,8 @@ declare global {
}
}
+const AssetNameRegex = /^\w+$/;
+
@customElement("or-edit-asset-panel")
export class OrEditAssetPanel extends LitElement {
@@ -299,7 +301,7 @@ export class OrEditAssetPanel extends LitElement {
let attr: Attribute<any>;
const onAttributeChanged = (attribute: Attribute<any>) => {
- const addDisabled = !(attribute.name && !asset.attributes![attribute.name] && attribute.type);
+ const addDisabled = !(attribute.name && !asset.attributes![attribute.name] && AssetNameRegex.test(attribute.name) && attribute.type);
const addBtn = dialog!.shadowRoot!.getElementById("add-btn") as OrInput;
addBtn!.disabled = addDisabled;
attr = attribute;