From 94ba0e5470a7a8fe1d9c26b667d839ad372144ef Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 25 Oct 2023 14:53:19 +0300 Subject: [PATCH] RED-7619 little cleanup --- .../src/app/models/file/annotation.wrapper.ts | 8 ------- .../annotation-card.component.html | 2 +- .../accept-recommendation-dialog.component.ts | 24 ++++++++----------- .../services/manual-redaction.service.ts | 24 ------------------- 4 files changed, 11 insertions(+), 47 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index f27200460..1bd215125 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -215,18 +215,10 @@ export class AnnotationWrapper implements IListable { return !!SuggestionAddSuperTypes[this.superType]; } - get isSuggestionAddDictionary() { - return this.superType === SuperTypes.SuggestionAddDictionary; - } - get isSuggestionRemove() { return !!SuggestionRemoveSuperTypes[this.superType]; } - get isSuggestionRemoveDictionary() { - return this.superType === SuperTypes.SuggestionRemoveDictionary; - } - get isSuggestionLegalBasisChange() { return this.superType === SuperTypes.SuggestionChangeLegalBasis; } diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html index 06eaabe85..b822419ff 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html @@ -1,7 +1,7 @@
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component.ts index 74f3c2cac..c5b7a91a6 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component.ts @@ -1,12 +1,12 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup, Validators } from '@angular/forms'; +import { Component, inject, Inject, OnInit } from '@angular/core'; +import { Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { PermissionsService } from '@services/permissions.service'; -import { Dictionary, Dossier } from '@red/domain'; -import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { BaseDialogComponent } from '@iqser/common-ui'; -import { DictionaryService } from '@services/entity-services/dictionary.service'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { Dictionary } from '@red/domain'; +import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; +import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { PermissionsService } from '@services/permissions.service'; import { acceptRecommendationTranslations } from '@translations/accept-recommendation-translations'; export interface AcceptRecommendationData { @@ -23,22 +23,18 @@ export interface AcceptRecommendationReturnType { templateUrl: './accept-recommendation-dialog.component.html', }) export class AcceptRecommendationDialogComponent extends BaseDialogComponent implements OnInit { + readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId); readonly dialogHeader: string; - possibleDictionaries: Dictionary[] = []; - private readonly _dossier: Dossier; - constructor( permissionsService: PermissionsService, - activeDossiersService: ActiveDossiersService, private readonly _dictionaryService: DictionaryService, protected readonly _dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) readonly data: AcceptRecommendationData, ) { super(_dialogRef); - this._dossier = activeDossiersService.find(this.data.dossierId); - const isDocumentAdmin = permissionsService.isApprover(this._dossier); + const isDocumentAdmin = permissionsService.isApprover(this.#dossier); this.dialogHeader = isDocumentAdmin ? acceptRecommendationTranslations.addToDictionary : acceptRecommendationTranslations.requestAddToDictionary; @@ -55,7 +51,7 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp } async ngOnInit() { - this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id); + this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this.#dossier.dossierTemplateId, this.#dossier.id); this.form.patchValue({ dictionary: this.possibleDictionaries.find(dict => dict.type === this.data.annotations[0].recommendationType)?.type, }); @@ -78,7 +74,7 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp ); } - private _getForm(): UntypedFormGroup { + private _getForm() { return this._formBuilder.group({ dictionary: [Validators.required], comment: [null], diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 2329b4354..6a6748e88 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -7,7 +7,6 @@ import { type AnnotationWrapper } from '@models/file/annotation.wrapper'; import { type ManualRedactionEntryType } from '@models/file/manual-redaction-entry.wrapper'; import type { DictionaryActions, - Dossier, IAddRedactionRequest, ILegalBasisChangeRequest, IManualAddResponse, @@ -16,8 +15,6 @@ import type { IResizeRequest, ManualRedactionActions, } from '@red/domain'; -import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; -import { PermissionsService } from '@services/permissions.service'; import { dictionaryActionsTranslations, manualRedactionActionsTranslations } from '@translations/annotation-actions-translations'; import { Roles } from '@users/roles'; import { NGXLogger } from 'ngx-logger'; @@ -41,15 +38,12 @@ function getMessage(action: ManualRedactionActions, isDictionary = false, error @Injectable() export class ManualRedactionService extends GenericService { protected readonly _defaultModelPath = 'manualRedaction'; - readonly #bulkRequest = `${this._defaultModelPath}/bulk/request`; readonly #bulkRedaction = `${this._defaultModelPath}/bulk/redaction`; constructor( private readonly _toaster: Toaster, private readonly _logger: NGXLogger, - private readonly _permissionsService: PermissionsService, private readonly _iqaerPermissionsService: IqserPermissionsService, - private readonly _activeDossiersService: ActiveDossiersService, ) { super(); } @@ -112,14 +106,6 @@ export class ManualRedactionService extends GenericService { return this.undo(annotationIds, dossierId, fileId).pipe(this.#showToast('undo', modifyDictionary)); } - declineOrRemove(annotationIds: List, dossierId: string, fileId: string, modifyDictionary = false) { - if (this._permissionsService.isApprover(this.#dossier(dossierId))) { - return this.decline(annotationIds, dossierId, fileId).pipe(this.#showToast('decline', modifyDictionary)); - } - - return this.undo(annotationIds, dossierId, fileId).pipe(this.#showToast('undo', modifyDictionary)); - } - removeRedaction(body: List, dossierId: string, fileId: string, removeFromDictionary = false, isHint = false) { return this.remove(body, dossierId, fileId).pipe(this.#showToast(!isHint ? 'remove' : 'remove-hint', removeFromDictionary)); } @@ -151,12 +137,6 @@ export class ManualRedactionService extends GenericService { ); } - requestLegalBasisChange(body: List, dossierId: string, fileId: string) { - return this._post(body, `${this.#bulkRequest}/legalBasis/${dossierId}/${fileId}`).pipe( - this.#log('Request legal basis change', body), - ); - } - approve(annotationIds: List, dossierId: string, fileId: string) { return this._post(annotationIds, `${this._defaultModelPath}/bulk/approve/${dossierId}/${fileId}`).pipe( this.#log('Approve', annotationIds), @@ -222,8 +202,4 @@ export class ManualRedactionService extends GenericService { }, }); } - - #dossier(dossierId: string): Dossier { - return this._activeDossiersService.find(dossierId); - } }