private openToscaGetFunctionModal() {
const modalTitle = this.translateService.translate('TOSCA_FUNCTION_MODAL_TITLE');
const modalButtons = [];
+ let disableSaveButtonFlag = true;
modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_SAVE'), 'blue',
() => {
const toscaGetFunction: ToscaGetFunction = modal.instance.dynamicContent.instance.toscaGetFunction;
this.clearCheckedInstancePropertyValue();
}
modal.instance.close();
- }
+ },
+ (): boolean => { return disableSaveButtonFlag }
));
const checkedInstanceProperty = this.buildCheckedInstanceProperty();
modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_CANCEL'), 'outline grey', () => {
'property': checkedInstanceProperty,
'componentInstanceMap': this.componentInstanceMap
});
+ modal.instance.dynamicContent.instance.onValidityChange.subscribe(isValid => {
+ disableSaveButtonFlag = !isValid;
+ });
modal.instance.open();
}
toscaGetFunctionValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
const toscaGetFunction: ToscaGetFunction = control.value;
+ const hasAnyValue = Object.keys(toscaGetFunction).find(key => toscaGetFunction[key]);
+ if (!hasAnyValue) {
+ return null;
+ }
const errors: ValidationErrors = {};
if (!toscaGetFunction.sourceName) {
errors.sourceName = { required: true };
this.loadToscaFunctions();
this.loadPropertySourceDropdown();
this.initToscaGetFunction();
+ }
+
+ private initToscaGetFunction(): void {
this.toscaGetFunctionForm.valueChanges.subscribe(toscaGetFunction => {
this.onValidityChange.emit(this.toscaGetFunctionForm.valid);
if (this.toscaGetFunctionForm.valid) {
this.onValidFunction.emit(toscaGetFunction);
}
- })
- }
-
- private initToscaGetFunction(): void {
+ });
if (!this.property.isToscaGetFunction()) {
return;
}
}
private resetForm(): void {
- this.toscaGetFunction = new ToscaGetFunction(undefined);
- this.toscaGetFunctionForm.setValue(new ToscaGetFunction(undefined));
+ this.toscaGetFunction = new ToscaGetFunction();
+ this.toscaGetFunctionForm.setValue(new ToscaGetFunction());
this.propertySource = undefined;
this.selectedProperty = undefined;
}