From 61e8668899051e1df738093d1700564fbc22a428 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Thu, 12 May 2022 17:37:43 +0100 Subject: Support list of map properties in composition Supports editing list properties in the edit properties dialog in the composition screen. Fixes entry schema of type map not being shown. Change-Id: Iea1732f51148ae88dedd2242b3b19d19c4548eb4 Issue-ID: SDC-4001 Signed-off-by: andre.schmid --- .../type-list/type-list-directive.ts | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts') 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 997e28dabc..76810040e6 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 @@ -37,21 +37,29 @@ export interface ITypeListScope extends ng.IScope { listDefaultValue:any; listNewItem:any; maxLength:number; - + stringSchema: SchemaProperty; + constraints:string[]; getValidationPattern(type:string):RegExp; validateIntRange(value:string):boolean; addListItem():void; - deleteListItem(listItemIndex:number):void + deleteListItem(listItemIndex:number):void; + getStringSchemaProperty():SchemaProperty; } export class TypeListDirective implements ng.IDirective { + private readonly stringSchema: SchemaProperty; + constructor(private DataTypesService:DataTypesService, private PropertyNameValidationPattern:RegExp, - private ValidationUtils:ValidationUtils) { + private ValidationUtils:ValidationUtils) { + this.stringSchema = new SchemaProperty(); + this.stringSchema.type = PROPERTY_TYPES.STRING; + this.stringSchema.isSimpleType = true; + this.stringSchema.isDataType = false; } scope = { @@ -73,6 +81,7 @@ export class TypeListDirective implements ng.IDirective { link = (scope:ITypeListScope, element:any, $attr:any) => { scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + scope.stringSchema = this.stringSchema; //reset valueObjRef when schema type is changed scope.$watchCollection('schemaProperty.type', (newData:any):void => { @@ -103,17 +112,22 @@ export class TypeListDirective implements ng.IDirective { scope.addListItem = ():void => { scope.valueObjRef = scope.valueObjRef || []; - let newVal = ((scope.schemaProperty.simpleType || scope.schemaProperty.type) == PROPERTY_TYPES.STRING ? scope.listNewItem.value : JSON.parse(scope.listNewItem.value)); + let newVal; + if (scope.schemaProperty.type === PROPERTY_TYPES.MAP) { + newVal = {"": ""}; + } else if ((scope.schemaProperty.simpleType || scope.schemaProperty.type) == PROPERTY_TYPES.STRING) { + newVal = scope.listNewItem.value; + } else { + newVal = JSON.parse(scope.listNewItem.value); + } scope.valueObjRef.push(newVal); scope.listNewItem.value = ""; }; - scope.deleteListItem = (listItemIndex:number):void => { + scope.deleteListItem = (listItemIndex: number): void => { scope.valueObjRef.splice(listItemIndex, 1); - if (!scope.valueObjRef.length) { - if (scope.listDefaultValue) { - angular.copy(scope.listDefaultValue, scope.valueObjRef); - } + if (!scope.valueObjRef.length && scope.listDefaultValue) { + angular.copy(scope.listDefaultValue, scope.valueObjRef); } }; }; -- cgit 1.2.3-korg