aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-06-09 18:12:20 +0100
committerMichael Morris <michael.morris@est.tech>2022-06-13 13:43:57 +0000
commit6527ef7840f625dc2d6f3f53145c1ff03e2e0296 (patch)
tree74b774c7ec5415e20590d4145feada7b185c1055 /catalog-ui/src
parent1f240151bfac463eb1f5c1df1f497eed8495106e (diff)
Consider schema in filtering function properties
Considers the selected property/input schema, not only the type, when searching for matching properties/inputs in the TOSCA function. Change-Id: Ie6e3eb8991a1ff9233d8d32109217d59f82f403d Issue-ID: SDC-4043 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts27
1 files changed, 22 insertions, 5 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 2d03732723..81e5b473a1 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
@@ -230,13 +230,13 @@ export class ToscaFunctionComponent implements OnInit {
const properties: PropertyBEModel[] = this.extractProperties(response);
if (!properties || properties.length === 0) {
const msgCode = this.isGetInputSelected() ? 'TOSCA_FUNCTION_NO_INPUT_FOUND' : 'TOSCA_FUNCTION_NO_PROPERTY_FOUND';
- this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.property.type});
+ this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.propertyTypeToString()});
return;
}
this.addPropertiesToDropdown(properties);
if (this.propertyDropdownList.length == 0) {
const msgCode = this.isGetInputSelected() ? 'TOSCA_FUNCTION_NO_INPUT_FOUND' : 'TOSCA_FUNCTION_NO_PROPERTY_FOUND';
- this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.property.type});
+ this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.propertyTypeToString()});
}
}, (error) => {
console.error('An error occurred while loading properties.', error);
@@ -248,6 +248,13 @@ export class ToscaFunctionComponent implements OnInit {
});
}
+ private propertyTypeToString() {
+ if (this.property.schemaType) {
+ return `${this.property.type} of ${this.property.schemaType}`;
+ }
+ return this.property.type;
+ }
+
private extractProperties(componentGenericResponse: ComponentGenericResponse): PropertyBEModel[] {
if (this.isGetInputSelected()) {
return componentGenericResponse.inputs;
@@ -290,7 +297,7 @@ export class ToscaFunctionComponent implements OnInit {
private addPropertiesToDropdown(properties: PropertyBEModel[]): void {
for (const property of properties) {
- if (this.property.type === property.type) {
+ if (this.hasSameType(property)) {
this.addPropertyToDropdown({
propertyName: property.name,
propertyId: property.uniqueId,
@@ -310,19 +317,29 @@ export class ToscaFunctionComponent implements OnInit {
}
parentPropertyList.push(inputProperty);
dataTypeFound.properties.forEach(dataTypeProperty => {
- if (dataTypeProperty.type === this.property.type) {
+ if (this.hasSameType(dataTypeProperty)) {
this.addPropertyToDropdown({
propertyName: dataTypeProperty.name,
propertyId: parentPropertyList[0].uniqueId,
propertyLabel: parentPropertyList.map(property => property.name).join('->') + '->' + dataTypeProperty.name,
propertyPath: [...parentPropertyList.map(property => property.name), dataTypeProperty.name]
});
- } else if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(dataTypeProperty.type) === -1) {
+ } else if (this.isComplexType(dataTypeProperty.type)) {
this.fillPropertyDropdownWithMatchingChildProperties(dataTypeProperty, [...parentPropertyList])
}
});
}
+ private hasSameType(property: PropertyBEModel) {
+ if (this.property.schema && this.property.schema.property) {
+ if (!property.schema || !property.schema.property) {
+ return false;
+ }
+ return property.type === this.property.type && this.property.schema.property.type === property.schema.property.type;
+ }
+ return property.type === this.property.type;
+ }
+
private isGetPropertySelected(): boolean {
return this.toscaGetFunction.functionType === ToscaGetFunctionType.GET_PROPERTY;
}