+ onPropertyValueChange(): void {
+ let toscaIndexFlag = false;
+ let nestedToscaFlag = false;
+ this.indexListValues = [];
+ let subPropertyDropdownList : Array<PropertyDropdownValue> = [];
+ const selectedProperty: PropertyDropdownValue = this.selectedProperty.value;
+ if (this.parentListTypeFlag && selectedProperty.isList) {
+ toscaIndexFlag = true;
+ if (selectedProperty.schemaType != null) {
+ nestedToscaFlag = true;
+ const dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, selectedProperty.schemaType);
+ this.addPropertiesToDropdown(dataTypeFound.properties, subPropertyDropdownList);
+ }
+ }
+ if (toscaIndexFlag || nestedToscaFlag) {
+ let indexValueMap : ToscaIndexObject = {indexFlag : toscaIndexFlag, nestedFlag : nestedToscaFlag, indexValue: "0", indexProperty: null, subPropertyArray: subPropertyDropdownList};
+ this.indexListValues.push(indexValueMap);
+ }
+ this.formValidation();
+ }
+
+ onSubPropertyValueChange(indexObject : ToscaIndexObject, elementIndex: number): void {
+ let toscaIndexFlag = false;
+ let nestedToscaFlag = false;
+ let subPropertyDropdownList : Array<PropertyDropdownValue> = [];
+ let selectedProperty: PropertyDropdownValue = indexObject.indexProperty;
+ if (selectedProperty.isList) {
+ toscaIndexFlag = true;
+ if (selectedProperty.schemaType != null) {
+ nestedToscaFlag = true;
+ const dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, selectedProperty.schemaType);
+ this.addPropertiesToDropdown(dataTypeFound.properties, subPropertyDropdownList);
+ }
+ }
+ if (toscaIndexFlag || nestedToscaFlag) {
+ let indexValueMap : ToscaIndexObject = {indexFlag : toscaIndexFlag, nestedFlag : nestedToscaFlag, indexValue: "0", indexProperty: null, subPropertyArray: subPropertyDropdownList};
+ if(!this.indexListValues[elementIndex+1]) {
+ this.indexListValues.push(indexValueMap);
+ } else {
+ this.indexListValues[elementIndex+1] = indexValueMap;
+ }
+ } else {
+ if(this.indexListValues[elementIndex+1]) {
+ this.indexListValues.splice((elementIndex+1),1);
+ }
+ }
+ this.formValidation();
+ }
+
+ indexTokenChange(indexObject : ToscaIndexObject): void {
+ if ((indexObject.indexValue).toLowerCase() === 'index' ) {
+ this.formValidation();
+ }
+
+ const regEx = /^[0-9]*$/;
+ const error = document.getElementById('error');
+
+ if (!(regEx.test(indexObject.indexValue)) && (indexObject.indexValue).toLowerCase() !== 'index') {
+ error.textContent='Invalid value - must be an integer or INDEX';
+ this.onValidityChange.emit({
+ isValid: false,
+ toscaGetFunction: this.formGroup.valid ? this.buildGetFunctionFromForm() : undefined
+ });
+ } else {
+ error.textContent='';
+ this.formValidation();
+ }
+ }
+