diff options
Diffstat (limited to 'catalog-ui')
-rw-r--r-- | catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts | 38 |
1 files changed, 17 insertions, 21 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 c36a242c2a..4218123215 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 @@ -48,7 +48,7 @@ interface IPropertyFormViewModelScope extends ng.IScope { propertyNameValidationPattern:RegExp; commentValidationPattern:RegExp; editPropertyModel:IEditPropertyModel; - modalInstanceProperty:ng.ui.bootstrap.IModalServiceInstance; + modalInstanceProperty:ng.ui.bootstrap.IModalServiceInstance; currentPropertyIndex:number; isLastProperty:boolean; myValue:any; @@ -101,7 +101,7 @@ export class PropertyFormViewModel { 'CompositionService', 'workspaceService' ]; - + private formState:FormState; constructor(private $scope:IPropertyFormViewModelScope, @@ -134,9 +134,7 @@ export class PropertyFormViewModel { this.$scope.editPropertyModel.property.type = this.property.type ? this.property.type : null; this.$scope.editPropertyModel.property.value = this.$scope.editPropertyModel.property.value || this.$scope.editPropertyModel.property.defaultValue; this.$scope.constraints = this.property.constraints && this.property.constraints[0] ? this.property.constraints[0]["validValues"] : null; - this.setMaxLength(); - }; //init property add-ons labels that show up at the left side of the input. @@ -193,31 +191,26 @@ export class PropertyFormViewModel { private initScope = ():void => { //scope properties + this.$scope.isLoading = true; this.$scope.forms = {}; this.$scope.validationPattern = this.ValidationPattern; this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; this.$scope.commentValidationPattern = this.CommentValidationPattern; - this.$scope.isLoading = false; this.$scope.isNew = (this.formState === FormState.CREATE); this.$scope.isService = this.workspaceService.metadata.isService(); this.$scope.modalInstanceProperty = this.$uibModalInstance; this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, i=> i.name == this.property.name); this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1); - this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.workspaceService.metadata.model); - this.$scope.isPropertyValueOwner = this.isPropertyValueOwner; - this.$scope.propertyOwnerType = this.propertyOwnerType; - this.$scope.modelNameFilter = this.workspaceService.metadata.model; - this.$scope.editPropertyModel = { property : new PropertyModel(this.property), types : PROPERTY_DATA.TYPES, simpleTypes : PROPERTY_DATA.SIMPLE_TYPES}; //All simple types - - + this.$scope.isPropertyValueOwner = this.isPropertyValueOwner; + this.$scope.propertyOwnerType = this.propertyOwnerType; + this.$scope.modelNameFilter = this.workspaceService.metadata.model; //check if property of VnfConfiguration this.$scope.isVnfConfiguration = false; if(this.propertyOwnerType == "component" && angular.isArray(this.compositionService.componentInstances)) { - var componentPropertyOwner:ComponentInstance = this.compositionService.componentInstances.find((ci:ComponentInstance) => { return ci.uniqueId === this.property.resourceInstanceUniqueId; }); @@ -225,14 +218,9 @@ export class PropertyFormViewModel { this.$scope.isVnfConfiguration = true; } } - - this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> { - return this.$scope.editPropertyModel.types.indexOf(type) == -1; - }); this.initResource(); this.initForNotSimpleType(); - this.$scope.validateJson = (json:string):boolean => { if (!json) { return true; @@ -240,6 +228,14 @@ export class PropertyFormViewModel { return this.ValidationUtils.validateJson(json); }; + 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.$scope.isLoading = false; + }); //scope methods this.$scope.save = (doNotCloseModal?:boolean):void => { @@ -291,7 +287,7 @@ export class PropertyFormViewModel { property.value = myValueString; } this.updateInstanceProperties(property.resourceInstanceUniqueId, [property]).subscribe((propertiesFromBE) => onPropertySuccess(propertiesFromBE[0]), - error => onPropertyFaild(error)); + error => onPropertyFaild(error)); } else { if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) { let myValueString:string = JSON.stringify(this.$scope.myValue); @@ -417,7 +413,7 @@ export class PropertyFormViewModel { return newProperty; }; return this.topologyTemplateService.addProperty(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId, property) - .map(onSuccess); + .map(onSuccess); } else { let onSuccess = (newProperty: PropertyModel): PropertyModel => { // find exist instance property in parent component for update the new value ( find bu uniqueId ) @@ -440,4 +436,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 |