form field validation (much better error messages)

This commit is contained in:
jonaswinkler
2021-01-03 13:09:16 +01:00
parent d7065bfde0
commit 677974924a
16 changed files with 102 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
<form [formGroup]="objectForm" class="needs-validation" novalidate (ngSubmit)="save()">
<form [formGroup]="objectForm" (ngSubmit)="save()">
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4>
<button type="button" class="close" aria-label="Close" (click)="cancel()">
@@ -7,10 +7,10 @@
</div>
<div class="modal-body">
<app-input-text i18n-title title="Name" formControlName="name"></app-input-text>
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
<app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match"></app-input-text>
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive" novalidate></app-input-check>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="cancel()" i18n>Cancel</button>

View File

@@ -25,10 +25,6 @@ export class CorrespondentEditDialogComponent extends EditDialogComponent<Paperl
return $localize`Edit correspondent`
}
getSaveErrorMessage(error: string) {
return $localize`Could not save correspondent: ${error}`
}
getForm(): FormGroup {
return new FormGroup({
name: new FormControl(''),

View File

@@ -1,4 +1,4 @@
<form [formGroup]="objectForm" class="needs-validation" novalidate (ngSubmit)="save()">
<form [formGroup]="objectForm" (ngSubmit)="save()">
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4>
<button type="button" class="close" aria-label="Close" (click)="cancel()">
@@ -7,7 +7,7 @@
</div>
<div class="modal-body">
<app-input-text i18n-title title="Name" formControlName="name"></app-input-text>
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
<app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match"></app-input-text>
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>

View File

@@ -25,10 +25,6 @@ export class DocumentTypeEditDialogComponent extends EditDialogComponent<Paperle
return $localize`Edit document type`
}
getSaveErrorMessage(error: string) {
return $localize`Could not save document type: ${error}`
}
getForm(): FormGroup {
return new FormGroup({
name: new FormControl(''),

View File

@@ -1,4 +1,4 @@
<form [formGroup]="objectForm" class="needs-validation" novalidate (ngSubmit)="save()">
<form [formGroup]="objectForm" (ngSubmit)="save()">
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4>
<button type="button" class="close" aria-label="Close" (click)="cancel()">
@@ -6,7 +6,7 @@
</button>
</div>
<div class="modal-body">
<app-input-text title="Name" formControlName="name"></app-input-text>
<app-input-text title="Name" formControlName="name" [error]="error?.name"></app-input-text>
<div class="form-group paperless-input-select">

View File

@@ -25,10 +25,6 @@ export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
return $localize`Edit tag`
}
getSaveErrorMessage(error: string) {
return $localize`Could not save tag: ${error}`
}
getForm(): FormGroup {
return new FormGroup({
name: new FormControl(''),