@@ -54,7 +54,7 @@
-
+
@@ -74,11 +74,11 @@
-
-
+
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts
index bb1727d50..ccb2c63ae 100644
--- a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts
+++ b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts
@@ -1,4 +1,4 @@
-import { Component, Inject, OnInit } from '@angular/core';
+import { Component, Inject, Injector, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppStateService } from '@state/app-state.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
@@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dictionary, Dossier, File, IAddRedactionRequest } from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service';
+import { BaseDialogComponent } from '@iqser/common-ui';
import { DictionaryService } from '@shared/services/dictionary.service';
export interface LegalBasisOption {
@@ -22,9 +23,7 @@ export interface LegalBasisOption {
templateUrl: './manual-annotation-dialog.component.html',
styleUrls: ['./manual-annotation-dialog.component.scss'],
})
-export class ManualAnnotationDialogComponent implements OnInit {
- redactionForm: FormGroup;
-
+export class ManualAnnotationDialogComponent extends BaseDialogComponent implements OnInit {
isDocumentAdmin: boolean;
isDictionaryRequest: boolean;
isFalsePositiveRequest: boolean;
@@ -43,15 +42,21 @@ export class ManualAnnotationDialogComponent implements OnInit {
private readonly _dossiersService: DossiersService,
private readonly _dictionaryService: DictionaryService,
public dialogRef: MatDialogRef
,
+ protected readonly _injector: Injector,
+ protected readonly _dialogRef: MatDialogRef,
@Inject(MAT_DIALOG_DATA) public data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; file: File },
) {
+ super(_injector, _dialogRef);
this._dossier = this._dossiersService.find(this.data.file.dossierId);
this.isDocumentAdmin = this._permissionsService.isApprover(this._dossier);
this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest;
- this.redactionForm = this._getForm();
+ this.form = this._getForm();
+ this.initialFormValue = this.form.getRawValue();
+
+ this.possibleDictionaries = this._possibleDictionaries;
}
get title() {
@@ -59,7 +64,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
}
get displayedDictionaryLabel() {
- const dictType = this.redactionForm.get('dictionary').value;
+ const dictType = this.form.get('dictionary').value;
if (dictType) {
return this.possibleDictionaries.find(d => d.type === dictType).label;
}
@@ -92,6 +97,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
}
async ngOnInit() {
+ super.ngOnInit();
this.possibleDictionaries = await this._getPossibleDictionaries();
const data = await this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId).toPromise();
@@ -104,11 +110,11 @@ export class ManualAnnotationDialogComponent implements OnInit {
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
}
- handleAddRedaction() {
+ save() {
this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
this._manualAnnotationService.addAnnotation(this.data.manualRedactionEntryWrapper.manualRedactionEntry, this.data.file).subscribe(
- response => this.dialogRef.close(new ManualAnnotationResponse(this.data.manualRedactionEntryWrapper, response)),
- () => this.dialogRef.close(),
+ response => this._dialogRef.close(new ManualAnnotationResponse(this.data.manualRedactionEntryWrapper, response)),
+ () => this._dialogRef.close(),
);
}
@@ -133,8 +139,8 @@ export class ManualAnnotationDialogComponent implements OnInit {
}
private _enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) {
- const legalOption: LegalBasisOption = this.redactionForm.get('reason').value;
- addRedactionRequest.type = this.redactionForm.get('dictionary').value;
+ const legalOption: LegalBasisOption = this.form.get('reason').value;
+ addRedactionRequest.type = this.form.get('dictionary').value;
if (legalOption) {
addRedactionRequest.reason = legalOption.description;
addRedactionRequest.legalBasis = legalOption.legalBasis;
@@ -146,11 +152,13 @@ export class ManualAnnotationDialogComponent implements OnInit {
if (!addRedactionRequest.reason) {
addRedactionRequest.reason = 'Dictionary Request';
}
- const commentValue = this.redactionForm.get('comment').value;
+ const commentValue = this.form.get('comment').value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
- addRedactionRequest.section = this.redactionForm.get('section').value;
- addRedactionRequest.value = addRedactionRequest.rectangle
- ? this.redactionForm.get('classification').value
- : addRedactionRequest.value;
+ addRedactionRequest.section = this.form.get('section').value;
+ addRedactionRequest.value = addRedactionRequest.rectangle ? this.form.get('classification').value : addRedactionRequest.value;
+ }
+
+ get disabled() {
+ return this.form.invalid;
}
}
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.html
index aeafba369..a1073bcd3 100644
--- a/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.html
+++ b/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.html
@@ -1,5 +1,5 @@
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.ts
index 3e6771b28..488438e46 100644
--- a/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.ts
+++ b/apps/red-ui/src/app/modules/dossier/dialogs/recategorize-image-dialog/recategorize-image-dialog.component.ts
@@ -1,17 +1,17 @@
-import { Component, Inject, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { Component, Inject, Injector, OnInit } from '@angular/core';
+import { FormBuilder, Validators } from '@angular/forms';
import { PermissionsService } from '@services/permissions.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { imageCategoriesTranslations } from '../../translations/image-categories-translations';
import { ImageCategory } from '../../models/image-category.model';
import { Dossier } from '@red/domain';
+import { BaseDialogComponent } from '@iqser/common-ui';
@Component({
templateUrl: './recategorize-image-dialog.component.html',
})
-export class RecategorizeImageDialogComponent implements OnInit {
- recategorizeImageForm: FormGroup;
+export class RecategorizeImageDialogComponent extends BaseDialogComponent implements OnInit {
isDocumentAdmin: boolean;
typeOptions: ImageCategory[] = ['signature', 'logo', 'formula', 'image'];
translations = imageCategoriesTranslations;
@@ -19,27 +19,32 @@ export class RecategorizeImageDialogComponent implements OnInit {
constructor(
private readonly _permissionsService: PermissionsService,
private readonly _formBuilder: FormBuilder,
- public dialogRef: MatDialogRef,
+ protected readonly _injector: Injector,
+ protected readonly _dialogRef: MatDialogRef,
@Inject(MAT_DIALOG_DATA) public data: { annotations: AnnotationWrapper[]; dossier: Dossier },
- ) {}
+ ) {
+ super(_injector, _dialogRef);
+ }
get changed(): boolean {
- return this.recategorizeImageForm.get('type').value !== this.data.annotations[0].type;
+ return this.form.get('type').value !== this.data.annotations[0].type;
}
ngOnInit() {
+ super.ngOnInit();
this.isDocumentAdmin = this._permissionsService.isApprover(this.data.dossier);
- this.recategorizeImageForm = this._formBuilder.group({
+ this.form = this._formBuilder.group({
type: [this.data.annotations[0].type, Validators.required],
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
});
+ this.initialFormValue = this.form.getRawValue();
}
save() {
- this.dialogRef.close({
- type: this.recategorizeImageForm.get('type').value,
- comment: this.recategorizeImageForm.get('comment').value,
+ this._dialogRef.close({
+ type: this.form.get('type').value,
+ comment: this.form.get('comment').value,
});
}
}
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.html
index 9f40bf629..287629e70 100644
--- a/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.html
+++ b/apps/red-ui/src/app/modules/dossier/dialogs/remove-annotations-dialog/remove-annotations-dialog.component.html
@@ -7,7 +7,7 @@
) | translate: { hint: data.hint }
}}
-