import {ToscaFunction} from "../../../../models/tosca-function";
import {ToscaConcatFunctionValidationEvent} from "./tosca-concat-function/tosca-concat-function.component";
import {PROPERTY_TYPES} from "../../../../utils/constants";
+import {YamlFunctionValidationEvent} from "./yaml-function/yaml-function.component";
@Component({
selector: 'tosca-function',
this.onValidFunction.emit(this.toscaFunctionForm.value);
}
});
- this.initToscaGetFunction();
+ this.initToscaFunction();
this.emitValidityChange();
this.isInitialized = true;
}
return (!this.toscaFunctionForm.value && !this.toscaFunctionTypeForm.value) || this.formGroup.valid;
}
- private initToscaGetFunction() {
- if (!this.property.isToscaGetFunction()) {
+ private initToscaFunction() {
+ if (!this.property.isToscaFunction()) {
return;
}
this.toscaFunctionForm.setValue(this.property.toscaFunction);
if (this.property.type === PROPERTY_TYPES.STRING) {
this.toscaFunctions.push(ToscaFunctionType.CONCAT);
}
+ this.toscaFunctions.push(ToscaFunctionType.YAML);
}
private resetForm(): void {
return this.isGetInputSelected() || this.isGetPropertySelected() || this.isGetAttributeSelected();
}
+ isYamlFunctionSelected(): boolean {
+ return this.formGroup.get('toscaFunctionType').value === ToscaFunctionType.YAML;
+ }
+
onClearValues() {
this.resetForm();
}
}
}
+ onYamlFunctionValidityChange(validationEvent: YamlFunctionValidationEvent) {
+ if (validationEvent.isValid) {
+ this.toscaFunctionForm.setValue(validationEvent.value);
+ } else {
+ this.toscaFunctionForm.setValue(undefined);
+ }
+ }
+
private emitValidityChange() {
const isValid = this.validate();
this.onValidityChange.emit({
toscaFunction: isValid ? this.toscaFunctionForm.value : undefined
});
}
+
}
export class ToscaFunctionValidationEvent {