Commit a535e4c5 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

fix: [DLCM-1973] close user profile dialog when validate without validation error

parent deaccd98
......@@ -39,8 +39,8 @@
<button [mat-dialog-close]=""
mat-button
>{{labelTranslateEnum.close | translate}}</button>
<button (click)="formPresentational?.onSubmit()"
(onEnter)="formPresentational?.onSubmit()"
<button (click)="validate()"
(onEnter)="validate()"
[disabled]="(!formPresentational?.form.valid || !formPresentational?.form.dirty) && !this.validateEnable"
color="primary"
mat-flat-button
......
......@@ -17,16 +17,21 @@ import {
Person,
User,
} from "@models";
import {Store} from "@ngxs/store";
import {
Actions,
Store,
} from "@ngxs/store";
import {SharedAbstractDialog} from "@shared/components/dialogs/shared-abstract/shared-abstract.dialog";
import {SharedPersonFormPresentational} from "@shared/components/presentationals/shared-person-form/shared-person-form.presentational";
import {ResourceLogoNameSpace} from "@shared/stores/resource-logo/resource-logo-namespace.model";
import {Observable} from "rxjs";
import {tap} from "rxjs/operators";
import {
isNotNullNorUndefined,
isNullOrUndefined,
MemoizedUtil,
ModelFormControlEvent,
ofSolidifyActionCompleted,
} from "solidify-frontend";
@Component({
......@@ -35,7 +40,7 @@ import {
styleUrls: ["./user.dialog.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UserDialog extends SharedAbstractDialog<User> implements OnInit {
export class UserDialog extends SharedAbstractDialog<User, Person> implements OnInit {
currentPersonObs: Observable<Person> = MemoizedUtil.current(this._store, AppPersonState);
isLoadingPersonObs: Observable<boolean> = MemoizedUtil.isLoading(this._store, AppPersonState);
......@@ -49,7 +54,8 @@ export class UserDialog extends SharedAbstractDialog<User> implements OnInit {
constructor(protected readonly _store: Store,
protected readonly _dialogRef: MatDialogRef<UserDialog>,
@Inject(MAT_DIALOG_DATA) public user: User) {
@Inject(MAT_DIALOG_DATA) public user: User,
protected readonly _actions$: Actions) {
super(_dialogRef, user);
}
......@@ -81,4 +87,14 @@ export class UserDialog extends SharedAbstractDialog<User> implements OnInit {
activateButton($event: Event): void {
this.validateEnable = true;
}
validate(): void {
this.subscribe(this._actions$.pipe(
ofSolidifyActionCompleted(AppPersonAction.UpdateSuccess),
tap(result => {
this.submit(result.action.model);
}),
));
this.formPresentational?.onSubmit();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment