Browse Source

fix undefined this in getModelingRule()

Martin Kunz 1 month ago
parent
commit
01582e5fda
2 changed files with 7 additions and 7 deletions
  1. 5 5
      src/components/TheDynamics.vue
  2. 2 2
      src/ua/UABaseNode.ts

+ 5 - 5
src/components/TheDynamics.vue

@@ -41,7 +41,7 @@ watch(selectedNode, async (newNode, _oldNode) => {
 })
 
 function getRefTypes():UABaseNode[] {
-  let list=(store.addressSpace?.getSubTreeAsList("ns=0;i="+ReferenceTypeIds.HierarchicalReferences)||[]) as UAReferenceType[];
+  let list=(store.addressSpace?.getSubTreeAsList("i="+ReferenceTypeIds.HierarchicalReferences)||[]) as UAReferenceType[];
   list=list.filter((node) => node.isAbstract==false)
   return list;
 }
@@ -52,21 +52,21 @@ function getObjTypes(nid: string):UABaseNode[] {
 }
 
 function getInstanceDecl(nid: string, mrType: string){
-  const aggregates = (store.addressSpace?.getSubTreeAsList("ns=0;i="+ReferenceTypeIds.Aggregates)||[]) as UABaseNode[];
+  const aggregates = (store.addressSpace?.getSubTreeAsList("i="+ReferenceTypeIds.Aggregates)||[]) as UABaseNode[];
   let aggStrings:String[] = [];
   aggregates.forEach((item) => {
     aggStrings.push(item.browseName);
   })
   let node =  (store.addressSpace?.findNode(nid)) as UABaseNode;
   let res:string[] = [];
-  node.references.forEach((item) => {
+  for(const item of node.references) {
     if(aggStrings.includes(item.referenceType) && item.isForward){
       let mr = item.toNode.getModellingRule()||"";
       if(mr == mrType){
-        res.push(item.toNode.browseName||"");
+        res.push(item.toNode.browseName);
       }
     }
-  })
+  }
   return res;
 }
 

+ 2 - 2
src/ua/UABaseNode.ts

@@ -118,11 +118,11 @@ export class UABaseNode implements IToXML{
     }
 
     getModellingRule(): string|undefined{
-        this.references.forEach((ref)=>{
+        for(const ref of this.references) {
             if(ref.referenceType == "HasModellingRule"){
                 return ref.toNode.browseName;
             }
-        });
+        }
         return undefined;
     }