aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-06-08 16:07:43 +0100
committerMichael Morris <michael.morris@est.tech>2023-07-04 14:25:27 +0000
commit0977894d34b43eba0846b23dd5bc4f186ca7edc2 (patch)
tree95233cbbc9a03d1ddf45fd418262dfce64cebd82 /catalog-ui/src/app/ng2/pages
parentb0b217c4ad3252c4eb24d2fc0a5508e51eee0fba (diff)
Provide tosca function capability to complex type fields in composition view
Tosca function capability is provided to all complex type fields in composition view Issue-ID: SDC-4528 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I4742c2a46ac7a9ed0fd47677aac5b4be9ad612a1
Diffstat (limited to 'catalog-ui/src/app/ng2/pages')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts37
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts7
2 files changed, 35 insertions, 9 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
index 34ed9a618d..29290805af 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
@@ -82,7 +82,6 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
if (!this.isInitialized) {
return;
}
- this.emitValidityChange();
if (this.formGroup.valid) {
this.onValidFunction.emit(this.toscaFunctionForm.value);
}
@@ -111,12 +110,23 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
let keyToFind = [this.compositionMapKey];
let subPropertyToscaFunction = this.property.subPropertyToscaFunctions.find(subPropertyToscaFunction => this.areEqual(subPropertyToscaFunction.subPropertyPath, keyToFind));
- if (subPropertyToscaFunction){
- this.toscaFunction = subPropertyToscaFunction.toscaFunction;
- this.toscaFunctionForm.setValue(this.toscaFunction);
- this.toscaFunctionTypeForm.setValue(this.toscaFunction.type);
+ if (subPropertyToscaFunction){
+ this.toscaFunction = subPropertyToscaFunction.toscaFunction;
+ this.toscaFunctionForm.setValue(this.toscaFunction);
+ let type = this.toscaFunction.type;
+ if (type == ToscaFunctionType.CUSTOM) {
+ let name = (subPropertyToscaFunction.toscaFunction as ToscaCustomFunction).name;
+ let customToscaFunc = this.customToscaFunctions.find(custToscFunc => _.isEqual(custToscFunc.name, name))
+ if (customToscaFunc) {
+ this.toscaFunctionTypeForm.setValue(name);
+ } else {
+ this.toscaFunctionTypeForm.setValue("other");
+ }
+ } else {
+ this.toscaFunctionTypeForm.setValue(type);
}
- return;
+ }
+ return;
}
if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && (<PropertyDeclareAPIModel> this.property).propertiesName){
let propertiesPath = (<PropertyDeclareAPIModel> this.property).propertiesName.split("#");
@@ -127,7 +137,18 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
if (subPropertyToscaFunction){
this.toscaFunction = subPropertyToscaFunction.toscaFunction;
this.toscaFunctionForm.setValue(this.toscaFunction);
- this.toscaFunctionTypeForm.setValue(this.toscaFunction.type);
+ let type = this.toscaFunction.type;
+ if (type == ToscaFunctionType.CUSTOM) {
+ let name = (subPropertyToscaFunction.toscaFunction as ToscaCustomFunction).name;
+ let customToscaFunc = this.customToscaFunctions.find(custToscFunc => _.isEqual(custToscFunc.name, name))
+ if (customToscaFunc) {
+ this.toscaFunctionTypeForm.setValue(name);
+ } else {
+ this.toscaFunctionTypeForm.setValue("other");
+ }
+ } else {
+ this.toscaFunctionTypeForm.setValue(type);
+ }
}
return;
}
@@ -259,6 +280,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onGetFunctionValidityChange(validationEvent: ToscaGetFunctionValidationEvent): void {
@@ -267,6 +289,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onYamlFunctionValidityChange(validationEvent: YamlFunctionValidationEvent): void {
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
index a1ed8aa137..1fe467736d 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
@@ -486,7 +486,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (this.typeHasSchema(this.property.type)) {
if ((this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) || this.compositionMap) {
let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input);
- let childSchemaType = this.property.schemaType != null ? this.property.schemaType : childObject.type;
+ let childSchemaType = (this.property != null && this.property.schemaType != null) ? this.property.schemaType : childObject.type;
if(this.isComplexType(childSchemaType) && !this.compositionMap){
if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
return validPropertyType === PROPERTY_TYPES.STRING;
@@ -501,12 +501,15 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
}
return validPropertyType === this.property.type && this.property.schema.property.type === property.schema.property.type;
}
- if (this.property.schema.property.isDataType && this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>this.property).propertiesName){
+ if ((this.property.schema.property.isDataType || this.isComplexType(this.property.type)) && this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>this.property).propertiesName){
let typeToMatch = (<PropertyDeclareAPIModel> this.property).input.type;
let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input);
if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
typeToMatch = PROPERTY_TYPES.STRING;
}
+ if ((typeToMatch === PROPERTY_TYPES.LIST || typeToMatch === PROPERTY_TYPES.MAP) && (<PropertyDeclareAPIModel> this.property).input.schema.property.type && this.compositionMap && !isNaN(Number(this.compositionMapKey))) {
+ typeToMatch = (<PropertyDeclareAPIModel> this.property).input.schema.property.type;
+ }
return validPropertyType === typeToMatch;
}