import {ToscaFunction} from "../../../../models/tosca-function";
import {ToscaConcatFunctionValidationEvent} from "./tosca-concat-function/tosca-concat-function.component";
import {ToscaCustomFunctionValidationEvent} from "./tosca-custom-function/tosca-custom-function.component";
-import {PROPERTY_TYPES, PROPERTY_DATA} from "../../../../utils/constants";
+import {PROPERTY_TYPES} from "../../../../utils/constants";
import {YamlFunctionValidationEvent} from "./yaml-function/yaml-function.component";
import {ToscaConcatFunction} from "../../../../models/tosca-concat-function";
import {ToscaCustomFunction} from "../../../../models/tosca-custom-function";
export class ToscaFunctionComponent implements OnInit, OnChanges {
@Input() property: PropertyBEModel;
+ @Input() overridingType: PROPERTY_TYPES;
+ @Input() inToscaFunction: ToscaFunction;
@Input() componentInstanceMap: Map<string, InstanceFeDetails> = new Map<string, InstanceFeDetails>();
@Input() customToscaFunctions: Array<CustomToscaFunction> = [];
@Input() allowClear: boolean = true;
ngOnInit(): void {
this.componentMetadata = this.workspaceService.metadata;
- this.toscaFunction = this.property.toscaFunction ? this.property.toscaFunction : undefined;
+ this.toscaFunction = this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction ? this.property.toscaFunction : undefined;
this.loadToscaFunctions();
this.formGroup.valueChanges.subscribe(() => {
if (!this.isInitialized) {
ngOnChanges(changes: SimpleChanges): void {
if (changes.property) {
this.resetForm();
- this.toscaFunction = this.property.toscaFunction ? this.property.toscaFunction : undefined;
+ this.toscaFunction = this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction ? this.property.toscaFunction : undefined;
this.initToscaFunction();
this.loadToscaFunctions();
this.emitValidityChange();
return;
}
}
-
if (!this.property.isToscaFunction()) {
return;
}
- this.toscaFunctionForm.setValue(this.property.toscaFunction);
+
+ this.toscaFunctionForm.setValue(this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction);
let type = this.property.toscaFunction.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 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);
+ this.toscaFunctionTypeForm.setValue(this.inToscaFunction ? this.inToscaFunction.type : type);
}
}
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) {
+ if ((this.property.type === PROPERTY_TYPES.STRING || this.property.type === PROPERTY_TYPES.ANY) && this.overridingType === undefined) {
this.toscaFunctions.push(ToscaFunctionType.CONCAT);
}
this.loadCustomToscaFunctions();
getCustomFunctionName():string {
let toscaFunctionType: CustomToscaFunction = this.getCustomToscaFunction();
- return toscaFunctionType.name;
+ let name = toscaFunctionType.name;
+ return name == 'other' ? '' : name;
+ }
+
+ getCustomFunctionType():string {
+ let toscaFunctionType: CustomToscaFunction = this.getCustomToscaFunction();
+ return toscaFunctionType.type;
}
isDefaultCustomFunction(): boolean {
isCustomSelected(): boolean {
let toscaFunctionType: CustomToscaFunction = this.getCustomToscaFunction();
- return toscaFunctionType && toscaFunctionType.type === ToscaFunctionType.CUSTOM;
+ return toscaFunctionType && (toscaFunctionType.type === ToscaFunctionType.CUSTOM || toscaFunctionType.type === ToscaFunctionType.GET_INPUT);
}
isGetFunctionSelected(): boolean {