From 0745943c5bb7d2f51b81d37b38a5ae56bee7679c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Andr=C3=A9?= Date: Fri, 27 Aug 2021 16:45:20 +0200 Subject: [PATCH] Correction pour soumettre le formulaire avec la touche "Enter" --- .../app/login-user/login-user.component.html | 3 +- .../app/login-user/login-user.component.ts | 30 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Front/skydivelogs-app/src/app/login-user/login-user.component.html b/Front/skydivelogs-app/src/app/login-user/login-user.component.html index 126f907..4e92fc6 100644 --- a/Front/skydivelogs-app/src/app/login-user/login-user.component.html +++ b/Front/skydivelogs-app/src/app/login-user/login-user.component.html @@ -1,4 +1,5 @@ -
+

{{ 'LoginUser_Username' | translate }} diff --git a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts index ddd276c..09cb545 100644 --- a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts +++ b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts @@ -39,7 +39,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit { username: ['', [Validators.required, Validators.minLength(3)]], password: ['', [Validators.required]] }, - { updateOn: 'blur' } + { updateOn: 'submit' } ); // get return url from route parameters or default to '/' @@ -54,21 +54,19 @@ export class LoginUserComponent implements OnInit, AfterViewInit { onLoginSubmit() { this.submitted = true; - if (this.loginForm.invalid) { - return; + if (this.loginForm.valid) { + this.loading = true; + this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value) + .pipe(first()) + .subscribe( + data => { + this.router.navigate([this.returnUrl]); + }, + error => { + this.error = error; + this.loading = false; + } + ); } - - this.loading = true; - this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value) - .pipe(first()) - .subscribe( - data => { - this.router.navigate([this.returnUrl]); - }, - error => { - this.error = error; - this.loading = false; - } - ); } }