diff options
Diffstat (limited to 'catalog-ui/src/app/view-models')
2 files changed, 33 insertions, 4 deletions
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts index eda5efcd49..151c34f31a 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts @@ -154,10 +154,36 @@ export class PropertyFormViewModel { this.$scope.editPropertyModel.hasGetFunctionValue = this.$scope.editPropertyModel.property.isToscaFunction(); this.$scope.editPropertyModel.isGetFunctionValid = true; } + + private isDataTypeForPropertyType = (property:PropertyModel):boolean=> { + property.simpleType = ""; + if (property.type && PROPERTY_DATA.TYPES.indexOf(property.type) > -1) { + return false; + } + let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type); + if (simpleType) { + property.simpleType = simpleType; + return false; + } + return true; + }; + + private getTypeForDataTypeDerivedFromSimple = (dataTypeName:string):string => { + if (!this.$scope.dataTypes[dataTypeName]) { + return 'string'; + } + if (this.$scope.dataTypes[dataTypeName].derivedFromName == "tosca.datatypes.Root" || this.$scope.dataTypes[dataTypeName].properties) { + return null; + } + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.$scope.dataTypes[dataTypeName].derivedFromName) > -1) { + return this.$scope.dataTypes[dataTypeName].derivedFromName + } + return this.getTypeForDataTypeDerivedFromSimple(this.$scope.dataTypes[dataTypeName].derivedFromName); + }; private initForNotSimpleType = ():void => { const property = this.$scope.editPropertyModel.property; - this.$scope.isTypeDataType = this.DataTypesService.isDataTypeForPropertyType(this.$scope.editPropertyModel.property); + this.$scope.isTypeDataType = this.isDataTypeForPropertyType(this.$scope.editPropertyModel.property); if (property.isToscaFunction()) { this.initValueForGetFunction(); return; @@ -274,7 +300,6 @@ export class PropertyFormViewModel { } } this.initResource(); - this.initForNotSimpleType(); this.initComponentInstanceMap(); this.$scope.validateJson = (json:string):boolean => { @@ -286,10 +311,11 @@ export class PropertyFormViewModel { this.DataTypesService.fetchDataTypesByModel(this.workspaceService.metadata.model).then(response => { this.$scope.dataTypes = response.data as DataTypesMap; + this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> { return this.$scope.editPropertyModel.types.indexOf(type) == -1; }); - + this.initForNotSimpleType(); this.$scope.isLoading = false; }); @@ -565,4 +591,4 @@ export class PropertyFormViewModel { return this.topologyTemplateService.deleteProperty(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId, propertyId).map(onSuccess, onFailed); }; -}
\ No newline at end of file +} diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html index 6a9013cce6..dc26d1f6a3 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html @@ -169,6 +169,7 @@ fields-prefix-name="currentPropertyIndex" read-only="editPropertyModel.property.readonly && !isPropertyValueOwner" default-value="{{getDefaultValue()}}" + types="dataTypes" expand-by-default="true"></fields-structure> </div> @@ -183,6 +184,7 @@ read-only="(editPropertyModel.property.readonly && !isPropertyValueOwner) || isVnfConfiguration" default-value="{{getDefaultValue()}}" max-length="maxLength" + types="dataTypes" constraints="editPropertyModel.property.constraints && editPropertyModel.property.constraints[0].validValues"> </type-map> </div> @@ -197,6 +199,7 @@ read-only="editPropertyModel.property.readonly && !isPropertyValueOwner" default-value="{{getDefaultValue()}}" max-length="maxLength" + types="dataTypes" constraints="editPropertyModel.property.constraints && editPropertyModel.property.constraints[0].validValues"></type-list> </div> |