NodeInfo::getModel expects the instance-model
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / objectsToTree / objectToInstanceTree / objectToInstanceTree.service.ts
index 89d901f..13dca56 100644 (file)
@@ -8,10 +8,12 @@ import {ErrorMsgService} from "../../../../shared/components/error-msg/error-msg
 import {FeatureFlagsService, Features} from "../../../../shared/services/featureFlag/feature-flags.service";
 import {NgRedux} from "@angular-redux/store";
 import {AppState} from "../../../../shared/store/reducers";
+import {SharedTreeService} from "../shared.tree.service";
 
 @Injectable()
 export class ObjectToInstanceTreeService {
-  constructor(private _objectToTreeService: ObjectToTreeService, private _errorMsgService: ErrorMsgService, private store: NgRedux<AppState>) {
+  constructor(private _objectToTreeService: ObjectToTreeService, private _errorMsgService: ErrorMsgService,
+              private store: NgRedux<AppState>, private _sharedTreeService: SharedTreeService) {
     this.numberOfFailed = 0;
     this.numberOfElements = 0;
 
@@ -76,7 +78,11 @@ export class ObjectToInstanceTreeService {
    * @param parentType
    ****************************************************************/
   getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, serviceModelId: string, parentType ?: string) {
-    const model = option.getModel(modelName, instance, serviceHierarchy);
+    const instanceModel = this._sharedTreeService.modelByIdentifiers(
+      serviceHierarchy, option.name,
+      this._sharedTreeService.modelUniqueNameOrId(instance), modelName
+    );
+    const model = option.getModel(instanceModel);
 
     let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName, serviceModelId);
     this.increaseNumberOfFailed(optionalNodes);
@@ -99,6 +105,7 @@ export class ObjectToInstanceTreeService {
       node.parentType = !_.isNil(parentType) ? parentType : "";
       node.updatePoistionFunction = option.updatePosition;
       node.position = option.getNodePosition(instance, node.dynamicModelName);
+      node.modelTypeName = option.name;
       node.getModel = option.getModel.bind(option);
       node.getInfo = !_.isNil(option.getInfo) ? option.getInfo.bind(option) : ()=>{};
       node.componentInfoType = option.componentInfoType;