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 { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
import { ManualAnnotationService } from '../../services/manual-annotation.service';
import { ManualAnnotationResponse } from '@models/file/manual-annotation-response';
import { PermissionsService } from '@services/permissions.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 { DictionaryService } from '@shared/services/dictionary.service';
import { BaseDialogComponent } from '@iqser/common-ui';
@ -20,7 +19,6 @@ export interface LegalBasisOption {
}
@Component({
selector: 'redaction-manual-annotation-dialog',
templateUrl: './manual-annotation-dialog.component.html',
styleUrls: ['./manual-annotation-dialog.component.scss'],
})
@ -44,10 +42,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
private readonly _dictionaryService: DictionaryService,
protected readonly _injector: Injector,
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);
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.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
@ -73,6 +71,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
return this.form.invalid;
}
get commentIsMandatory() {
return !this.isDocumentAdmin && !this.isDictionaryRequest;
}
async ngOnInit() {
super.ngOnInit();
this.possibleDictionaries = await this._appStateService.getDictionariesOptions(
@ -91,11 +93,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
save() {
this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
this._manualAnnotationService.addAnnotation(this.data.manualRedactionEntryWrapper.manualRedactionEntry, this.data.file).subscribe(
(response: IManualAddResponse) =>
this._dialogRef.close(new ManualAnnotationResponse(this.data.manualRedactionEntryWrapper, response)),
() => this._dialogRef.close(),
);
this._dialogRef.close(this.data.manualRedactionEntryWrapper);
}
format(value: string) {
@ -118,10 +116,6 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
});
}
get commentIsMandatory() {
return !this.isDocumentAdmin && !this.isDictionaryRequest;
}
private _enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) {
const legalOption: LegalBasisOption = this.form.get('reason').value;
addRedactionRequest.type = this.form.get('dictionary').value;

View File

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

View File

@ -87,21 +87,15 @@ export class AnnotationActionsComponent implements OnChanges {
removeOrSuggestRemoveAnnotation($event: MouseEvent, removeFromDict: boolean) {
$event.stopPropagation();
this.annotationActionsService.removeOrSuggestRemoveAnnotation(
$event,
this.annotations,
this.file,
removeFromDict,
this.annotationsChanged,
);
this.annotationActionsService.removeOrSuggestRemoveAnnotation($event, this.annotations, removeFromDict, this.annotationsChanged);
}
markAsFalsePositive($event: MouseEvent) {
this.annotationActionsService.markAsFalsePositive($event, this.annotations, this.file, this.annotationsChanged);
this.annotationActionsService.markAsFalsePositive($event, this.annotations, this.annotationsChanged);
}
acceptRecommendation($event: MouseEvent) {
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.file, this.annotationsChanged);
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.annotationsChanged);
}
hideAnnotation($event: MouseEvent) {
@ -123,7 +117,7 @@ export class AnnotationActionsComponent implements OnChanges {
}
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) {

View File

@ -651,10 +651,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
}
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 {

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
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 { FileAssignService } from '../../../../shared/services/file-assign.service';
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 { FilesService } from '@services/entity-services/files.service';
import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs';
import { BehaviorSubject, combineLatest, Observable, switchMap } from 'rxjs';
import { BehaviorSubject, combineLatest, firstValueFrom, Observable, switchMap } from 'rxjs';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { distinctUntilChanged, map } from 'rxjs/operators';
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(
log(),
map(([file, canAssignUser, dossier]) => !file.assignee && canAssignUser && dossier.hasReviewers),
log(),
distinctUntilChanged(),
);

View File

@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppStateService } from '@state/app-state.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
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 { BaseDialogComponent } from '@iqser/common-ui';
import { DictionaryService } from '@shared/services/dictionary.service';
@ -12,7 +12,7 @@ import { AnnotationWrapper } from '../../../../../../models/file/annotation.wrap
export interface AcceptRecommendationData {
readonly annotations: AnnotationWrapper[];
readonly file: File;
readonly dossierId: string;
}
export interface AcceptRecommendationReturnType {
@ -42,7 +42,7 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp
@Inject(MAT_DIALOG_DATA) readonly data: AcceptRecommendationData,
) {
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.form = this._getForm();
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 { File, ViewMode } from '@red/domain';
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 { PdfViewerDataService } from '../../services/pdf-viewer-data.service';
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 { DossiersService } from '@services/entity-services/dossiers.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 { WatermarkService } from '@shared/services/watermark.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 { FileDataModel } from '../../../../models/file/file-data.model';
import { filePreviewScreenProviders } from './utils';
import { ManualAnnotationService } from '../../services/manual-annotation.service';
import Annotation = Core.Annotations.Annotation;
import PDFNet = Core.PDFNet;
@ -106,6 +107,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
private readonly _reanalysisService: ReanalysisService,
private readonly _errorService: ErrorService,
private readonly _skippedService: SkippedService,
private readonly _manualAnnotationService: ManualAnnotationService,
readonly excludedPagesService: ExcludedPagesService,
readonly viewModeService: ViewModeService,
readonly multiSelectService: MultiSelectService,
@ -188,7 +190,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
}
async ngOnAttach(previousRoute: ActivatedRouteSnapshot): Promise<boolean> {
const file = this._filesMapService.get(this.dossierId, this.fileId);
const file = await this.stateService.file;
if (!file.canBeOpened) {
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);
this._subscribeToFileUpdates();
const file = this._filesMapService.get(this.dossierId, this.fileId);
const file = await this.stateService.file;
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;
@ -278,18 +281,22 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
openManualAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
this._ngZone.run(() => {
const file = this._filesMapService.get(this.dossierId, this.fileId);
this.dialogRef = this._dialogService.openDialog(
'manualAnnotation',
null,
{ manualRedactionEntryWrapper, file },
async (response: ManualAnnotationResponse) => {
{ manualRedactionEntryWrapper, dossierId: this.dossierId },
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) {
const annotation = this._instance.Core.annotationManager.getAnnotationById(
response.manualRedactionEntryWrapper.rectId,
);
this._instance.Core.annotationManager.deleteAnnotation(annotation);
// await this._filesService.reload(this.dossierId, this.fileId).toPromise();
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
.map(p => p.page)
.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 { UserService } from '@services/user.service';
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 { AnnotationDrawService } from './annotation-draw.service';
import { translateQuads } from '@utils/pdf-coordinates';
@ -42,42 +42,42 @@ export class AnnotationActionsService {
private readonly _screenStateService: FilePreviewStateService,
) {}
acceptSuggestion(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
private get _dossier(): Dossier {
return this._dossiersService.find(this._screenStateService.dossierId);
}
acceptSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.approve(annotation.id, file, annotation.isModifyDictionary),
this._manualAnnotationService.approve(annotation.id, dossierId, fileId, annotation.isModifyDictionary),
annotation,
annotationsChanged,
);
});
}
rejectSuggestion(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
rejectSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => {
this._processObsAndEmit(this._manualAnnotationService.declineOrRemoveRequest(annotation, file), annotation, annotationsChanged);
this._processObsAndEmit(
this._manualAnnotationService.declineOrRemoveRequest(annotation, dossierId, fileId),
annotation,
annotationsChanged,
);
});
}
forceAnnotation(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
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) => {
annotations.forEach(annotation => {
this._processObsAndEmit(
@ -86,7 +86,8 @@ export class AnnotationActionsService {
...request,
annotationId: annotation.id,
},
file,
dossierId,
fileId,
),
annotation,
annotationsChanged,
@ -95,22 +96,19 @@ export class AnnotationActionsService {
});
}
changeLegalBasis(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
changeLegalBasis($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
const { dossierId, fileId } = this._screenStateService;
this._dialogService.openDialog(
'changeLegalBasis',
$event,
{ annotations, dossier: this._dossier(file) },
{ annotations, dossier: this._dossier },
(data: { comment: string; legalBasis: string; section: string; value: string }) => {
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.changeLegalBasis(
annotation.annotationId,
file,
dossierId,
fileId,
data.section,
data.value,
data.legalBasis,
@ -127,20 +125,26 @@ export class AnnotationActionsService {
removeOrSuggestRemoveAnnotation(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
removeFromDictionary: boolean,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
const data = {
annotationsToRemove: annotations,
removeFromDictionary,
dossier: this._dossier(file),
dossier: this._dossier,
hint: annotations[0].hintDictionary,
};
const { dossierId, fileId } = this._screenStateService;
this._dialogService.openDialog('removeAnnotations', $event, data, (result: { comment: string }) => {
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.removeOrSuggestRemoveAnnotation(annotation, file, removeFromDictionary, result.comment),
this._manualAnnotationService.removeOrSuggestRemoveAnnotation(
annotation,
dossierId,
fileId,
removeFromDictionary,
result.comment,
),
annotation,
annotationsChanged,
);
@ -148,28 +152,19 @@ export class AnnotationActionsService {
});
}
markAsFalsePositive(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
annotations.forEach(annotation => {
this._markAsFalsePositive($event, annotation, file, this._getFalsePositiveText(annotation), annotationsChanged);
this._markAsFalsePositive($event, annotation, this._getFalsePositiveText(annotation), annotationsChanged);
});
}
recategorizeImages(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
const data = { annotations, dossier: this._dossier(file) };
recategorizeImages($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
const data = { annotations, dossier: this._dossier };
const { dossierId, fileId } = this._screenStateService;
this._dialogService.openDialog('recategorizeImage', $event, data, (res: { type: string; comment: string }) => {
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.recategorizeImg(annotation.annotationId, file, res.type, res.comment),
this._manualAnnotationService.recategorizeImg(annotation.annotationId, dossierId, fileId, res.type, res.comment),
annotation,
annotationsChanged,
);
@ -177,37 +172,37 @@ export class AnnotationActionsService {
});
}
undoDirectAction(
$event: MouseEvent,
annotations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
undoDirectAction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
annotations.forEach(annotation => {
this._processObsAndEmit(this._manualAnnotationService.undoRequest(annotation, file), annotation, annotationsChanged);
this._processObsAndEmit(
this._manualAnnotationService.undoRequest(annotation, dossierId, fileId),
annotation,
annotationsChanged,
);
});
}
convertRecommendationToAnnotation(
$event: any,
recommendations: AnnotationWrapper[],
file: File,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
$event?.stopPropagation();
const { dossierId, fileId } = this._screenStateService;
const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>(
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));
dialogClosed.subscribe(({ annotations, comment: commentText }) => {
const comment = commentText ? { text: commentText } : undefined;
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.addRecommendation(annotation, file, comment),
this._manualAnnotationService.addRecommendation(annotation, dossierId, fileId, comment),
annotation,
annotationsChanged,
);
@ -242,8 +237,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.resize-accept.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.acceptResize(null, viewer, file, firstAnnotation, annotationsChanged);
this._ngZone.run(() => {
this.acceptResize(null, viewer, firstAnnotation, annotationsChanged);
}),
});
availableActions.push({
@ -273,8 +268,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/edit.svg'),
title: this._translateService.instant('annotation-actions.edit-reason.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.changeLegalBasis(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.changeLegalBasis(null, annotations, annotationsChanged);
}),
});
}
@ -286,8 +281,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-down.svg'),
title: this._translateService.instant('annotation-actions.recategorize-image'),
onClick: () =>
this._runForCurrentFile(file => {
this.recategorizeImages(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.recategorizeImages(null, annotations, annotationsChanged);
}),
});
}
@ -302,8 +297,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/remove-from-dict.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.remove-from-dict'),
onClick: () =>
this._runForCurrentFile(file => {
this.removeOrSuggestRemoveAnnotation(null, annotations, file, true, annotationsChanged);
this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, true, annotationsChanged);
}),
});
}
@ -315,8 +310,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.accept-recommendation.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.convertRecommendationToAnnotation(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.convertRecommendationToAnnotation(null, annotations, annotationsChanged);
}),
});
}
@ -328,8 +323,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.accept-suggestion.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.acceptSuggestion(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.acceptSuggestion(null, annotations, annotationsChanged);
}),
});
}
@ -341,8 +336,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/undo.svg'),
title: this._translateService.instant('annotation-actions.undo'),
onClick: () =>
this._runForCurrentFile(file => {
this.undoDirectAction(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.undoDirectAction(null, annotations, annotationsChanged);
}),
});
}
@ -354,8 +349,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-down.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.false-positive'),
onClick: () =>
this._runForCurrentFile(file => {
this.markAsFalsePositive(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.markAsFalsePositive(null, annotations, annotationsChanged);
}),
});
}
@ -367,8 +362,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-up.svg'),
title: this._translateService.instant('annotation-actions.force-redaction.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.forceAnnotation(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.forceAnnotation(null, annotations, annotationsChanged);
}),
});
}
@ -380,8 +375,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/thumb-up.svg'),
title: this._translateService.instant('annotation-actions.force-hint.label'),
onClick: () =>
this._runForCurrentFile(file => {
this.forceAnnotation(null, annotations, file, annotationsChanged, true);
this._ngZone.run(() => {
this.forceAnnotation(null, annotations, annotationsChanged, true);
}),
});
}
@ -393,8 +388,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/close.svg'),
title: this._translateService.instant('annotation-actions.reject-suggestion'),
onClick: () =>
this._runForCurrentFile(file => {
this.rejectSuggestion(null, annotations, file, annotationsChanged);
this._ngZone.run(() => {
this.rejectSuggestion(null, annotations, annotationsChanged);
}),
});
}
@ -409,8 +404,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/trash.svg'),
title: this._translateService.instant('annotation-actions.remove-annotation.only-here'),
onClick: () =>
this._runForCurrentFile(file => {
this.removeOrSuggestRemoveAnnotation(null, annotations, file, false, annotationsChanged);
this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, false, annotationsChanged);
}),
});
}
@ -443,11 +438,11 @@ export class AnnotationActionsService {
acceptResize(
$event: MouseEvent,
viewer: WebViewerInstance,
file: File,
annotationWrapper: 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 }) => {
const textAndPositions = await this._extractTextAndPositions(viewer, annotationWrapper.id);
const text =
@ -461,7 +456,7 @@ export class AnnotationActionsService {
};
this._processObsAndEmit(
this._manualAnnotationService.resizeOrSuggestToResize(annotationWrapper, file, resizeRequest),
this._manualAnnotationService.resizeOrSuggestToResize(annotationWrapper, data.dossier.dossierId, fileId, resizeRequest),
annotationWrapper,
annotationsChanged,
);
@ -486,17 +481,6 @@ export class AnnotationActionsService {
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(
obs: Observable<unknown>,
annotation: AnnotationWrapper,
@ -531,7 +515,6 @@ export class AnnotationActionsService {
private _markAsFalsePositive(
$event: MouseEvent,
annotation: AnnotationWrapper,
file: File,
text: string,
annotationsChanged: EventEmitter<AnnotationWrapper>,
) {
@ -544,8 +527,13 @@ export class AnnotationActionsService {
falsePositiveRequest.positions = annotation.positions;
falsePositiveRequest.addToDictionary = true;
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 {

View File

@ -2,7 +2,6 @@ import { Injectable, Injector } from '@angular/core';
import { AppStateService } from '@state/app-state.service';
import {
Dossier,
File,
IAddRedactionRequest,
IApproveRequest,
IImageRecategorizationRequest,
@ -57,14 +56,15 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
_makeRequest(
mode: AnnotationActionMode,
file: File,
dossierId: string,
fileId: string,
body: any,
secondParam: any = null,
modifyDictionary = false,
): Observable<unknown> {
const obs = !secondParam
? this[this.CONFIG[mode]](body, file.dossierId, file.id)
: this[this.CONFIG[mode]](body, secondParam, file.dossierId, file.id);
? this[this.CONFIG[mode]](body, dossierId, fileId)
: this[this.CONFIG[mode]](body, secondParam, dossierId, fileId);
return obs.pipe(
tap({
@ -74,7 +74,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
this._toaster.error(this._getMessage(mode, modifyDictionary, true, isConflict), {
error,
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,
},
positionClass: 'toast-file-preview',
@ -96,7 +97,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
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 = {};
manualRedactionEntry.addToDictionary = true;
// 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.type = annotation.recommendationType;
manualRedactionEntry.comment = comment;
return this.addAnnotation(manualRedactionEntry, file);
return this.addAnnotation(manualRedactionEntry, dossierId, fileId);
}
// /manualRedaction/request/legalBasis
changeLegalBasis(annotationId: string, file: File, section: string, value: string, legalBasis: string, comment?: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file))
changeLegalBasis(
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'
: '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
// /manualRedaction/redaction/legalBasisChange
// /manualRedaction/request/recategorize
recategorizeImg(annotationId: string, file: File, type: string, comment: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file))
recategorizeImg(annotationId: string, dossierId: string, fileId: string, type: string, comment: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId))
? 'recategorize-image'
: 'request-image-recategorization';
return this._makeRequest(mode, file, { annotationId, type, comment });
return this._makeRequest(mode, dossierId, fileId, { annotationId, type, comment });
}
// this wraps
// /manualRedaction/redaction/recategorize
// /manualRedaction/request/add
addAnnotation(manualRedactionEntry: IAddRedactionRequest, file: File) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'add' : 'suggest';
return this._makeRequest(mode, file, manualRedactionEntry, null, manualRedactionEntry.addToDictionary);
addAnnotation(manualRedactionEntry: IAddRedactionRequest, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId)) ? 'add' : 'suggest';
return this._makeRequest(mode, dossierId, fileId, manualRedactionEntry, null, manualRedactionEntry.addToDictionary);
}
// this wraps
// /manualRedaction/redaction/add
// /manualRedaction/request/force
force(request: ILegalBasisChangeRequest, file: File) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file))
force(request: ILegalBasisChangeRequest, dossierId: string, fileId: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId))
? 'force-redaction'
: 'request-force-redaction';
return this._makeRequest(mode, file, request);
return this._makeRequest(mode, dossierId, fileId, request);
}
// this wraps
// /manualRedaction/redaction/force
// /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
return this._makeRequest('approve', file, { addOrRemoveFromDictionary: addToDictionary }, annotationId, addToDictionary);
return this._makeRequest(
'approve',
dossierId,
fileId,
{ addOrRemoveFromDictionary: addToDictionary },
annotationId,
addToDictionary,
);
}
// this wraps
undoRequest(annotationWrapper: AnnotationWrapper, file: File) {
return this._makeRequest('undo', file, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
}
// /manualRedaction/undo
declineOrRemoveRequest(annotationWrapper: AnnotationWrapper, file: File) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'decline' : 'undo';
return this._makeRequest(mode, file, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
undoRequest(annotationWrapper: AnnotationWrapper, dossierId: string, fileId: string) {
return this._makeRequest('undo', dossierId, fileId, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
}
// this wraps
// /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/
resizeOrSuggestToResize(annotationWrapper: AnnotationWrapper, file: File, resizeRequest: IResizeRequest) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'resize' : 'request-resize';
return this._makeRequest(mode, file, resizeRequest);
resizeOrSuggestToResize(annotationWrapper: AnnotationWrapper, dossierId: string, fileId: string, resizeRequest: IResizeRequest) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(dossierId)) ? 'resize' : 'request-resize';
return this._makeRequest(mode, dossierId, fileId, resizeRequest);
}
// this wraps
@ -183,7 +197,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
// /manualRedaction/request/remove/
removeOrSuggestRemoveAnnotation(
annotationWrapper: AnnotationWrapper,
file: File,
dossierId: string,
fileId: string,
removeFromDictionary: boolean = false,
comment: string,
) {
@ -191,7 +206,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
body: any,
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
mode = 'remove';
body = {
@ -210,7 +225,7 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
removeDict = removeFromDictionary;
}
return this._makeRequest(mode, file, body, null, removeDict);
return this._makeRequest(mode, dossierId, fileId, body, null, removeDict);
}
// this wraps
@ -353,8 +368,8 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
return this._post(body, url);
}
private _dossier(file: File): Dossier {
return this._dossiersService.find(file.dossierId);
private _dossier(dossierId: string): Dossier {
return this._dossiersService.find(dossierId);
}
private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error = false, isConflict = false) {

View File

@ -138,7 +138,7 @@ export class PdfViewerUtils {
this._annotationManager.deselectAnnotations(ann);
}
private _navigateToPage(pageNumber) {
private _navigateToPage(pageNumber: number) {
if (this._currentInternalPage !== pageNumber) {
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)) {
const foundFilter = allFilters.find(f => f.id === key);
if (foundFilter) {