@Input() allowClear: boolean = true;
@Input() compositionMap: boolean = false;
@Input() compositionMapKey: string = "";
+ @Input() complexListKey: string = null;
@Output() onValidFunction: EventEmitter<ToscaGetFunction> = new EventEmitter<ToscaGetFunction>();
@Output() onValidityChange: EventEmitter<ToscaFunctionValidationEvent> = new EventEmitter<ToscaFunctionValidationEvent>();
if (!this.isInitialized) {
return;
}
- this.emitValidityChange();
if (this.formGroup.valid) {
this.onValidFunction.emit(this.toscaFunctionForm.value);
}
private initToscaFunction(): void {
if (this.compositionMap && this.property.subPropertyToscaFunctions) {
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 (this.complexListKey != null) {
+ keyToFind = [this.complexListKey,this.compositionMapKey];
+ }
+ let subPropertyToscaFunction;
+ this.property.subPropertyToscaFunctions.forEach(subToscaFunction => {
+ if (subToscaFunction.subPropertyPath.toString() == keyToFind.toString()) {
+ subPropertyToscaFunction = subToscaFunction;
}
- return;
+ });
+
+ 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;
}
if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && (<PropertyDeclareAPIModel> this.property).propertiesName){
let propertiesPath = (<PropertyDeclareAPIModel> this.property).propertiesName.split("#");
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;
}
}
this.toscaFunctionForm.setValue(this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction);
- let type = this.property.toscaFunction.type;
+ let type = this.property.toscaFunction.type ? this.property.toscaFunction.type : this.toscaFunctionForm.value.type;
if (type == ToscaFunctionType.CUSTOM) {
- let name = (this.property.toscaFunction as ToscaCustomFunction).name;
- let test = this.customToscaFunctions.find(custToscFunc => _.isEqual(custToscFunc.name, name))
- if (test) {
+ let name = (this.toscaFunctionForm.value as ToscaCustomFunction).name;
+ let customToscaFunc = this.customToscaFunctions.find(custToscFunc => _.isEqual(custToscFunc.name, name))
+ if (customToscaFunc) {
this.toscaFunctionTypeForm.setValue(name);
} else {
this.toscaFunctionTypeForm.setValue("other");
this.toscaFunctions.push(ToscaFunctionType.GET_ATTRIBUTE);
this.toscaFunctions.push(ToscaFunctionType.GET_INPUT);
this.toscaFunctions.push(ToscaFunctionType.GET_PROPERTY);
- if (this.property.type === PROPERTY_TYPES.STRING || this.property.type === PROPERTY_TYPES.ANY) {
- this.toscaFunctions.push(ToscaFunctionType.CUSTOM);
- }
if ((this.property.type === PROPERTY_TYPES.STRING || this.property.type === PROPERTY_TYPES.ANY) && this.overridingType === undefined) {
this.toscaFunctions.push(ToscaFunctionType.CONCAT);
}
getCustomFunctionName():string {
let toscaFunctionType: CustomToscaFunction = this.getCustomToscaFunction();
- return toscaFunctionType.name;
+ let name = toscaFunctionType.name;
+ return name == 'other' ? '' : name;
}
getCustomFunctionType():string {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onCustomFunctionValidityChange(validationEvent: ToscaCustomFunctionValidationEvent): void {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onGetFunctionValidityChange(validationEvent: ToscaGetFunctionValidationEvent): void {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onYamlFunctionValidityChange(validationEvent: YamlFunctionValidationEvent): void {
} else {
this.toscaFunctionForm.setValue(undefined);
}
+ this.emitValidityChange();
}
onFunctionTypeChange(): void {