summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-07-07 19:23:03 +0300
committerIttay Stern <ittay.stern@att.com>2019-07-08 16:13:43 +0300
commitf792671ae247a931f34d902e9276202b5016ef9a (patch)
tree6104971e8074c9a3d720836276ff18619719ec02 /vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts
parentfc62274e8d15964d63c62bf0e2f4abc040252ee9 (diff)
Merge from ecomp 718fd196 - Modern UI
Issue-ID: VID-378 Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts53
1 files changed, 31 insertions, 22 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts
index 1fc439ea3..7a908b7fd 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts
@@ -48,7 +48,7 @@ export class ObjectToInstanceTreeService {
* @param node - the current node
****************************************************************/
increaseNumberOfFailed(node) {
- if (node.isFailed) {
+ if (node && node.isFailed) {
this.numberOfFailed++;
node['errors'] = !_.isNil(node['errors']) ? node['errors'] : {};
node['errors']["isFailed"] = true;
@@ -92,11 +92,16 @@ export class ObjectToInstanceTreeService {
}
addingExtraDataToNode(node, modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, parentType ?: string) {
- node.trackById = _.isNil(node.trackById) ? DefaultDataGeneratorService.createRandomTrackById() : node['trackById'];
- node.parentType = !_.isNil(parentType) ? parentType : "";
- node.updatePoistionFunction = option.updatePosition;
- node.position = option.getNodePosition(instance, node.dynamicModelName);
- node.onSelectedNode = option.onSelectedNode;
+ if(!_.isNil(node)){
+ node.trackById = _.isNil(node.trackById) ? DefaultDataGeneratorService.createRandomTrackById() : node['trackById'];
+ node.parentType = !_.isNil(parentType) ? parentType : "";
+ node.updatePoistionFunction = option.updatePosition;
+ node.position = option.getNodePosition(instance, node.dynamicModelName);
+ node.getModel = option.getModel.bind(option);
+ node.getInfo = !_.isNil(option.getInfo) ? option.getInfo.bind(option) : ()=>{};
+ node.componentInfoType = option.componentInfoType;
+ }
+
return node;
}
@@ -116,24 +121,27 @@ export class ObjectToInstanceTreeService {
* @param serviceHierarchy - The service Hierarchy store
****************************************************************/
addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy): any[] {
- if (!_.isNil(levelNodeInfo.childName)) {
+ if (!_.isNil(levelNodeInfo.childNames)&& levelNodeInfo.childNames.length > 0) {
+ const that = this;
parentNode.children = [];
- if (!_.isNil(parentInstance[levelNodeInfo.childName])) {
- let parentType = levelNodeInfo.type;
- let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(this);
- Object.keys(parentInstance[levelNodeInfo.childName]).map((modelName) => {
- let nextLevelInstance = parentInstance[levelNodeInfo.childName][modelName];
- let nodes: any[] | any = this.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, parentType);
- if (_.isArray(nodes)) {
- parentNode.children = parentNode.children.concat(nodes);
- } else {
- parentNode.children.push(nodes);
- }
- });
- return this.sortElementsByPosition(parentNode.children);
- }
+ levelNodeInfo.childNames.forEach(function (childName) {
+ if (!_.isNil(parentInstance[childName])) {
+ let parentType = levelNodeInfo.type;
+ let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(that, [childName]);
+ Object.keys(parentInstance[childName]).map((modelName) => {
+ let nextLevelInstance = parentInstance[childName][modelName];
+ let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, parentType);
+ if (_.isArray(nodes)) {
+ parentNode.children = parentNode.children.concat(nodes);
+ } else {
+ parentNode.children.push(nodes);
+ }
+ });
+ }
+ });
+ return this.sortElementsByPosition(parentNode.children);
}
- return parentNode.children;
+ return !_.isNil(parentNode) ? parentNode.children : null;
}
@@ -142,6 +150,7 @@ export class ObjectToInstanceTreeService {
* @param node
*********************************************************************************/
updateScalingPolicy(node): void {
+ if(_.isNil(node)) return node;
node['errors'] = !_.isNil(node['errors']) ? node['errors'] : {};
if (!_.isNil(node['limitMembers']) && !_.isNil(node.children)) {
let effectiveChildren = (node.children).filter(child => [