diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/services/data-type.service.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/services/data-type.service.ts | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts index be2388144f..48d32b7e69 100644 --- a/catalog-ui/src/app/ng2/services/data-type.service.ts +++ b/catalog-ui/src/app/ng2/services/data-type.service.ts @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + import { Injectable } from '@angular/core'; import { DataTypeModel, DataTypesMap, PropertyBEModel, PropertyFEModel, DerivedFEProperty, DerivedFEPropertyMap } from "app/models"; import { DataTypesService } from "app/services/data-types-service"; @@ -20,35 +40,7 @@ export class DataTypeService { public getDataTypeByTypeName(typeName: string): DataTypeModel { return this.dataTypes[typeName]; } -/* - //if the dt derived from simple- return the first parent type, else- return null - public getTypeForDataTypeDerivedFromSimple = (dataTypeName:string):string => { - /////////temporary hack for tosca primitives/////////////////////// - if (!this.dataTypes[dataTypeName]) { - return PROPERTY_TYPES.STRING; - } - /////////////////////////////////////////////////////////////////// - if (this.dataTypes[dataTypeName].derivedFromName == PROPERTY_DATA.ROOT_DATA_TYPE || this.dataTypes[dataTypeName].properties) { - return null; - } - if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.dataTypes[dataTypeName].derivedFromName) > -1) { - return this.dataTypes[dataTypeName].derivedFromName - } - return this.getTypeForDataTypeDerivedFromSimple(this.dataTypes[dataTypeName].derivedFromName); - }; - /** - * The function returns all properties for the DataType passed in, and recurses through parent dataTypes (derivedFrom) to retrieve their properties as well - * @param dataTypeObj - * - public getDataTypePropertiesRecursively(dataTypeObj: DataTypeModel): Array<PropertyBEModel> { - let propertiesArray: Array<PropertyBEModel> = dataTypeObj.properties || []; - if (PROPERTY_DATA.ROOT_DATA_TYPE !== dataTypeObj.derivedFromName) { - propertiesArray = propertiesArray.concat(this.getDataTypePropertiesRecursively(dataTypeObj.derivedFrom)); - } - return propertiesArray; - } -*/ public getDerivedDataTypeProperties(dataTypeObj: DataTypeModel, propertiesArray: Array<DerivedFEProperty>, parentName: string) { //push all child properties to array @@ -67,5 +59,24 @@ export class DataTypeService { } } + /** + * Checks for custom behavior for a given data type by checking if a function exists within data-type.service with that name + * Additional custom behavior can be added by adding a function with the given dataType name + */ + public checkForCustomBehavior = (property:PropertyFEModel) => { + let shortTypeName:string = property.type.split('.').pop(); + if (this[shortTypeName]) { + this[shortTypeName](property); //execute function for given type, pass property as param + } + } + + public Naming = (property: PropertyFEModel) => { + let generatedNamingVal: boolean = _.get(property.valueObj, 'ecomp_generated_naming', true); + property.flattenedChildren.forEach((prop) => { + if (prop.name == 'naming_policy') prop.hidden = !generatedNamingVal; + if (prop.name == 'instance_name') prop.hidden = generatedNamingVal; + }); + } + } |