aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.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/objectToModelTree/objectToModelTree.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/objectToModelTree/objectToModelTree.service.ts')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts48
1 files changed, 35 insertions, 13 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts
index e941faad3..c101f44e9 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts
@@ -2,9 +2,11 @@ import {Injectable} from "@angular/core";
import {ILevelNodeInfo} from "../models/basic.model.info";
import {ObjectToTreeService} from "../objectToTree.service";
import * as _ from "lodash";
+import {IModelTreeNodeModel} from "../../../objectsToTree/objectToModelTree/modelTreeNode.model";
@Injectable()
export class ObjectToModelTreeService {
+ numberOfPlusButton: number;
constructor(private _objectToTreeService: ObjectToTreeService) {
}
@@ -21,10 +23,20 @@ export class ObjectToModelTreeService {
nodes.push(_this.addFirstLevelModel(serviceModel.service.uuid, key, item, item.type, serviceModel, option));
});
}
+
+ this.calculateNumberOfNodesWithPlusIcon(serviceModel, nodes);
+
console.log('nodes', nodes);
return nodes;
}
+ calculateNumberOfNodesWithPlusIcon(serviceModel, nodes) : void {
+ this.numberOfPlusButton = nodes.reduce((sum, node)=>{
+ let showNodeIconResult = node.showNodeIcons({data : node}, serviceModel.service.uuid);
+ return (!_.isNil(showNodeIconResult) && showNodeIconResult.addIcon && !showNodeIconResult.vIcon) ? sum + 1 : sum;
+ }, 0);
+ }
+
/***********************************************************
* return node with all his child's
@@ -50,13 +62,14 @@ export class ObjectToModelTreeService {
* @param parentNode - parent node.
************************************************************/
addNextLevelNodes(serviceId: string, currentModel, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode): any[] {
- if (!_.isNil(levelNodeInfo.childName)) {
- if (!_.isNil(currentModel[levelNodeInfo.childName])) {
- let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(this);
- parentNode.children = Object.keys(currentModel[levelNodeInfo.childName]).map((key) =>
- ObjectToModelTreeService.convertItemToTreeNode(serviceId, key, currentModel[levelNodeInfo.childName][key], levelNodeInfo.childName, currentModel, nextLevelNodeInfo));
-
- }
+ if (!_.isNil(levelNodeInfo.childNames) && levelNodeInfo.childNames.length > 0) {
+ levelNodeInfo.childNames.forEach(function (childName) {
+ if (!_.isNil(currentModel[childName])) {
+ let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(this, [childName]);
+ parentNode.children = Object.keys(currentModel[childName]).map((key) =>
+ ObjectToModelTreeService.convertItemToTreeNode(serviceId, key, currentModel[childName][key], childName, currentModel, nextLevelNodeInfo));
+ }
+ })
}
return parentNode.children;
}
@@ -72,7 +85,7 @@ export class ObjectToModelTreeService {
* @param levelNodeInfo - current levelNodeInfo object
************************************************************/
static convertItemToTreeNode(serviceId: string, name: string, currentModel: any, valueType: string, parentModel: string, levelNodeInfo: ILevelNodeInfo) {
- let node = {
+ let node : IModelTreeNodeModel = {
id: currentModel.customizationUuid || currentModel.uuid,
modelCustomizationId : currentModel.customizationUuid,
modelVersionId: currentModel.uuid,
@@ -88,11 +101,20 @@ export class ObjectToModelTreeService {
isEcompGeneratedNaming: levelNodeInfo.isEcompGeneratedNaming(currentModel, parentModel)
};
- node['onAddClick'] = (node, serviceId) => levelNodeInfo.onClickAdd(node, serviceId);
- node['getNodeCount'] = (node, serviceId) => levelNodeInfo.getNodeCount(node, serviceId);
- node['getMenuAction'] = (node, serviceId) => levelNodeInfo.getMenuAction(node, serviceId);
- node['showNodeIcons'] = (node, serviceId) => levelNodeInfo.showNodeIcons(node, serviceId);
- node['typeName'] = levelNodeInfo['typeName'];
+ node = this.addExtraFunctionality(node, serviceId, name, currentModel, valueType, parentModel, levelNodeInfo);
+ return node;
+ }
+
+
+ static addExtraFunctionality(node, serviceId: string, name: string, currentModel: any, valueType: string, parentModel: string, levelNodeInfo: ILevelNodeInfo){
+ node.onAddClick = (node, serviceId) => levelNodeInfo.onClickAdd(node, serviceId);
+ node.getNodeCount = (node, serviceId) => levelNodeInfo.getNodeCount(node, serviceId);
+ node.getMenuAction = (node, serviceId) => levelNodeInfo.getMenuAction(node, serviceId);
+ node.showNodeIcons = (node, serviceId) => levelNodeInfo.showNodeIcons(node, serviceId);
+ node.typeName = levelNodeInfo.typeName;
+ node.getModel = levelNodeInfo.getModel.bind(levelNodeInfo);
+ node.getInfo = !_.isNil(levelNodeInfo.getInfo) ? levelNodeInfo.getInfo.bind(levelNodeInfo) : ()=>{};
+ node.componentInfoType = levelNodeInfo.componentInfoType;
return node;
}
}