summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-04-12 16:02:46 +0100
committerMichael Morris <michael.morris@est.tech>2023-05-09 14:33:29 +0000
commita1ba3abf29613ee9e576a7c96a76ceb921086044 (patch)
treef3f9e4d9c98c6b5bc2d8aba1be01b327dd36b31d /catalog-ui/src/app/ng2
parent3bc3a5c724e9a6ea8a112dca72a9a3128eddca19 (diff)
Support for addition of INDEX token to tosca functions
Providing the capability to add the index token to th tosca function of all types Issue-ID: SDC-4472 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: Ib7ac80f31710101f50de76bdb7c79abdc637cfe3
Diffstat (limited to 'catalog-ui/src/app/ng2')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html4
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts62
2 files changed, 55 insertions, 11 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html
index 62cd697f8c..387bb5cbcb 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html
@@ -28,9 +28,11 @@
</div>
<div *ngIf="showPropertyDropdown()" class="i-sdc-form-item">
<label class="i-sdc-form-label required">{{dropdownValuesLabel}}</label>
- <select formControlName="selectedProperty">
+ <select formControlName="selectedProperty" (change)="onPropertyValueChange()">
<option *ngFor="let value of propertyDropdownList" [ngValue]="value">{{value.propertyLabel}}</option>
</select>
+ <label class="i-sdc-form-label required" *ngIf="toscaIndexFlag">Index</label>
+ <input type="text" *ngIf="toscaIndexFlag" formControlName="toscaIndex" (change)="indexTokenChange()"/>
</div>
<div *ngIf="dropDownErrorMsg" class="tosca-error">{{dropDownErrorMsg}}</div>
</form>
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 36ead13117..fe6f2f143c 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
@@ -52,7 +52,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
formGroup: FormGroup = new FormGroup({
'selectedProperty': new FormControl(undefined, Validators.required),
- 'propertySource': new FormControl(undefined, Validators.required)
+ 'propertySource': new FormControl(undefined, Validators.required),
+ 'toscaIndex' : new FormControl(undefined)
});
isLoading: boolean = false;
@@ -61,6 +62,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
instanceNameAndIdMap: Map<string, string> = new Map<string, string>();
dropdownValuesLabel: string;
dropDownErrorMsg: string;
+ toscaIndexFlag: boolean = false;
private isInitialized: boolean = false;
private componentMetadata: ComponentMetadata;
@@ -78,8 +80,14 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (!this.isInitialized) {
return;
}
+ let formGroupStatus : boolean = this.formGroup.valid;
+ const selectedProperty: PropertyDropdownValue = this.formGroup.value.selectedProperty;
+ if (selectedProperty != null && selectedProperty.isList && formGroupStatus
+ && (this.toscaIndex.value == null || this.toscaIndex.value == '')) {
+ formGroupStatus = false;
+ }
this.onValidityChange.emit({
- isValid: this.formGroup.valid,
+ isValid: formGroupStatus,
toscaGetFunction: this.formGroup.valid ? this.buildGetFunctionFromForm() : undefined
});
if (this.formGroup.valid) {
@@ -132,6 +140,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
} else {
subscriber.next();
}
+ if (this.toscaGetFunction.toscaIndex != null) {
+ this.toscaIndexFlag = true;
+ this.toscaIndex.setValue(this.toscaGetFunction.toscaIndex);
+ }
});
}
@@ -154,6 +166,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
toscaGetFunction.propertyUniqueId = selectedProperty.propertyId;
toscaGetFunction.propertyName = selectedProperty.propertyName;
toscaGetFunction.propertyPathFromSource = selectedProperty.propertyPath;
+ toscaGetFunction.toscaIndex = this.toscaIndex.value;
return toscaGetFunction;
}
@@ -219,6 +232,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
private resetPropertyDropdown(): void {
this.dropDownErrorMsg = undefined;
this.selectedProperty.reset();
+ this.toscaIndex.reset();
this.propertyDropdownList = [];
}
@@ -357,7 +371,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
propertyName: property.name,
propertyId: property.uniqueId,
propertyLabel: property.name,
- propertyPath: [property.name]
+ propertyPath: [property.name],
+ isList: property.type === PROPERTY_TYPES.LIST
});
} else if (this.isComplexType(property.type)) {
this.fillPropertyDropdownWithMatchingChildProperties(property);
@@ -378,7 +393,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
propertyName: dataTypeProperty.name,
propertyId: parentPropertyList[0].uniqueId,
propertyLabel: parentPropertyList.map(property => property.name).join('->') + '->' + dataTypeProperty.name,
- propertyPath: [...parentPropertyList.map(property => property.name), dataTypeProperty.name]
+ propertyPath: [...parentPropertyList.map(property => property.name), dataTypeProperty.name],
+ isList : dataTypeProperty.type === PROPERTY_TYPES.LIST
});
} else if (this.isComplexType(dataTypeProperty.type)) {
this.fillPropertyDropdownWithMatchingChildProperties(dataTypeProperty, [...parentPropertyList])
@@ -390,23 +406,24 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (this.property.type === PROPERTY_TYPES.ANY) {
return true;
}
+ let validPropertyType = property.type === PROPERTY_TYPES.LIST ? property.schemaType : property.type;
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;
if(this.isComplexType(childSchemaType) && !this.compositionMap){
if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
- return property.type === PROPERTY_TYPES.STRING;
+ return validPropertyType === PROPERTY_TYPES.STRING;
}
- return property.type === childObject.type;
+ return validPropertyType === childObject.type;
}else{
- return property.type === this.property.schema.property.type;
+ return validPropertyType === this.property.schema.property.type;
}
}
if (!property.schema || !property.schema.property) {
return false;
}
- return property.type === this.property.type && this.property.schema.property.type === property.schema.property.type;
+ 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){
let typeToMatch = (<PropertyDeclareAPIModel> this.property).input.type;
@@ -414,10 +431,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
typeToMatch = PROPERTY_TYPES.STRING;
}
- return property.type === typeToMatch;
+ return validPropertyType === typeToMatch;
}
- return property.type === this.property.type;
+ return validPropertyType === this.property.type;
}
private getType(propertyPath:string[], type: string): string {
@@ -467,12 +484,32 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
onPropertySourceChange(): void {
this.selectedProperty.reset();
+ this.toscaIndex.reset();
if (!this.functionType || !this.propertySource.valid) {
return;
}
this.loadPropertyDropdown();
}
+ onPropertyValueChange(): void {
+ this.toscaIndexFlag = false;
+ this.toscaIndex.reset();
+ const selectedProperty: PropertyDropdownValue = this.selectedProperty.value;
+ if (selectedProperty.isList) {
+ this.toscaIndexFlag = true;
+ }
+ }
+
+ indexTokenChange(): void {
+ if ((this.toscaIndex.value).toLowerCase() === 'index') {
+ return;
+ }
+ let indexTokenValue = Number(this.toscaIndex.value);
+ if (isNaN(indexTokenValue)) {
+ this.toscaIndex.reset();
+ }
+ }
+
showPropertySourceDropdown(): boolean {
return this.isGetProperty() || this.isGetAttribute();
}
@@ -489,6 +526,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
return this.formGroup.get('selectedProperty') as FormControl;
}
+ private get toscaIndex(): FormControl {
+ return this.formGroup.get('toscaIndex') as FormControl;
+ }
+
}
export interface PropertyDropdownValue {
@@ -496,6 +537,7 @@ export interface PropertyDropdownValue {
propertyId: string;
propertyLabel: string;
propertyPath: Array<string>;
+ isList: boolean;
}
export interface ToscaGetFunctionValidationEvent {