Skip to content

armgit / core

Public Imported from GitHub
0

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

fetch selected optional attributes and add to payload when creating asset

Vincent6920b4bcee89
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 64d1ad7b4..6f4f96b90 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -548,9 +548,10 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
const addAssetDialog = dialog.shadowRoot!.getElementById("add-panel") as OrAddAssetDialog;
const descriptor = addAssetDialog.selectedType;
+ const selectedOptionalAttributes = addAssetDialog.selectedAttributes;
const name = addAssetDialog.name.trim();
const parent = addAssetDialog.parent;
-
+
if (!descriptor) {
return;
}
@@ -577,10 +578,20 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
name: attributeDescriptor.name,
type: attributeDescriptor.type,
meta: attributeDescriptor.meta ? {...attributeDescriptor.meta} : undefined
- } as Attribute<any>;
+ } as Attribute<any>;
});
}
+ if (selectedOptionalAttributes) {
+ selectedOptionalAttributes?.forEach(attribute => {
+ asset.attributes![attribute.name!] = {
+ name: attribute.name,
+ type: attribute.type,
+ meta: attribute.meta ? {...attribute.meta} : undefined
+ }
+ });
+ }
+
if (this.selectedIds) {
asset.parentId = parent ? parent.id : undefined;
}