diff --git a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-clone-dossier-template-dialog.component.ts b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-clone-dossier-template-dialog.component.ts index afb0def58..1ea204a86 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-clone-dossier-template-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/dialogs/add-edit-dossier-template-dialog/add-edit-clone-dossier-template-dialog.component.ts @@ -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), diff --git a/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.html b/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.html index 922e222e0..7e58ccc7e 100644 --- a/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.html @@ -1,7 +1,7 @@
diff --git a/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.ts b/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.ts index eacc00d60..fa7e5483c 100644 --- a/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component.ts @@ -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)]], }); } } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts index 82c1608a5..030469dad 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts @@ -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(null), - comment: new FormControl(null), + comment: new FormControl(null, Validators.maxLength(4000)), type: new FormControl(sameType ? this.data.annotations[0].type : null), section: new FormControl(sameSection ? this.data.annotations[0].section : null), option: new FormControl(null), diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index e7273ee3e..689a725bb 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -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); } } diff --git a/libs/common-ui b/libs/common-ui index 6dc910c4c..14f4f0089 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 6dc910c4ca6182fd4f1d6746b1114ad5210229a8 +Subproject commit 14f4f0089850700284ba7f44a5fe80639f3cd68f