remove file from action requests

This commit is contained in:
Dan Percic 2022-01-31 22:16:13 +02:00
parent 440063c3b3
commit 991e6a1b1c
11 changed files with 176 additions and 186 deletions

View File

@ -4,10 +4,9 @@ import { AppStateService } from '@state/app-state.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper'; import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
import { ManualAnnotationService } from '../../services/manual-annotation.service'; import { ManualAnnotationService } from '../../services/manual-annotation.service';
import { ManualAnnotationResponse } from '@models/file/manual-annotation-response';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { JustificationsService } from '@services/entity-services/justifications.service'; import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dictionary, Dossier, File, IAddRedactionRequest, IManualAddResponse } from '@red/domain'; import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { DictionaryService } from '@shared/services/dictionary.service'; import { DictionaryService } from '@shared/services/dictionary.service';
import { BaseDialogComponent } from '@iqser/common-ui'; import { BaseDialogComponent } from '@iqser/common-ui';
@ -20,7 +19,6 @@ export interface LegalBasisOption {
} }
@Component({ @Component({
selector: 'redaction-manual-annotation-dialog',
templateUrl: './manual-annotation-dialog.component.html', templateUrl: './manual-annotation-dialog.component.html',
styleUrls: ['./manual-annotation-dialog.component.scss'], styleUrls: ['./manual-annotation-dialog.component.scss'],
}) })
@ -44,10 +42,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
private readonly _dictionaryService: DictionaryService, private readonly _dictionaryService: DictionaryService,
protected readonly _injector: Injector, protected readonly _injector: Injector,
protected readonly _dialogRef: MatDialogRef<ManualAnnotationDialogComponent>, protected readonly _dialogRef: MatDialogRef<ManualAnnotationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; file: File }, @Inject(MAT_DIALOG_DATA) public data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string },
) { ) {
super(_injector, _dialogRef); super(_injector, _dialogRef);
this._dossier = this._dossiersService.find(this.data.file.dossierId); this._dossier = this._dossiersService.find(this.data.dossierId);
this.isDocumentAdmin = this._permissionsService.isApprover(this._dossier); this.isDocumentAdmin = this._permissionsService.isApprover(this._dossier);
this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE'; this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
@ -73,6 +71,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
return this.form.invalid; return this.form.invalid;
} }
get commentIsMandatory() {
return !this.isDocumentAdmin && !this.isDictionaryRequest;
}
async ngOnInit() { async ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.possibleDictionaries = await this._appStateService.getDictionariesOptions( this.possibleDictionaries = await this._appStateService.getDictionariesOptions(
@ -91,11 +93,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
save() { save() {
this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
this._manualAnnotationService.addAnnotation(this.data.manualRedactionEntryWrapper.manualRedactionEntry, this.data.file).subscribe( this._dialogRef.close(this.data.manualRedactionEntryWrapper);
(response: IManualAddResponse) =>
this._dialogRef.close(new ManualAnnotationResponse(this.data.manualRedactionEntryWrapper, response)),
() => this._dialogRef.close(),
);
} }
format(value: string) { format(value: string) {
@ -118,10 +116,6 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
}); });
} }
get commentIsMandatory() {
return !this.isDocumentAdmin && !this.isDictionaryRequest;
}
private _enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) { private _enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) {
const legalOption: LegalBasisOption = this.form.get('reason').value; const legalOption: LegalBasisOption = this.form.get('reason').value;
addRedactionRequest.type = this.form.get('dictionary').value; addRedactionRequest.type = this.form.get('dictionary').value;

View File

@ -32,7 +32,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.changeLegalBasis($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.changeLegalBasis($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canChangeLegalBasis" *ngIf="annotationPermissions.canChangeLegalBasis"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.edit-reason.label' | translate" [tooltip]="'annotation-actions.edit-reason.label' | translate"
@ -52,7 +52,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.acceptSuggestion($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.acceptSuggestion($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canAcceptSuggestion" *ngIf="annotationPermissions.canAcceptSuggestion"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.accept-suggestion.label' | translate" [tooltip]="'annotation-actions.accept-suggestion.label' | translate"
@ -61,7 +61,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.undoDirectAction($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.undoDirectAction($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canUndo" *ngIf="annotationPermissions.canUndo"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.undo' | translate" [tooltip]="'annotation-actions.undo' | translate"
@ -70,7 +70,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.rejectSuggestion($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.rejectSuggestion($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canRejectSuggestion" *ngIf="annotationPermissions.canRejectSuggestion"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.reject-suggestion' | translate" [tooltip]="'annotation-actions.reject-suggestion' | translate"
@ -79,7 +79,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.recategorizeImages($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.recategorizeImages($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canRecategorizeImage" *ngIf="annotationPermissions.canRecategorizeImage"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.recategorize-image' | translate" [tooltip]="'annotation-actions.recategorize-image' | translate"
@ -97,7 +97,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.forceAnnotation($event, annotations, file, annotationsChanged)" (action)="annotationActionsService.forceAnnotation($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canForceRedaction" *ngIf="annotationPermissions.canForceRedaction"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.force-redaction.label' | translate" [tooltip]="'annotation-actions.force-redaction.label' | translate"
@ -106,7 +106,7 @@
></iqser-circle-button> ></iqser-circle-button>
<iqser-circle-button <iqser-circle-button
(action)="annotationActionsService.forceAnnotation($event, annotations, file, annotationsChanged, true)" (action)="annotationActionsService.forceAnnotation($event, annotations, annotationsChanged, true)"
*ngIf="annotationPermissions.canForceHint" *ngIf="annotationPermissions.canForceHint"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.force-hint.label' | translate" [tooltip]="'annotation-actions.force-hint.label' | translate"

View File

@ -87,21 +87,15 @@ export class AnnotationActionsComponent implements OnChanges {
removeOrSuggestRemoveAnnotation($event: MouseEvent, removeFromDict: boolean) { removeOrSuggestRemoveAnnotation($event: MouseEvent, removeFromDict: boolean) {
$event.stopPropagation(); $event.stopPropagation();
this.annotationActionsService.removeOrSuggestRemoveAnnotation( this.annotationActionsService.removeOrSuggestRemoveAnnotation($event, this.annotations, removeFromDict, this.annotationsChanged);
$event,
this.annotations,
this.file,
removeFromDict,
this.annotationsChanged,
);
} }
markAsFalsePositive($event: MouseEvent) { markAsFalsePositive($event: MouseEvent) {
this.annotationActionsService.markAsFalsePositive($event, this.annotations, this.file, this.annotationsChanged); this.annotationActionsService.markAsFalsePositive($event, this.annotations, this.annotationsChanged);
} }
acceptRecommendation($event: MouseEvent) { acceptRecommendation($event: MouseEvent) {
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.file, this.annotationsChanged); this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.annotationsChanged);
} }
hideAnnotation($event: MouseEvent) { hideAnnotation($event: MouseEvent) {
@ -123,7 +117,7 @@ export class AnnotationActionsComponent implements OnChanges {
} }
acceptResize($event: MouseEvent) { acceptResize($event: MouseEvent) {
this.annotationActionsService.acceptResize($event, this.viewer, this.file, this.annotations[0], this.annotationsChanged); this.annotationActionsService.acceptResize($event, this.viewer, this.annotations[0], this.annotationsChanged);
} }
cancelResize($event: MouseEvent) { cancelResize($event: MouseEvent) {

View File

@ -651,10 +651,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
} }
private _loadDocument(blob: Blob, file: File) { private _loadDocument(blob: Blob, file: File) {
console.log(blob, file); this.instance.UI.loadDocument(blob, { filename: file?.filename ?? 'document.pdf' });
this.instance.UI.loadDocument(blob, {
filename: file?.filename ?? 'document.pdf',
});
} }
private _setReadyAndInitialState(): void { private _setReadyAndInitialState(): void {

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Dossier, File, StatusBarConfigs, User } from '@red/domain'; import { Dossier, File, StatusBarConfigs, User } from '@red/domain';
import { List, LoadingService, log, Toaster } from '@iqser/common-ui'; import { List, LoadingService, Toaster } from '@iqser/common-ui';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { FileAssignService } from '../../../../shared/services/file-assign.service'; import { FileAssignService } from '../../../../shared/services/file-assign.service';
import { workflowFileStatusTranslations } from '../../../../translations/file-status-translations'; import { workflowFileStatusTranslations } from '../../../../translations/file-status-translations';
@ -8,8 +8,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service'; import { UserService } from '@services/user.service';
import { FilesService } from '@services/entity-services/files.service'; import { FilesService } from '@services/entity-services/files.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs'; import { BehaviorSubject, combineLatest, firstValueFrom, Observable, switchMap } from 'rxjs';
import { BehaviorSubject, combineLatest, Observable, switchMap } from 'rxjs';
import { FilePreviewStateService } from '../../services/file-preview-state.service'; import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { distinctUntilChanged, map } from 'rxjs/operators'; import { distinctUntilChanged, map } from 'rxjs/operators';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
@ -81,9 +80,7 @@ export class UserManagementComponent {
); );
this.canAssignReviewer$ = combineLatest([this.stateService.file$, this._canAssignUser$, this._dossier$]).pipe( this.canAssignReviewer$ = combineLatest([this.stateService.file$, this._canAssignUser$, this._dossier$]).pipe(
log(),
map(([file, canAssignUser, dossier]) => !file.assignee && canAssignUser && dossier.hasReviewers), map(([file, canAssignUser, dossier]) => !file.assignee && canAssignUser && dossier.hasReviewers),
log(),
distinctUntilChanged(), distinctUntilChanged(),
); );

View File

@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppStateService } from '@state/app-state.service'; import { AppStateService } from '@state/app-state.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { Dictionary, Dossier, File } from '@red/domain'; import { Dictionary, Dossier } from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { BaseDialogComponent } from '@iqser/common-ui'; import { BaseDialogComponent } from '@iqser/common-ui';
import { DictionaryService } from '@shared/services/dictionary.service'; import { DictionaryService } from '@shared/services/dictionary.service';
@ -12,7 +12,7 @@ import { AnnotationWrapper } from '../../../../../../models/file/annotation.wrap
export interface AcceptRecommendationData { export interface AcceptRecommendationData {
readonly annotations: AnnotationWrapper[]; readonly annotations: AnnotationWrapper[];
readonly file: File; readonly dossierId: string;
} }
export interface AcceptRecommendationReturnType { export interface AcceptRecommendationReturnType {
@ -42,7 +42,7 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp
@Inject(MAT_DIALOG_DATA) readonly data: AcceptRecommendationData, @Inject(MAT_DIALOG_DATA) readonly data: AcceptRecommendationData,
) { ) {
super(_injector, _dialogRef); super(_injector, _dialogRef);
this._dossier = this._dossiersService.find(this.data.file.dossierId); this._dossier = this._dossiersService.find(this.data.dossierId);
this.isDocumentAdmin = this._permissionsService.isApprover(this._dossier); this.isDocumentAdmin = this._permissionsService.isApprover(this._dossier);
this.form = this._getForm(); this.form = this._getForm();
this.initialFormValue = this.form.getRawValue(); this.initialFormValue = this.form.getRawValue();

View File

@ -24,7 +24,7 @@ import { AnnotationDrawService } from './services/annotation-draw.service';
import { AnnotationProcessingService } from '../../services/annotation-processing.service'; import { AnnotationProcessingService } from '../../services/annotation-processing.service';
import { File, ViewMode } from '@red/domain'; import { File, ViewMode } from '@red/domain';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { combineLatest, firstValueFrom, Observable, timer } from 'rxjs'; import { combineLatest, firstValueFrom, Observable, of, timer } from 'rxjs';
import { UserPreferenceService } from '@services/user-preference.service'; import { UserPreferenceService } from '@services/user-preference.service';
import { PdfViewerDataService } from '../../services/pdf-viewer-data.service'; import { PdfViewerDataService } from '../../services/pdf-viewer-data.service';
import { download } from '@utils/file-download-utils'; import { download } from '@utils/file-download-utils';
@ -36,7 +36,7 @@ import { handleFilterDelta } from '@utils/filter-utils';
import { FilesService } from '@services/entity-services/files.service'; import { FilesService } from '@services/entity-services/files.service';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { FileManagementService } from '@services/entity-services/file-management.service'; import { FileManagementService } from '@services/entity-services/file-management.service';
import { filter, map, switchMap, tap } from 'rxjs/operators'; import { catchError, filter, map, switchMap, tap } from 'rxjs/operators';
import { FilesMapService } from '@services/entity-services/files-map.service'; import { FilesMapService } from '@services/entity-services/files-map.service';
import { WatermarkService } from '@shared/services/watermark.service'; import { WatermarkService } from '@shared/services/watermark.service';
import { ExcludedPagesService } from './services/excluded-pages.service'; import { ExcludedPagesService } from './services/excluded-pages.service';
@ -49,6 +49,7 @@ import { SkippedService } from './services/skipped.service';
import { FilePreviewStateService } from './services/file-preview-state.service'; import { FilePreviewStateService } from './services/file-preview-state.service';
import { FileDataModel } from '../../../../models/file/file-data.model'; import { FileDataModel } from '../../../../models/file/file-data.model';
import { filePreviewScreenProviders } from './utils'; import { filePreviewScreenProviders } from './utils';
import { ManualAnnotationService } from '../../services/manual-annotation.service';
import Annotation = Core.Annotations.Annotation; import Annotation = Core.Annotations.Annotation;
import PDFNet = Core.PDFNet; import PDFNet = Core.PDFNet;
@ -106,6 +107,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
private readonly _reanalysisService: ReanalysisService, private readonly _reanalysisService: ReanalysisService,
private readonly _errorService: ErrorService, private readonly _errorService: ErrorService,
private readonly _skippedService: SkippedService, private readonly _skippedService: SkippedService,
private readonly _manualAnnotationService: ManualAnnotationService,
readonly excludedPagesService: ExcludedPagesService, readonly excludedPagesService: ExcludedPagesService,
readonly viewModeService: ViewModeService, readonly viewModeService: ViewModeService,
readonly multiSelectService: MultiSelectService, readonly multiSelectService: MultiSelectService,
@ -188,7 +190,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
} }
async ngOnAttach(previousRoute: ActivatedRouteSnapshot): Promise<boolean> { async ngOnAttach(previousRoute: ActivatedRouteSnapshot): Promise<boolean> {
const file = this._filesMapService.get(this.dossierId, this.fileId); const file = await this.stateService.file;
if (!file.canBeOpened) { if (!file.canBeOpened) {
return this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]); return this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]);
} }
@ -205,9 +207,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
await this.userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId); await this.userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId);
this._subscribeToFileUpdates(); this._subscribeToFileUpdates();
const file = this._filesMapService.get(this.dossierId, this.fileId); const file = await this.stateService.file;
if (file?.analysisRequired) { if (file?.analysisRequired) {
await this._reanalysisService.reanalyzeFilesForDossier([this.fileId], this.dossierId, true).toPromise(); const reanalyzeFiles = this._reanalysisService.reanalyzeFilesForDossier([this.fileId], this.dossierId, true);
await firstValueFrom(reanalyzeFiles);
} }
this.displayPdfViewer = true; this.displayPdfViewer = true;
@ -278,18 +281,22 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
openManualAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) { openManualAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
this._ngZone.run(() => { this._ngZone.run(() => {
const file = this._filesMapService.get(this.dossierId, this.fileId);
this.dialogRef = this._dialogService.openDialog( this.dialogRef = this._dialogService.openDialog(
'manualAnnotation', 'manualAnnotation',
null, null,
{ manualRedactionEntryWrapper, file }, { manualRedactionEntryWrapper, dossierId: this.dossierId },
async (response: ManualAnnotationResponse) => { async (entryWrapper: ManualRedactionEntryWrapper) => {
const addAnnotation$ = this._manualAnnotationService
.addAnnotation(entryWrapper.manualRedactionEntry, this.dossierId, this.fileId)
.pipe(catchError(() => of(undefined)));
const addAnnotationResponse = await firstValueFrom(addAnnotation$);
const response = new ManualAnnotationResponse(entryWrapper, addAnnotationResponse);
if (response?.annotationId) { if (response?.annotationId) {
const annotation = this._instance.Core.annotationManager.getAnnotationById( const annotation = this._instance.Core.annotationManager.getAnnotationById(
response.manualRedactionEntryWrapper.rectId, response.manualRedactionEntryWrapper.rectId,
); );
this._instance.Core.annotationManager.deleteAnnotation(annotation); this._instance.Core.annotationManager.deleteAnnotation(annotation);
// await this._filesService.reload(this.dossierId, this.fileId).toPromise();
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
.map(p => p.page) .map(p => p.page)
.filter((item, pos, self) => self.indexOf(item) === pos); .filter((item, pos, self) => self.indexOf(item) === pos);

View File

@ -10,7 +10,7 @@ import { DossiersDialogService } from '../../../services/dossiers-dialog.service
import { BASE_HREF } from '../../../../../tokens'; import { BASE_HREF } from '../../../../../tokens';
import { UserService } from '@services/user.service'; import { UserService } from '@services/user.service';
import { Core, WebViewerInstance } from '@pdftron/webviewer'; import { Core, WebViewerInstance } from '@pdftron/webviewer';
import { Dossier, File, IAddRedactionRequest, ILegalBasisChangeRequest, IRectangle, IResizeRequest } from '@red/domain'; import { Dossier, IAddRedactionRequest, ILegalBasisChangeRequest, IRectangle, IResizeRequest } from '@red/domain';
import { toPosition } from '../../../utils/pdf-calculation.utils'; import { toPosition } from '../../../utils/pdf-calculation.utils';
import { AnnotationDrawService } from './annotation-draw.service'; import { AnnotationDrawService } from './annotation-draw.service';
import { translateQuads } from '@utils/pdf-coordinates'; import { translateQuads } from '@utils/pdf-coordinates';
@ -42,42 +42,42 @@ export class AnnotationActionsService {
private readonly _screenStateService: FilePreviewStateService, private readonly _screenStateService: FilePreviewStateService,
) {} ) {}
acceptSuggestion( private get _dossier(): Dossier {
$event: MouseEvent, return this._dossiersService.find(this._screenStateService.dossierId);
annotations: AnnotationWrapper[], }
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>, acceptSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
) {
$event?.stopPropagation(); $event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.approve(annotation.id, file, annotation.isModifyDictionary), this._manualAnnotationService.approve(annotation.id, dossierId, fileId, annotation.isModifyDictionary),
annotation, annotation,
annotationsChanged, annotationsChanged,
); );
}); });
} }
rejectSuggestion( rejectSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
$event?.stopPropagation(); $event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit(this._manualAnnotationService.declineOrRemoveRequest(annotation, file), annotation, annotationsChanged); this._processObsAndEmit(
this._manualAnnotationService.declineOrRemoveRequest(annotation, dossierId, fileId),
annotation,
annotationsChanged,
);
}); });
} }
forceAnnotation( forceAnnotation(
$event: MouseEvent, $event: MouseEvent,
annotations: AnnotationWrapper[], annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>, annotationsChanged: EventEmitter<AnnotationWrapper>,
hint: boolean = false, hint: boolean = false,
) { ) {
const data = { dossier: this._dossier(file), hint }; const { dossierId, fileId } = this._screenStateService;
const data = { dossier: this._dossier, hint };
this._dialogService.openDialog('forceAnnotation', $event, data, (request: ILegalBasisChangeRequest) => { this._dialogService.openDialog('forceAnnotation', $event, data, (request: ILegalBasisChangeRequest) => {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
@ -86,7 +86,8 @@ export class AnnotationActionsService {
...request, ...request,
annotationId: annotation.id, annotationId: annotation.id,
}, },
file, dossierId,
fileId,
), ),
annotation, annotation,
annotationsChanged, annotationsChanged,
@ -95,22 +96,19 @@ export class AnnotationActionsService {
}); });
} }
changeLegalBasis( changeLegalBasis($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event: MouseEvent, const { dossierId, fileId } = this._screenStateService;
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
this._dialogService.openDialog( this._dialogService.openDialog(
'changeLegalBasis', 'changeLegalBasis',
$event, $event,
{ annotations, dossier: this._dossier(file) }, { annotations, dossier: this._dossier },
(data: { comment: string; legalBasis: string; section: string; value: string }) => { (data: { comment: string; legalBasis: string; section: string; value: string }) => {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.changeLegalBasis( this._manualAnnotationService.changeLegalBasis(
annotation.annotationId, annotation.annotationId,
file, dossierId,
fileId,
data.section, data.section,
data.value, data.value,
data.legalBasis, data.legalBasis,
@ -127,20 +125,26 @@ export class AnnotationActionsService {
removeOrSuggestRemoveAnnotation( removeOrSuggestRemoveAnnotation(
$event: MouseEvent, $event: MouseEvent,
annotations: AnnotationWrapper[], annotations: AnnotationWrapper[],
file: File,
removeFromDictionary: boolean, removeFromDictionary: boolean,
annotationsChanged: EventEmitter<AnnotationWrapper>, annotationsChanged: EventEmitter<AnnotationWrapper>,
) { ) {
const data = { const data = {
annotationsToRemove: annotations, annotationsToRemove: annotations,
removeFromDictionary, removeFromDictionary,
dossier: this._dossier(file), dossier: this._dossier,
hint: annotations[0].hintDictionary, hint: annotations[0].hintDictionary,
}; };
const { dossierId, fileId } = this._screenStateService;
this._dialogService.openDialog('removeAnnotations', $event, data, (result: { comment: string }) => { this._dialogService.openDialog('removeAnnotations', $event, data, (result: { comment: string }) => {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.removeOrSuggestRemoveAnnotation(annotation, file, removeFromDictionary, result.comment), this._manualAnnotationService.removeOrSuggestRemoveAnnotation(
annotation,
dossierId,
fileId,
removeFromDictionary,
result.comment,
),
annotation, annotation,
annotationsChanged, annotationsChanged,
); );
@ -148,28 +152,19 @@ export class AnnotationActionsService {
}); });
} }
markAsFalsePositive( markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._markAsFalsePositive($event, annotation, file, this._getFalsePositiveText(annotation), annotationsChanged); this._markAsFalsePositive($event, annotation, this._getFalsePositiveText(annotation), annotationsChanged);
}); });
} }
recategorizeImages( recategorizeImages($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event: MouseEvent, const data = { annotations, dossier: this._dossier };
annotations: AnnotationWrapper[], const { dossierId, fileId } = this._screenStateService;
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
const data = { annotations, dossier: this._dossier(file) };
this._dialogService.openDialog('recategorizeImage', $event, data, (res: { type: string; comment: string }) => { this._dialogService.openDialog('recategorizeImage', $event, data, (res: { type: string; comment: string }) => {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.recategorizeImg(annotation.annotationId, file, res.type, res.comment), this._manualAnnotationService.recategorizeImg(annotation.annotationId, dossierId, fileId, res.type, res.comment),
annotation, annotation,
annotationsChanged, annotationsChanged,
); );
@ -177,37 +172,37 @@ export class AnnotationActionsService {
}); });
} }
undoDirectAction( undoDirectAction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
$event?.stopPropagation(); $event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit(this._manualAnnotationService.undoRequest(annotation, file), annotation, annotationsChanged); this._processObsAndEmit(
this._manualAnnotationService.undoRequest(annotation, dossierId, fileId),
annotation,
annotationsChanged,
);
}); });
} }
convertRecommendationToAnnotation( convertRecommendationToAnnotation(
$event: any, $event: any,
recommendations: AnnotationWrapper[], recommendations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>, annotationsChanged: EventEmitter<AnnotationWrapper>,
) { ) {
$event?.stopPropagation(); $event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>( const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>(
AcceptRecommendationDialogComponent, AcceptRecommendationDialogComponent,
{ ...defaultDialogConfig, autoFocus: true, data: { annotations: recommendations, file } }, { ...defaultDialogConfig, autoFocus: true, data: { annotations: recommendations, dossierId } },
); );
const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotations)); const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotations));
dialogClosed.subscribe(({ annotations, comment: commentText }) => { dialogClosed.subscribe(({ annotations, comment: commentText }) => {
const comment = commentText ? { text: commentText } : undefined; const comment = commentText ? { text: commentText } : undefined;
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.addRecommendation(annotation, file, comment), this._manualAnnotationService.addRecommendation(annotation, dossierId, fileId, comment),
annotation, annotation,
annotationsChanged, annotationsChanged,
); );
@ -242,8 +237,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'), img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.resize-accept.label'), title: this._translateService.instant('annotation-actions.resize-accept.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.acceptResize(null, viewer, file, firstAnnotation, annotationsChanged); this.acceptResize(null, viewer, firstAnnotation, annotationsChanged);
}), }),
}); });
availableActions.push({ availableActions.push({
@ -273,8 +268,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/edit.svg'), img: this._convertPath('/assets/icons/general/edit.svg'),
title: this._translateService.instant('annotation-actions.edit-reason.label'), title: this._translateService.instant('annotation-actions.edit-reason.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.changeLegalBasis(null, annotations, file, annotationsChanged); this.changeLegalBasis(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -286,8 +281,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-down.svg'), img: this._convertPath('/assets/icons/general/thumb-down.svg'),
title: this._translateService.instant('annotation-actions.recategorize-image'), title: this._translateService.instant('annotation-actions.recategorize-image'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.recategorizeImages(null, annotations, file, annotationsChanged); this.recategorizeImages(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -302,8 +297,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/remove-from-dict.svg'), img: this._convertPath('/assets/icons/general/remove-from-dict.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.remove-from-dict'), title: this._translateService.instant('annotation-actions.remove-annotation.remove-from-dict'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, file, true, annotationsChanged); this.removeOrSuggestRemoveAnnotation(null, annotations, true, annotationsChanged);
}), }),
}); });
} }
@ -315,8 +310,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'), img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.accept-recommendation.label'), title: this._translateService.instant('annotation-actions.accept-recommendation.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.convertRecommendationToAnnotation(null, annotations, file, annotationsChanged); this.convertRecommendationToAnnotation(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -328,8 +323,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'), img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.accept-suggestion.label'), title: this._translateService.instant('annotation-actions.accept-suggestion.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.acceptSuggestion(null, annotations, file, annotationsChanged); this.acceptSuggestion(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -341,8 +336,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/undo.svg'), img: this._convertPath('/assets/icons/general/undo.svg'),
title: this._translateService.instant('annotation-actions.undo'), title: this._translateService.instant('annotation-actions.undo'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.undoDirectAction(null, annotations, file, annotationsChanged); this.undoDirectAction(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -354,8 +349,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-down.svg'), img: this._convertPath('/assets/icons/general/thumb-down.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.false-positive'), title: this._translateService.instant('annotation-actions.remove-annotation.false-positive'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.markAsFalsePositive(null, annotations, file, annotationsChanged); this.markAsFalsePositive(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -367,8 +362,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-up.svg'), img: this._convertPath('/assets/icons/general/thumb-up.svg'),
title: this._translateService.instant('annotation-actions.force-redaction.label'), title: this._translateService.instant('annotation-actions.force-redaction.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.forceAnnotation(null, annotations, file, annotationsChanged); this.forceAnnotation(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -380,8 +375,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-up.svg'), img: this._convertPath('/assets/icons/general/thumb-up.svg'),
title: this._translateService.instant('annotation-actions.force-hint.label'), title: this._translateService.instant('annotation-actions.force-hint.label'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.forceAnnotation(null, annotations, file, annotationsChanged, true); this.forceAnnotation(null, annotations, annotationsChanged, true);
}), }),
}); });
} }
@ -393,8 +388,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/close.svg'), img: this._convertPath('/assets/icons/general/close.svg'),
title: this._translateService.instant('annotation-actions.reject-suggestion'), title: this._translateService.instant('annotation-actions.reject-suggestion'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.rejectSuggestion(null, annotations, file, annotationsChanged); this.rejectSuggestion(null, annotations, annotationsChanged);
}), }),
}); });
} }
@ -409,8 +404,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/trash.svg'), img: this._convertPath('/assets/icons/general/trash.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.only-here'), title: this._translateService.instant('annotation-actions.remove-annotation.only-here'),
onClick: () => onClick: () =>
this._runForCurrentFile(file => { this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, file, false, annotationsChanged); this.removeOrSuggestRemoveAnnotation(null, annotations, false, annotationsChanged);
}), }),
}); });
} }
@ -443,11 +438,11 @@ export class AnnotationActionsService {
acceptResize( acceptResize(
$event: MouseEvent, $event: MouseEvent,
viewer: WebViewerInstance, viewer: WebViewerInstance,
file: File,
annotationWrapper: AnnotationWrapper, annotationWrapper: AnnotationWrapper,
annotationsChanged?: EventEmitter<AnnotationWrapper>, annotationsChanged?: EventEmitter<AnnotationWrapper>,
) { ) {
const data = { dossier: this._dossier(file) }; const data = { dossier: this._dossier };
const fileId = this._screenStateService.fileId;
this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string }) => { this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string }) => {
const textAndPositions = await this._extractTextAndPositions(viewer, annotationWrapper.id); const textAndPositions = await this._extractTextAndPositions(viewer, annotationWrapper.id);
const text = const text =
@ -461,7 +456,7 @@ export class AnnotationActionsService {
}; };
this._processObsAndEmit( this._processObsAndEmit(
this._manualAnnotationService.resizeOrSuggestToResize(annotationWrapper, file, resizeRequest), this._manualAnnotationService.resizeOrSuggestToResize(annotationWrapper, data.dossier.dossierId, fileId, resizeRequest),
annotationWrapper, annotationWrapper,
annotationsChanged, annotationsChanged,
); );
@ -486,17 +481,6 @@ export class AnnotationActionsService {
annotationsChanged.emit(annotationWrapper); annotationsChanged.emit(annotationWrapper);
} }
private async _runForCurrentFile(func: (file: File) => unknown): Promise<void> {
const file = await this._screenStateService.file;
this._ngZone.run(() => {
func(file);
});
}
private _dossier(file: File): Dossier {
return this._dossiersService.find(file.dossierId);
}
private _processObsAndEmit( private _processObsAndEmit(
obs: Observable<unknown>, obs: Observable<unknown>,
annotation: AnnotationWrapper, annotation: AnnotationWrapper,
@ -531,7 +515,6 @@ export class AnnotationActionsService {
private _markAsFalsePositive( private _markAsFalsePositive(
$event: MouseEvent, $event: MouseEvent,
annotation: AnnotationWrapper, annotation: AnnotationWrapper,
file: File,
text: string, text: string,
annotationsChanged: EventEmitter<AnnotationWrapper>, annotationsChanged: EventEmitter<AnnotationWrapper>,
) { ) {
@ -544,8 +527,13 @@ export class AnnotationActionsService {
falsePositiveRequest.positions = annotation.positions; falsePositiveRequest.positions = annotation.positions;
falsePositiveRequest.addToDictionary = true; falsePositiveRequest.addToDictionary = true;
falsePositiveRequest.comment = { text: 'False Positive' }; falsePositiveRequest.comment = { text: 'False Positive' };
const { dossierId, fileId } = this._screenStateService;
this._processObsAndEmit(this._manualAnnotationService.addAnnotation(falsePositiveRequest, file), annotation, annotationsChanged); this._processObsAndEmit(
this._manualAnnotationService.addAnnotation(falsePositiveRequest, dossierId, fileId),
annotation,
annotationsChanged,
);
} }
private _convertPath(path: string): string { private _convertPath(path: string): string {

View File

@ -2,7 +2,6 @@ import { Injectable, Injector } from '@angular/core';
import { AppStateService } from '@state/app-state.service'; import { AppStateService } from '@state/app-state.service';
import { import {
Dossier, Dossier,
File,
IAddRedactionRequest, IAddRedactionRequest,
IApproveRequest, IApproveRequest,
IImageRecategorizationRequest, IImageRecategorizationRequest,
@ -57,14 +56,15 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
_makeRequest( _makeRequest(
mode: AnnotationActionMode, mode: AnnotationActionMode,
file: File, dossierId: string,
fileId: string,
body: any, body: any,
secondParam: any = null, secondParam: any = null,
modifyDictionary = false, modifyDictionary = false,
): Observable<unknown> { ): Observable<unknown> {
const obs = !secondParam const obs = !secondParam
? this[this.CONFIG[mode]](body, file.dossierId, file.id) ? this[this.CONFIG[mode]](body, dossierId, fileId)
: this[this.CONFIG[mode]](body, secondParam, file.dossierId, file.id); : this[this.CONFIG[mode]](body, secondParam, dossierId, fileId);
return obs.pipe( return obs.pipe(
tap({ tap({
@ -74,7 +74,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
this._toaster.error(this._getMessage(mode, modifyDictionary, true, isConflict), { this._toaster.error(this._getMessage(mode, modifyDictionary, true, isConflict), {
error, error,
params: { params: {
dictionaryName: this._appStateService.getDictionary(body.type, this._dossier(file).dossierTemplateId).label, dictionaryName: this._appStateService.getDictionary(body.type, this._dossier(dossierId).dossierTemplateId)
.label,
content: body.value, content: body.value,
}, },
positionClass: 'toast-file-preview', positionClass: 'toast-file-preview',
@ -96,7 +97,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
return super.delete({}, url); return super.delete({}, url);
} }
addRecommendation(annotation: AnnotationWrapper, file: File, comment = { text: 'Accepted Recommendation' }) { addRecommendation(annotation: AnnotationWrapper, dossierId: string, fileId: string, comment = { text: 'Accepted Recommendation' }) {
const manualRedactionEntry: IAddRedactionRequest = {}; const manualRedactionEntry: IAddRedactionRequest = {};
manualRedactionEntry.addToDictionary = true; manualRedactionEntry.addToDictionary = true;
// set the ID as reason, so we can hide the suggestion // set the ID as reason, so we can hide the suggestion
@ -105,76 +106,89 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
manualRedactionEntry.positions = annotation.positions; manualRedactionEntry.positions = annotation.positions;
manualRedactionEntry.type = annotation.recommendationType; manualRedactionEntry.type = annotation.recommendationType;
manualRedactionEntry.comment = comment; manualRedactionEntry.comment = comment;
return this.addAnnotation(manualRedactionEntry, file); return this.addAnnotation(manualRedactionEntry, dossierId, fileId);
} }
// /manualRedaction/request/legalBasis // /manualRedaction/request/legalBasis
changeLegalBasis(annotationId: string, file: File, section: string, value: string, legalBasis: string, comment?: string) { changeLegalBasis(
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) annotationId: string,
dossierId: string,
fileId: string,
section: string,
value: string,
legalBasis: string,
comment?: string,
) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId))
? 'change-legal-basis' ? 'change-legal-basis'
: 'request-change-legal-basis'; : 'request-change-legal-basis';
return this._makeRequest(mode, file, { annotationId, legalBasis, comment, section, value }); return this._makeRequest(mode, dossierId, fileId, { annotationId, legalBasis, comment, section, value });
} }
// this wraps // this wraps
// /manualRedaction/redaction/legalBasisChange // /manualRedaction/redaction/legalBasisChange
// /manualRedaction/request/recategorize // /manualRedaction/request/recategorize
recategorizeImg(annotationId: string, file: File, type: string, comment: string) { recategorizeImg(annotationId: string, dossierId: string, fileId: string, type: string, comment: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId))
? 'recategorize-image' ? 'recategorize-image'
: 'request-image-recategorization'; : 'request-image-recategorization';
return this._makeRequest(mode, file, { annotationId, type, comment }); return this._makeRequest(mode, dossierId, fileId, { annotationId, type, comment });
} }
// this wraps // this wraps
// /manualRedaction/redaction/recategorize // /manualRedaction/redaction/recategorize
// /manualRedaction/request/add // /manualRedaction/request/add
addAnnotation(manualRedactionEntry: IAddRedactionRequest, file: File) { addAnnotation(manualRedactionEntry: IAddRedactionRequest, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'add' : 'suggest'; const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId)) ? 'add' : 'suggest';
return this._makeRequest(mode, file, manualRedactionEntry, null, manualRedactionEntry.addToDictionary); return this._makeRequest(mode, dossierId, fileId, manualRedactionEntry, null, manualRedactionEntry.addToDictionary);
} }
// this wraps // this wraps
// /manualRedaction/redaction/add // /manualRedaction/redaction/add
// /manualRedaction/request/force // /manualRedaction/request/force
force(request: ILegalBasisChangeRequest, file: File) { force(request: ILegalBasisChangeRequest, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId))
? 'force-redaction' ? 'force-redaction'
: 'request-force-redaction'; : 'request-force-redaction';
return this._makeRequest(mode, file, request); return this._makeRequest(mode, dossierId, fileId, request);
} }
// this wraps // this wraps
// /manualRedaction/redaction/force // /manualRedaction/redaction/force
// /manualRedaction/approve // /manualRedaction/approve
approve(annotationId: string, file: File, addToDictionary: boolean = false) { approve(annotationId: string, dossierId: string, fileId: string, addToDictionary: boolean = false) {
// for only here - approve the request // for only here - approve the request
return this._makeRequest('approve', file, { addOrRemoveFromDictionary: addToDictionary }, annotationId, addToDictionary); return this._makeRequest(
'approve',
dossierId,
fileId,
{ addOrRemoveFromDictionary: addToDictionary },
annotationId,
addToDictionary,
);
} }
// this wraps // this wraps
undoRequest(annotationWrapper: AnnotationWrapper, file: File) {
return this._makeRequest('undo', file, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
}
// /manualRedaction/undo // /manualRedaction/undo
declineOrRemoveRequest(annotationWrapper: AnnotationWrapper, file: File) { undoRequest(annotationWrapper: AnnotationWrapper, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'decline' : 'undo'; return this._makeRequest('undo', dossierId, fileId, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
return this._makeRequest(mode, file, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
} }
// this wraps // this wraps
// /manualRedaction/decline/remove // /manualRedaction/decline/remove
declineOrRemoveRequest(annotationWrapper: AnnotationWrapper, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId)) ? 'decline' : 'undo';
return this._makeRequest(mode, dossierId, fileId, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
}
// /manualRedaction/request/resize/ // /manualRedaction/request/resize/
resizeOrSuggestToResize(annotationWrapper: AnnotationWrapper, file: File, resizeRequest: IResizeRequest) { resizeOrSuggestToResize(annotationWrapper: AnnotationWrapper, dossierId: string, fileId: string, resizeRequest: IResizeRequest) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'resize' : 'request-resize'; const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId)) ? 'resize' : 'request-resize';
return this._makeRequest(mode, file, resizeRequest); return this._makeRequest(mode, dossierId, fileId, resizeRequest);
} }
// this wraps // this wraps
@ -183,7 +197,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
// /manualRedaction/request/remove/ // /manualRedaction/request/remove/
removeOrSuggestRemoveAnnotation( removeOrSuggestRemoveAnnotation(
annotationWrapper: AnnotationWrapper, annotationWrapper: AnnotationWrapper,
file: File, dossierId: string,
fileId: string,
removeFromDictionary: boolean = false, removeFromDictionary: boolean = false,
comment: string, comment: string,
) { ) {
@ -191,7 +206,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
body: any, body: any,
removeDict = false; removeDict = false;
if (this._permissionsService.isApprover(this._dossier(file))) { if (this._permissionsService.isApprover(this._dossier(dossierId))) {
// if it was something manual simply decline the existing request // if it was something manual simply decline the existing request
mode = 'remove'; mode = 'remove';
body = { body = {
@ -210,7 +225,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
removeDict = removeFromDictionary; removeDict = removeFromDictionary;
} }
return this._makeRequest(mode, file, body, null, removeDict); return this._makeRequest(mode, dossierId, fileId, body, null, removeDict);
} }
// this wraps // this wraps
@ -353,8 +368,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
return this._post(body, url); return this._post(body, url);
} }
private _dossier(file: File): Dossier { private _dossier(dossierId: string): Dossier {
return this._dossiersService.find(file.dossierId); return this._dossiersService.find(dossierId);
} }
private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error = false, isConflict = false) { private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error = false, isConflict = false) {

View File

@ -138,7 +138,7 @@ export class PdfViewerUtils {
this._annotationManager.deselectAnnotations(ann); this._annotationManager.deselectAnnotations(ann);
} }
private _navigateToPage(pageNumber) { private _navigateToPage(pageNumber: number) {
if (this._currentInternalPage !== pageNumber) { if (this._currentInternalPage !== pageNumber) {
this._documentViewer.displayPageLocation(pageNumber, 0, 0); this._documentViewer.displayPageLocation(pageNumber, 0, 0);
} }

View File

@ -23,8 +23,6 @@ export function handleFilterDelta(oldFilters: INestedFilter[], newFilters: INest
} }
} }
console.log(newFiltersDelta);
for (const key of Object.keys(newFiltersDelta)) { for (const key of Object.keys(newFiltersDelta)) {
const foundFilter = allFilters.find(f => f.id === key); const foundFilter = allFilters.find(f => f.id === key);
if (foundFilter) { if (foundFilter) {