Bug fix on tosca function impact changes 93/134693/3
authorimamSidero <imam.hussain@est.tech>
Thu, 25 May 2023 16:23:11 +0000 (17:23 +0100)
committerMichael Morris <michael.morris@est.tech>
Tue, 30 May 2023 08:46:20 +0000 (08:46 +0000)
Providing the required inputs and dependency changes for tosca functionality

Issue-ID: SDC-4510
Signed-off-by: Imam hussain <imam.hussain@est.tech>
Change-Id: Idf5af079c50bf2b9a09f572af30ca9fc294a831e

catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.html
catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts
catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts
catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html

index 7929191..78aa7bc 100644 (file)
         <div data-ng-if="dataTypesService.isDataTypeForDataTypePropertyType(property)" class="inner-structure">
             <fields-structure value-obj-ref="(valueObjRef[property.name])"
                               type-name="property.type"
+                              parent-property="parentProperty"
+                              component-instance-map="componentInstanceMap"
                               parent-form-obj="parentFormObj"
                               fields-prefix-name="fieldsPrefixName+property.name"
                               read-only="readOnly"
+                              is-service="isService"
                               default-value="{{currentTypeDefaultValue[property.name]}}">
 
             </fields-structure>
             <div ng-switch-when="map">
                 <type-map value-obj-ref="valueObjRef[property.name]"
                           schema-property="property.schema.property"
+                          parent-property="property"
+                          component-instance-map="componentInstanceMap"
                           parent-form-obj="parentFormObj"
                           fields-prefix-name="fieldsPrefixName+property.name"
                           read-only="readOnly"
                           default-value="{{currentTypeDefaultValue[property.name]}}"
+                          is-service="isService"
                           types="types"></type-map>
             </div>
             <div ng-switch-when="list">
                 <type-list value-obj-ref="valueObjRef[property.name]"
                            schema-property="property.schema.property"
+                           parent-property="parentProperty"
+                           component-instance-map="componentInstanceMap"
                            parent-form-obj="parentFormObj"
                            fields-prefix-name="fieldsPrefixName+property.name"
                            read-only="readOnly"
                            default-value="{{currentTypeDefaultValue[property.name]}}"
+                           is-service="isService"
                            types="types"></type-list>
             </div>
             <div ng-switch-default class="primitive-value-field">
index 419ad2d..30c7b06 100644 (file)
  * Created by obarda on 1/27/2016.
  */
 'use strict';
-import { DataTypesMap } from 'app/models';
+import { DataTypesMap, PropertyModel } from 'app/models';
 import { DataTypePropertyModel } from 'app/models/data-type-properties';
 import { DataTypesService } from 'app/services';
 import { ValidationUtils } from 'app/utils';
+import {InstanceFeDetails} from "app/models/instance-fe-details";
 import * as _ from 'lodash';
 
 export interface IDataTypeFieldsStructureScope extends ng.IScope {
     parentFormObj: ng.IFormController;
     dataTypeProperties: DataTypePropertyModel[];
+    parentProperty:PropertyModel;
+    componentInstanceMap: Map<string, InstanceFeDetails>;
     typeName: string;
     valueObjRef: any;
     propertyNameValidationPattern: RegExp;
@@ -43,6 +46,7 @@ export interface IDataTypeFieldsStructureScope extends ng.IScope {
     expanded: boolean;
     dataTypesService: DataTypesService;
     constraints: string[];
+    isService:boolean;
 
     expandAndCollapse(): void;
     getValidationPattern(type: string): RegExp;
@@ -58,12 +62,15 @@ export class DataTypeFieldsStructureDirective implements ng.IDirective {
     scope = {
         valueObjRef: '=',
         typeName: '=',
+        componentInstanceMap: '=',
+        parentProperty: '=',
         parentFormObj: '=',
         fieldsPrefixName: '=',
         readOnly: '=',
         defaultValue: '@',
         types: '=',
-        expandByDefault: '='
+        expandByDefault: '=',
+        isService: '='
     };
 
     restrict = 'E';
index b2d322b..40a29da 100644 (file)
@@ -123,7 +123,8 @@ export class TypeListDirective implements ng.IDirective {
     link = (scope:ITypeListScope, element:any, $attr:any) => {
         scope.propertyNameValidationPattern = this.PropertyNameValidationPattern;
         scope.stringSchema = this.stringSchema;
-        if (scope.valueObjRef.length == 0) {
+        if (scope.valueObjRef == null || scope.valueObjRef.length == 0) {
+            scope.valueObjRef = [];
             scope.valueObjRef.push("");
         }
         scope.showToscaFunction = new Array(scope.valueObjRef.length);
index 7987ba2..cbbc2d9 100644 (file)
@@ -63,6 +63,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
     dropdownValuesLabel: string;
     dropDownErrorMsg: string;
     indexListValues:Array<ToscaIndexObject>;
+    parentListTypeFlag : boolean;
 
     private isInitialized: boolean = false;
     private componentMetadata: ComponentMetadata;
@@ -77,6 +78,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
     ngOnInit(): void {
         this.componentMetadata = this.workspaceService.metadata;
         this.indexListValues = [];
+        if (this.property != null) {
+            this.parentListTypeFlag = (this.property.type != PROPERTY_TYPES.LIST && (!this.isComplexType(this.property.type) || (this.isComplexType(this.property.type) 
+                                    && this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty && this.property.input.type != PROPERTY_TYPES.LIST)));
+        }
         this.formGroup.valueChanges.subscribe(() => {
             this.formValidation();
         });
@@ -452,8 +457,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
         if (this.property.type === PROPERTY_TYPES.ANY) {
             return true;
         }
-        let validPropertyType = (this.property.type != PROPERTY_TYPES.LIST && property.type === PROPERTY_TYPES.LIST) ? property.schema.property.type : property.type;
-        if (this.property.type != PROPERTY_TYPES.LIST && property.type === PROPERTY_TYPES.LIST && this.isComplexType(validPropertyType)) {
+        let validPropertyType = (this.parentListTypeFlag && property.type === PROPERTY_TYPES.LIST) ? property.schema.property.type : property.type;
+        if (this.parentListTypeFlag && property.type === PROPERTY_TYPES.LIST && this.isComplexType(validPropertyType)) {
             let returnFlag : boolean = false;
             const dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, validPropertyType);
             if (dataTypeFound && dataTypeFound.properties) {
@@ -555,7 +560,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
         this.indexListValues = [];
         let subPropertyDropdownList : Array<PropertyDropdownValue> = [];
         const selectedProperty: PropertyDropdownValue = this.selectedProperty.value;
-        if (selectedProperty.isList) {
+        if (this.parentListTypeFlag && selectedProperty.isList) {
             toscaIndexFlag = true;
             if (selectedProperty.schemaType != null) {
                 nestedToscaFlag = true;
index d0c3cc6..682c7a9 100644 (file)
                         <div data-ng-if="isTypeDataType">
                             <fields-structure value-obj-ref="myValue"
                                               type-name="editPropertyModel.property.type"
+                                              parent-property="editPropertyModel.property"
+                                              component-instance-map="componentInstanceMap"
                                               parent-form-obj="forms.editForm"
                                               fields-prefix-name="currentPropertyIndex"
                                               read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
                                               default-value="{{getDefaultValue()}}"
                                               types="dataTypes"
+                                              is-service="!componentMetadata.isVfc"
                                               expand-by-default="true"></fields-structure>
 
                         </div>