debug error messages validation form

This commit is contained in:
Tykayn 2021-11-12 18:17:49 +01:00 committed by tykayn
parent 7b82b5506d
commit 54f9e22070
4 changed files with 13 additions and 2 deletions

View File

@ -29,7 +29,7 @@ export class AdminConsultationComponent implements OnInit {
this._Activatedroute.paramMap.subscribe((params: ParamMap) => {
this.admin_key = params.get('admin_key');
if (!this.admin_key) {
this.router.navigate('page-not-found');
this.router.navigate(['page-not-found']);
}
this.apiService.getPollByAdminKey(this.admin_key).then(
(res) => {
@ -41,7 +41,7 @@ export class AdminConsultationComponent implements OnInit {
},
(err) => {
if (!this.admin_key) {
this.router.navigate('page-not-found');
this.router.navigate(['page-not-found']);
}
}
);

View File

@ -1,5 +1,6 @@
<div
class="validation-error-list padded"
*ngIf="(form.valid && !hide_on_valid) || !form.valid"
[ngClass]="{ 'has-background-warning': totalErrors > 0, 'has-background-success': totalErrors === 0 }"
>
<h1 class="title is-1">
@ -24,4 +25,10 @@
{{ m }}
</li>
</ul>
<div class="debug" *ngIf="!environment.production">
<pre>
{{ messages | json }}
</pre
>
</div>
</div>

View File

@ -1,6 +1,7 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { FormGroup, ValidationErrors } from '@angular/forms';
import { DOCUMENT } from '@angular/common';
import { environment } from '../../../../../../../environments/environment';
@Component({
selector: 'app-errors-list',
@ -12,6 +13,8 @@ export class ErrorsListComponent implements OnInit {
public totalErrors = 0;
public firstErrorId = '';
public messages = [];
public hide_on_valid = true;
public environment = environment;
constructor(@Inject(DOCUMENT) private document: any) {}

View File

@ -146,6 +146,7 @@
"lang": "Sélectionner la langue"
},
"validation": {
"required": "champ requis",
"You must enter a value": "You must enter a EEEE"
},
"You must enter a value": "You must enter a valueeeeeeee",