diff options
Diffstat (limited to 'catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts')
-rw-r--r-- | catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts index 18c46b4bac..40a29da5fb 100644 --- a/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts +++ b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts @@ -47,7 +47,6 @@ export interface ITypeListScope extends ng.IScope { constraints:string[]; types:DataTypesMap; isService:boolean; - complexToscapath: string; getValidationPattern(type:string):RegExp; validateIntRange(value:string):boolean; @@ -86,8 +85,7 @@ export class TypeListDirective implements ng.IDirective { maxLength: '=', constraints: '=', types: '=', - isService: '=', - complexToscapath: '=' + isService: '=' }; restrict = 'E'; @@ -125,26 +123,22 @@ export class TypeListDirective implements ng.IDirective { link = (scope:ITypeListScope, element:any, $attr:any) => { scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; scope.stringSchema = this.stringSchema; - if ((scope.valueObjRef == null || scope.valueObjRef.length == 0) && scope.complexToscapath == null) { + if (scope.valueObjRef == null || scope.valueObjRef.length == 0) { scope.valueObjRef = []; scope.valueObjRef.push(""); } - if (scope.valueObjRef != null && scope.valueObjRef.length > 0) { - scope.showToscaFunction = new Array(scope.valueObjRef.length); - scope.valueObjRef.forEach((value, index) => { - scope.showToscaFunction[index] = false; - if (scope.parentProperty.subPropertyToscaFunctions != null) { - let key : string = index.toString(); - scope.parentProperty.subPropertyToscaFunctions.forEach(SubPropertyToscaFunction => { - if (SubPropertyToscaFunction.subPropertyPath.toString() == key) { - scope.showToscaFunction[index] = true; - return; - } - }); - } - }); - } - + scope.showToscaFunction = new Array(scope.valueObjRef.length); + scope.valueObjRef.forEach((value, index) => { + scope.showToscaFunction[index] = false; + let key : string = index.toString(); + if (scope.parentProperty.subPropertyToscaFunctions != null) { + scope.parentProperty.subPropertyToscaFunctions.forEach(SubPropertyToscaFunction => { + if (SubPropertyToscaFunction.subPropertyPath.indexOf(key) != -1) { + scope.showToscaFunction[index] = true; + } + }); + } + }); //reset valueObjRef when schema type is changed scope.$watchCollection('schemaProperty.type', (newData:any):void => { scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); @@ -180,7 +174,6 @@ export class TypeListDirective implements ng.IDirective { } } scope.valueObjRef.push(newVal); - scope.showToscaFunction = scope.showToscaFunction || []; scope.showToscaFunction.push(false); scope.listNewItem.value = ""; }; @@ -221,7 +214,7 @@ export class TypeListDirective implements ng.IDirective { if (scope.parentProperty.subPropertyToscaFunctions != null) { let subToscaFunctionList : Array<SubPropertyToscaFunction> = []; scope.parentProperty.subPropertyToscaFunctions.forEach((SubPropertyToscaFunction, index) => { - if (SubPropertyToscaFunction.subPropertyPath.toString() != key) { + if (SubPropertyToscaFunction.subPropertyPath.indexOf(key) == -1) { subToscaFunctionList.push(SubPropertyToscaFunction); } }); @@ -233,26 +226,21 @@ export class TypeListDirective implements ng.IDirective { scope.onGetToscaFunction = (toscaGetFunction: ToscaGetFunction, index:number): void => { let key:string = index.toString(); if (scope.parentProperty.subPropertyToscaFunctions != null) { - let toscaFlag : boolean = true; scope.parentProperty.subPropertyToscaFunctions.forEach(SubPropertyToscaFunction => { - if (SubPropertyToscaFunction.subPropertyPath.toString() == key) { + if (SubPropertyToscaFunction.subPropertyPath.indexOf(key) != -1) { SubPropertyToscaFunction.toscaFunction = toscaGetFunction; - toscaFlag = false; return; } }); - if (toscaFlag) { - let subPropertyToscaFunction = new SubPropertyToscaFunction(); - subPropertyToscaFunction.toscaFunction = toscaGetFunction; - subPropertyToscaFunction.subPropertyPath = [key]; - scope.parentProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction); - } - } else { - let subPropertyToscaFunction = new SubPropertyToscaFunction(); - subPropertyToscaFunction.toscaFunction = toscaGetFunction; - subPropertyToscaFunction.subPropertyPath = [key]; - scope.parentProperty.subPropertyToscaFunctions = [subPropertyToscaFunction]; + + } + if (scope.parentProperty.subPropertyToscaFunctions == null){ + scope.parentProperty.subPropertyToscaFunctions = []; } + let subPropertyToscaFunction = new SubPropertyToscaFunction(); + subPropertyToscaFunction.toscaFunction = toscaGetFunction; + subPropertyToscaFunction.subPropertyPath = [key]; + scope.parentProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction); } }; |