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 @@
-
+
@@ -23,12 +23,12 @@
-
- +
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/resize-annotation-dialog/resize-annotation-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html index 72a505f70..a83614b35 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html @@ -1,5 +1,5 @@
-
+
@@ -10,12 +10,12 @@
-
- +
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts index 51e55a1ef..14b6e1b64 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts @@ -1,34 +1,40 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, Injector, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { FormBuilder, Validators } from '@angular/forms'; import { PermissionsService } from '@services/permissions.service'; import { Dossier } from '@red/domain'; +import { BaseDialogComponent } from '@iqser/common-ui'; @Component({ templateUrl: './resize-annotation-dialog.component.html', }) -export class ResizeAnnotationDialogComponent implements OnInit { - resizeForm: FormGroup; +export class ResizeAnnotationDialogComponent extends BaseDialogComponent implements OnInit { isDocumentAdmin: boolean; constructor( private readonly _permissionsService: PermissionsService, private readonly _formBuilder: FormBuilder, - public dialogRef: MatDialogRef, + protected readonly _injector: Injector, + protected readonly _dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) private readonly _data: { dossier: Dossier }, - ) {} + ) { + super(_injector, _dialogRef); + } ngOnInit() { + super.ngOnInit(); + this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier); - this.resizeForm = this._formBuilder.group({ + this.form = this._formBuilder.group({ comment: this.isDocumentAdmin ? [null] : [null, Validators.required], }); + this.initialFormValue = this.form.getRawValue(); } save() { - this.dialogRef.close({ - comment: this.resizeForm.get('comment').value, + this._dialogRef.close({ + comment: this.form.get('comment').value, }); } }