/***********************************************************
* return vfModule model
- * @param vfModuleModelId - current Model id
- * @param instance
- * @param serviceHierarchy - serviceHierarchy
+ * @param instanceModel - The model of the instance (usually extracted from
+ * serviceHierarchy store)
************************************************************/
- getModel = (vfModuleModelId: string, instance, serviceHierarchy): Partial<VfModule> => {
- if (!_.isNil(serviceHierarchy)) {
- if (!_.isNil(serviceHierarchy[this.name]) && !_.isNil(serviceHierarchy[this.name][vfModuleModelId])) {
- return new VfModule(serviceHierarchy[this.name][vfModuleModelId], this._featureFlagsService.getAllFlags());
- }
+ getModel = (instanceModel: any): Partial<VfModule> => {
+ if (!_.isNil(instanceModel)) {
+ return new VfModule(instanceModel, this._featureFlagsService.getAllFlags());
}
return {};
};
- createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number): VfModuleTreeNode {
+ createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number, serviceModelId: string): VfModuleTreeNode {
let dynamicModelName = Object.keys(instance)[index];
instance = instance[Object.keys(instance)[index]];
const isEcompGeneratedNaming: boolean = this.isEcompGeneratedNaming(currentModel, parentModel);
newVfModule.missingData = this._sharedTreeService.hasMissingData(instance, newVfModule.dynamicInputs, isEcompGeneratedNaming, []);
newVfModule.typeName = this.typeName;
- newVfModule.menuActions = this.getMenuAction(<any>newVfModule, currentModel.uuid);
+ newVfModule.menuActions = this.getMenuAction(<any>newVfModule, serviceModelId);
newVfModule.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed;
newVfModule.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : "";
return newVfModule;
}
- createInstanceTreeNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string): VfModuleTreeNode | VfModuleTreeNode[] {
+ createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any {
let numberOfChilds = Object.keys(instance).length;
if (numberOfChilds > 1) {
let result: VfModuleTreeNode[] = [];
for (let i = 0; i < numberOfChilds; i++) {
- result.push(this.createNode(instance, currentModel, parentModel, modelName, i));
+ result.push(this.createNode(instance, model, parentModel, storeKey, i, serviceModelId));
}
return result;
} else {
- return this.createNode(instance, currentModel, parentModel, modelName, 0);
+ return this.createNode(instance, model, parentModel, storeKey, 0, serviceModelId);
}
}
},
delete: {
method: (node, serviceModelId) => {
- this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId))
+ this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.modelName))
},
- visible: (node) => this._sharedTreeService.shouldShowDelete(node),
- enable: (node) => this._sharedTreeService.shouldShowDelete(node)
+ visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId),
+ enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId)
},
undoDelete: {
method: (node, serviceModelId) => {
this._store.dispatch(deleteVFModuleField(node.data.modelName, node.parent.data.vnfStoreKey, node.data.servicedId ,node.data.dynamicModelName, 'retainAssignments'));
},
visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node),
- enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId)
+ enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent, serviceModelId) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId)
},
upgrade: {
method: (node, serviceModelId) => {