Skip to content
Snippets Groups Projects
Commit eca2665f authored by Albert Bruns's avatar Albert Bruns
Browse files

submit fix

parent d38c4d4f
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ export abstract class KeycloakFormService<T> { ...@@ -95,7 +95,7 @@ export abstract class KeycloakFormService<T> {
} }
_processInvalidForm(): Observable<StateResource<T>> { _processInvalidForm(): Observable<StateResource<T>> {
// this._showValidationErrorForAllInvalidControls(this.form); this._showValidationErrorForAllInvalidControls(this.form);
return of(createEmptyStateResource<T>()); return of(createEmptyStateResource<T>());
} }
...@@ -112,8 +112,7 @@ export abstract class KeycloakFormService<T> { ...@@ -112,8 +112,7 @@ export abstract class KeycloakFormService<T> {
} }
_showValidationErrorForAllInvalidControls(control: AbstractControl): void { _showValidationErrorForAllInvalidControls(control: AbstractControl): void {
// if (control.invalid) if (control.invalid) control.updateValueAndValidity();
control.updateValueAndValidity();
if (control instanceof FormGroup || control instanceof FormArray) { if (control instanceof FormGroup || control instanceof FormArray) {
Object.values(control.controls).forEach((control) => this._showValidationErrorForAllInvalidControls(control)); Object.values(control.controls).forEach((control) => this._showValidationErrorForAllInvalidControls(control));
} }
......
<ods-button-with-spinner <ods-button-with-spinner
[stateResource]="submitStateResource$ | async" [stateResource]="submitStateResource$ | async"
(clickEmitter)="submit()"
text="Speichern" text="Speichern"
dataTestId="save-button" dataTestId="save-button"
/> />
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
<form [formGroup]="formService.form"> <form [formGroup]="formService.form" (ngSubmit)="onSubmit()">
<ods-spinner [stateResource]="userStateResource$ | async"> <ods-spinner [stateResource]="userStateResource$ | async">
<div class="max-w-[960px]" data-test-id="user-content"> <div class="max-w-[960px]" data-test-id="user-content">
<admin-user-form-headline [isPatch]="isPatch" /> <admin-user-form-headline [isPatch]="isPatch" />
......
...@@ -71,4 +71,8 @@ export class UserFormComponent implements OnInit { ...@@ -71,4 +71,8 @@ export class UserFormComponent implements OnInit {
}), }),
); );
} }
onSubmit(): void {
this.formService.submit();
}
} }
...@@ -45,20 +45,13 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue ...@@ -45,20 +45,13 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue
this.changesSubscr = this.fieldControl.valueChanges.subscribe((val) => { this.changesSubscr = this.fieldControl.valueChanges.subscribe((val) => {
this.onChange(val); this.onChange(val);
// if (this.control?.control && this.control.control.getRawValue() !== this.fieldControl.value) { this.removeErrors();
// this.control.control.setValue(this.fieldControl.value, { emitEvent: false });
// }
this.fieldControl.setErrors(null);
this.invalidParams = [];
}); });
} }
ngOnInit(): void { ngOnInit(): void {
if (!this.statusSubscr && this.control) if (!this.statusSubscr && this.control)
this.statusSubscr = this.control.statusChanges.subscribe(() => { this.statusSubscr = this.control.statusChanges.subscribe(() => {
this.onChange(this.fieldControl.value);
this.fieldControl.updateValueAndValidity({ emitEvent: false });
this.control.control.updateValueAndValidity({ emitEvent: false });
this.setErrors(); this.setErrors();
}); });
} }
...@@ -98,6 +91,11 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue ...@@ -98,6 +91,11 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue
} }
} }
removeErrors(): void {
this.fieldControl.setErrors(null);
this._updateInvalidParams();
}
_updateInvalidParams(): void { _updateInvalidParams(): void {
this.invalidParams = this.invalidParams =
this.fieldControl.errors ? this.fieldControl.errors ?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment