RED-7649: Added toaster error messages and length limits to fields.
This commit is contained in:
parent
2c0033b8e1
commit
73699a4eea
@ -93,11 +93,11 @@ export class AddEditCloneDossierTemplateDialogComponent extends BaseDialogCompon
|
||||
}
|
||||
this._dialogRef.close(true);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error.status === HttpStatusCode.Conflict
|
||||
? _('add-edit-clone-dossier-template.error.conflict')
|
||||
: _('add-edit-clone-dossier-template.error.generic');
|
||||
this._toaster.error(message, { error });
|
||||
if (error.status === HttpStatusCode.Conflict) {
|
||||
this._toaster.error(_('add-edit-clone-dossier-template.error.conflict'), { error });
|
||||
} else {
|
||||
this._toaster.rawError(error.error.message);
|
||||
}
|
||||
}
|
||||
this._loadingService.stop();
|
||||
}
|
||||
@ -114,8 +114,8 @@ export class AddEditCloneDossierTemplateDialogComponent extends BaseDialogCompon
|
||||
|
||||
#getForm() {
|
||||
return this._formBuilder.group({
|
||||
name: [this.#getCloneName(), Validators.required],
|
||||
description: [this.dossierTemplate?.description],
|
||||
name: [this.#getCloneName(), [Validators.required, Validators.maxLength(255)]],
|
||||
description: [this.dossierTemplate?.description, Validators.maxLength(4000)],
|
||||
validFrom: [
|
||||
this.dossierTemplate?.validFrom ? dayjs(this.dossierTemplate?.validFrom).toDate() : null,
|
||||
this.#requiredIfValidator(() => this.hasValidFrom),
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<section class="dialog">
|
||||
<div
|
||||
[innerHTML]="
|
||||
'add-edit-justification.title' | translate : { type: data.justification ? 'edit' : 'create', name: data.justification?.name }
|
||||
'add-edit-justification.title' | translate: { type: data.justification ? 'edit' : 'create', name: data.justification?.name }
|
||||
"
|
||||
class="dialog-header heading-l"
|
||||
></div>
|
||||
|
||||
@ -29,19 +29,25 @@ export class AddEditJustificationDialogComponent extends BaseDialogComponent {
|
||||
|
||||
async save() {
|
||||
const dossierTemplateId = this.data.dossierTemplateId;
|
||||
|
||||
this._loadingService.start();
|
||||
await firstValueFrom(this._justificationService.createOrUpdate(this.form.getRawValue() as Justification, dossierTemplateId));
|
||||
await firstValueFrom(this._justificationService.loadAll(dossierTemplateId));
|
||||
try {
|
||||
await firstValueFrom(this._justificationService.createOrUpdate(this.form.getRawValue() as Justification, dossierTemplateId));
|
||||
await firstValueFrom(this._justificationService.loadAll(dossierTemplateId));
|
||||
this._dialogRef.close(true);
|
||||
} catch (error) {
|
||||
this._toaster.rawError(error.error.message);
|
||||
}
|
||||
this._loadingService.stop();
|
||||
this._dialogRef.close(true);
|
||||
}
|
||||
|
||||
private _getForm(): UntypedFormGroup {
|
||||
return this._formBuilder.group({
|
||||
name: [{ value: this.data.justification?.name, disabled: !!this.data.justification }, Validators.required],
|
||||
reason: [this.data.justification?.reason, Validators.required],
|
||||
description: [this.data.justification?.description, Validators.required],
|
||||
name: [
|
||||
{ value: this.data.justification?.name, disabled: !!this.data.justification },
|
||||
[Validators.required, Validators.maxLength(255)],
|
||||
],
|
||||
reason: [this.data.justification?.reason, [Validators.required, Validators.maxLength(4000)]],
|
||||
description: [this.data.justification?.description, [Validators.required, Validators.maxLength(4000)]],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormControl } from '@angular/forms';
|
||||
import { FormBuilder, FormControl, Validators } from '@angular/forms';
|
||||
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
||||
import { Dictionary, SuperTypes } from '@red/domain';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
@ -58,7 +58,7 @@ export class EditRedactionDialogComponent
|
||||
}
|
||||
|
||||
get disabled() {
|
||||
return this.showExtras ? !this.form.controls.reason.value : false;
|
||||
return this.form.invalid || (this.showExtras ? !this.form.controls.reason.value : false);
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
@ -126,7 +126,7 @@ export class EditRedactionDialogComponent
|
||||
const sameSection = this.data.annotations.every(annotation => annotation.section === this.data.annotations[0].section);
|
||||
return this._formBuilder.group({
|
||||
reason: new FormControl<LegalBasisOption>(null),
|
||||
comment: new FormControl<string>(null),
|
||||
comment: new FormControl<string>(null, Validators.maxLength(4000)),
|
||||
type: new FormControl<string>(sameType ? this.data.annotations[0].type : null),
|
||||
section: new FormControl<string>(sameSection ? this.data.annotations[0].section : null),
|
||||
option: new FormControl<LegalBasisOption>(null),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IqserDialog } from '@common-ui/dialog/iqser-dialog.service';
|
||||
import { getConfig } from '@iqser/common-ui';
|
||||
import { getConfig, Toaster } from '@iqser/common-ui';
|
||||
import { List, log } from '@iqser/common-ui/lib/utils';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
@ -60,6 +60,7 @@ export class AnnotationActionsService {
|
||||
private readonly _skippedService: SkippedService,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _toaster: Toaster,
|
||||
) {}
|
||||
|
||||
removeHighlights(highlights: AnnotationWrapper[]): void {
|
||||
@ -126,8 +127,12 @@ export class AnnotationActionsService {
|
||||
}
|
||||
|
||||
if (result.comment) {
|
||||
for (const a of annotations) {
|
||||
await this._manualRedactionService.addComment(result.comment, a.id, dossierId, fileId);
|
||||
try {
|
||||
for (const a of annotations) {
|
||||
await this._manualRedactionService.addComment(result.comment, a.id, dossierId, fileId);
|
||||
}
|
||||
} catch (error) {
|
||||
this._toaster.rawError(error.error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 6dc910c4ca6182fd4f1d6746b1114ad5210229a8
|
||||
Subproject commit 14f4f0089850700284ba7f44a5fe80639f3cd68f
|
||||
Loading…
x
Reference in New Issue
Block a user