diff options
author | MichaelMorris <michael.morris@est.tech> | 2023-01-25 16:29:38 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-01-26 18:36:57 +0000 |
commit | 1bbecd7edbdd907a53812d303d378236d23d071e (patch) | |
tree | 2f8e6e9557ec8403c3b6900206b826d00d6e0895 /catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts | |
parent | dce3a3476f0d08dc9ffc1b012f11da6aa02a6858 (diff) |
Fix datatype in model not found
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4348
Change-Id: I648ffd91d719982e55d5ddc786a471f641ece088
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 | 36 |
1 files changed, 32 insertions, 4 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 fe509416fa..23add5363e 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 @@ -22,8 +22,8 @@ * Created by rcohen on 9/15/2016. */ 'use strict'; -import {SchemaProperty, PropertyModel} from "app/models"; -import {ValidationUtils, PROPERTY_TYPES} from "app/utils"; +import {SchemaProperty, PropertyModel, DataTypesMap} from "app/models"; +import {ValidationUtils, PROPERTY_TYPES, PROPERTY_DATA} from "app/utils"; import {DataTypesService} from "app/services"; import {InstanceFeDetails} from "app/models/instance-fe-details"; import {ToscaGetFunction} from "app/models/tosca-get-function"; @@ -45,6 +45,7 @@ export interface ITypeListScope extends ng.IScope { stringSchema: SchemaProperty; showToscaFunction: Array<boolean>; constraints:string[]; + types:DataTypesMap; getValidationPattern(type:string):RegExp; validateIntRange(value:string):boolean; @@ -81,7 +82,8 @@ export class TypeListDirective implements ng.IDirective { readOnly: '=',//is form read only defaultValue: '@',//this list default value maxLength: '=', - constraints: '=' + constraints: '=', + types: '=' }; restrict = 'E'; @@ -89,6 +91,32 @@ export class TypeListDirective implements ng.IDirective { template = ():string => { return require('./type-list-directive.html'); }; + + private isDataTypeForSchemaType = (property:SchemaProperty, types:DataTypesMap):boolean=> { + property.simpleType = ""; + if (property.type && PROPERTY_DATA.TYPES.indexOf(property.type) > -1) { + return false; + } + let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type, types); + if (simpleType) { + property.simpleType = simpleType; + return false; + } + return true; + }; + + private getTypeForDataTypeDerivedFromSimple = (dataTypeName:string, types:DataTypesMap):string => { + if (!types[dataTypeName]) { + return 'string'; + } + if (types[dataTypeName].derivedFromName == "tosca.datatypes.Root" || types[dataTypeName].properties) { + return null; + } + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(types[dataTypeName].derivedFromName) > -1) { + return types[dataTypeName].derivedFromName + } + return this.getTypeForDataTypeDerivedFromSimple(types[dataTypeName].derivedFromName, types); + }; link = (scope:ITypeListScope, element:any, $attr:any) => { scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; @@ -110,7 +138,7 @@ export class TypeListDirective implements ng.IDirective { }); //reset valueObjRef when schema type is changed scope.$watchCollection('schemaProperty.type', (newData:any):void => { - scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); + scope.isSchemaTypeDataType = this.isDataTypeForSchemaType(scope.schemaProperty, scope.types); }); //when user brows between properties in "edit property form" |