Pull request #330: Skipped service

Merge in RED/ui from refactor-fp-skipped to master

* commit '4235e3cdbcf654e637969ec6bc72a71e221d6900':
  Skipped service
This commit is contained in:
Adina Teudan 2022-01-16 20:58:11 +01:00
commit 0a6caf2698
10 changed files with 68 additions and 49 deletions

View File

@ -10,10 +10,8 @@ import { SharedModule } from '@shared/shared.module';
import { DossiersRoutingModule } from './dossiers-routing.module'; import { DossiersRoutingModule } from './dossiers-routing.module';
import { FileUploadDownloadModule } from '@upload-download/file-upload-download.module'; import { FileUploadDownloadModule } from '@upload-download/file-upload-download.module';
import { DossiersDialogService } from './services/dossiers-dialog.service'; import { DossiersDialogService } from './services/dossiers-dialog.service';
import { AnnotationActionsService } from './services/annotation-actions.service';
import { PdfViewerDataService } from './services/pdf-viewer-data.service'; import { PdfViewerDataService } from './services/pdf-viewer-data.service';
import { ManualAnnotationService } from './services/manual-annotation.service'; import { ManualAnnotationService } from './services/manual-annotation.service';
import { AnnotationDrawService } from './services/annotation-draw.service';
import { AnnotationProcessingService } from './services/annotation-processing.service'; import { AnnotationProcessingService } from './services/annotation-processing.service';
import { EditDossierDialogComponent } from './dialogs/edit-dossier-dialog/edit-dossier-dialog.component'; import { EditDossierDialogComponent } from './dialogs/edit-dossier-dialog/edit-dossier-dialog.component';
import { EditDossierGeneralInfoComponent } from './dialogs/edit-dossier-dialog/general-info/edit-dossier-general-info.component'; import { EditDossierGeneralInfoComponent } from './dialogs/edit-dossier-dialog/general-info/edit-dossier-general-info.component';
@ -56,14 +54,7 @@ const components = [
...dialogs, ...dialogs,
]; ];
const services = [ const services = [DossiersDialogService, ManualAnnotationService, PdfViewerDataService, AnnotationProcessingService];
DossiersDialogService,
AnnotationActionsService,
ManualAnnotationService,
PdfViewerDataService,
AnnotationDrawService,
AnnotationProcessingService,
];
@NgModule({ @NgModule({
declarations: [...components], declarations: [...components],

View File

@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { AnnotationPermissions } from '@models/file/annotation.permissions';
import { AnnotationActionsService } from '../../../../services/annotation-actions.service'; import { AnnotationActionsService } from '../../services/annotation-actions.service';
import { WebViewerInstance } from '@pdftron/webviewer'; import { WebViewerInstance } from '@pdftron/webviewer';
import { UserService } from '@services/user.service'; import { UserService } from '@services/user.service';
import { Dossier, File } from '@red/domain'; import { Dossier, File } from '@red/domain';

View File

@ -217,9 +217,9 @@
<ng-template #annotationFilterActionTemplate let-filter="filter"> <ng-template #annotationFilterActionTemplate let-filter="filter">
<iqser-circle-button <iqser-circle-button
(action)="toggleSkipped.emit($event)" (action)="skippedService.toggleSkipped($event)"
*ngIf="filter.id === 'skipped'" *ngIf="filter.id === 'skipped'"
[icon]="hideSkipped ? 'red:visibility-off' : 'red:visibility'" [icon]="(skippedService.hideSkipped$ | async) ? 'red:visibility-off' : 'red:visibility'"
[type]="circleButtonTypes.dark" [type]="circleButtonTypes.dark"
></iqser-circle-button> ></iqser-circle-button>
</ng-template> </ng-template>

View File

@ -32,6 +32,7 @@ import { File, IViewedPage } from '@red/domain';
import { ExcludedPagesService } from '../../services/excluded-pages.service'; import { ExcludedPagesService } from '../../services/excluded-pages.service';
import { MultiSelectService } from '../../services/multi-select.service'; import { MultiSelectService } from '../../services/multi-select.service';
import { DocumentInfoService } from '../../services/document-info.service'; import { DocumentInfoService } from '../../services/document-info.service';
import { SkippedService } from '../../services/skipped.service';
const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape'];
const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
@ -53,14 +54,12 @@ export class FileWorkloadComponent {
@Input() dialogRef: MatDialogRef<unknown>; @Input() dialogRef: MatDialogRef<unknown>;
@Input() viewedPages: IViewedPage[]; @Input() viewedPages: IViewedPage[];
@Input() file!: File; @Input() file!: File;
@Input() hideSkipped: boolean;
@Input() annotationActionsTemplate: TemplateRef<unknown>; @Input() annotationActionsTemplate: TemplateRef<unknown>;
@Input() viewer: WebViewerInstance; @Input() viewer: WebViewerInstance;
@Output() readonly shouldDeselectAnnotationsOnPageChangeChange = new EventEmitter<boolean>(); @Output() readonly shouldDeselectAnnotationsOnPageChangeChange = new EventEmitter<boolean>();
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>(); @Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly deselectAnnotations = new EventEmitter<AnnotationWrapper[]>(); @Output() readonly deselectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly selectPage = new EventEmitter<number>(); @Output() readonly selectPage = new EventEmitter<number>();
@Output() readonly toggleSkipped = new EventEmitter<MouseEvent>();
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper>(); @Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper>();
displayedPages: number[] = []; displayedPages: number[] = [];
pagesPanelActive = true; pagesPanelActive = true;
@ -76,6 +75,7 @@ export class FileWorkloadComponent {
readonly excludedPagesService: ExcludedPagesService, readonly excludedPagesService: ExcludedPagesService,
readonly multiSelectService: MultiSelectService, readonly multiSelectService: MultiSelectService,
readonly documentInfoService: DocumentInfoService, readonly documentInfoService: DocumentInfoService,
readonly skippedService: SkippedService,
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _filterService: FilterService, private readonly _filterService: FilterService,

View File

@ -22,8 +22,8 @@ import {
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { ManualAnnotationService } from '../../../../services/manual-annotation.service'; import { ManualAnnotationService } from '../../../../services/manual-annotation.service';
import { environment } from '@environments/environment'; import { environment } from '@environments/environment';
import { AnnotationDrawService } from '../../../../services/annotation-draw.service'; import { AnnotationDrawService } from '../../services/annotation-draw.service';
import { AnnotationActionsService } from '../../../../services/annotation-actions.service'; import { AnnotationActionsService } from '../../services/annotation-actions.service';
import { UserPreferenceService } from '@services/user-preference.service'; import { UserPreferenceService } from '@services/user-preference.service';
import { BASE_HREF } from '../../../../../../tokens'; import { BASE_HREF } from '../../../../../../tokens';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';

View File

@ -102,7 +102,6 @@
(deselectAnnotations)="deselectAnnotations($event)" (deselectAnnotations)="deselectAnnotations($event)"
(selectAnnotations)="selectAnnotations($event)" (selectAnnotations)="selectAnnotations($event)"
(selectPage)="selectPage($event)" (selectPage)="selectPage($event)"
(toggleSkipped)="toggleSkipped($event)"
*ngIf="!file.excluded" *ngIf="!file.excluded"
[(shouldDeselectAnnotationsOnPageChange)]="shouldDeselectAnnotationsOnPageChange" [(shouldDeselectAnnotationsOnPageChange)]="shouldDeselectAnnotationsOnPageChange"
[activeViewerPage]="activeViewerPage" [activeViewerPage]="activeViewerPage"
@ -110,7 +109,6 @@
[annotations]="visibleAnnotations" [annotations]="visibleAnnotations"
[dialogRef]="dialogRef" [dialogRef]="dialogRef"
[file]="file" [file]="file"
[hideSkipped]="hideSkipped"
[selectedAnnotations]="selectedAnnotations" [selectedAnnotations]="selectedAnnotations"
[viewedPages]="fileData?.viewedPages" [viewedPages]="fileData?.viewedPages"
[viewer]="activeViewer" [viewer]="activeViewer"

View File

@ -21,7 +21,7 @@ import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { ManualAnnotationResponse } from '@models/file/manual-annotation-response'; import { ManualAnnotationResponse } from '@models/file/manual-annotation-response';
import { FileDataModel } from '@models/file/file-data.model'; import { FileDataModel } from '@models/file/file-data.model';
import { AnnotationDrawService } from '../../services/annotation-draw.service'; import { AnnotationDrawService } from './services/annotation-draw.service';
import { AnnotationProcessingService } from '../../services/annotation-processing.service'; import { AnnotationProcessingService } from '../../services/annotation-processing.service';
import { Dossier, File, ViewMode } from '@red/domain'; import { Dossier, File, ViewMode } from '@red/domain';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
@ -47,6 +47,8 @@ import { DocumentInfoService } from './services/document-info.service';
import { ReanalysisService } from '../../../../services/reanalysis.service'; import { ReanalysisService } from '../../../../services/reanalysis.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { CommentingService } from './services/commenting.service'; import { CommentingService } from './services/commenting.service';
import { SkippedService } from './services/skipped.service';
import { AnnotationActionsService } from './services/annotation-actions.service';
import Annotation = Core.Annotations.Annotation; import Annotation = Core.Annotations.Annotation;
import PDFNet = Core.PDFNet; import PDFNet = Core.PDFNet;
@ -55,7 +57,17 @@ const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown'];
@Component({ @Component({
templateUrl: './file-preview-screen.component.html', templateUrl: './file-preview-screen.component.html',
styleUrls: ['./file-preview-screen.component.scss'], styleUrls: ['./file-preview-screen.component.scss'],
providers: [FilterService, ExcludedPagesService, ViewModeService, MultiSelectService, DocumentInfoService, CommentingService], providers: [
FilterService,
ExcludedPagesService,
ViewModeService,
MultiSelectService,
DocumentInfoService,
CommentingService,
SkippedService,
AnnotationDrawService,
AnnotationActionsService,
],
}) })
export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnInit, OnDestroy, OnAttach, OnDetach { export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnInit, OnDestroy, OnAttach, OnDetach {
readonly circleButtonTypes = CircleButtonTypes; readonly circleButtonTypes = CircleButtonTypes;
@ -65,7 +77,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
shouldDeselectAnnotationsOnPageChange = true; shouldDeselectAnnotationsOnPageChange = true;
fileData: FileDataModel; fileData: FileDataModel;
selectedAnnotations: AnnotationWrapper[] = []; selectedAnnotations: AnnotationWrapper[] = [];
hideSkipped = false;
displayPdfViewer = false; displayPdfViewer = false;
activeViewerPage: number = null; activeViewerPage: number = null;
@ViewChild(PdfViewerComponent) readonly viewerComponent: PdfViewerComponent; @ViewChild(PdfViewerComponent) readonly viewerComponent: PdfViewerComponent;
@ -105,6 +116,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
private readonly _dossiersService: DossiersService, private readonly _dossiersService: DossiersService,
private readonly _reanalysisService: ReanalysisService, private readonly _reanalysisService: ReanalysisService,
private readonly _errorService: ErrorService, private readonly _errorService: ErrorService,
private readonly _skippedService: SkippedService,
readonly excludedPagesService: ExcludedPagesService, readonly excludedPagesService: ExcludedPagesService,
readonly viewModeService: ViewModeService, readonly viewModeService: ViewModeService,
readonly multiSelectService: MultiSelectService, readonly multiSelectService: MultiSelectService,
@ -422,16 +434,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
download(data, file.filename); download(data, file.filename);
} }
toggleSkipped($event) {
$event.stopPropagation();
$event.preventDefault();
this.hideSkipped = !this.hideSkipped;
this._handleIgnoreAnnotationsDrawing();
return false;
}
private _setActiveViewerPage() { private _setActiveViewerPage() {
const currentPage = this._instance?.Core.documentViewer?.getCurrentPage(); const currentPage = this._instance?.Core.documentViewer?.getCurrentPage();
if (!currentPage) { if (!currentPage) {
@ -548,6 +550,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
.watchDeleted$(this.fileId) .watchDeleted$(this.fileId)
.pipe(tap(() => this._handleDeletedFile())) .pipe(tap(() => this._handleDeletedFile()))
.subscribe(); .subscribe();
this.addActiveScreenSubscription = this._skippedService.hideSkipped$
.pipe(tap(hideSkipped => this._handleIgnoreAnnotationsDrawing(hideSkipped)))
.subscribe();
} }
private _handleDeletedDossier(): void { private _handleDeletedDossier(): void {
@ -632,7 +638,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
annotations, annotations,
this.fileId, this.fileId,
this.dossierId, this.dossierId,
this.hideSkipped,
!!this.viewModeService.isCompare, !!this.viewModeService.isCompare,
); );
} }
@ -674,9 +679,13 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
} }
} }
private _handleIgnoreAnnotationsDrawing() { private _handleIgnoreAnnotationsDrawing(hideSkipped: boolean): void {
const ignored = this._getAnnotations(a => a.getCustomData('skipped')); const ignored = this._getAnnotations(a => a.getCustomData('skipped'));
return this.hideSkipped ? this._hide(ignored) : this._show(ignored); if (hideSkipped) {
this._hide(ignored);
} else {
this._show(ignored);
}
} }
private _getAnnotations(predicate: (value) => unknown) { private _getAnnotations(predicate: (value) => unknown) {

View File

@ -1,19 +1,19 @@
import { EventEmitter, Inject, Injectable, NgZone } from '@angular/core'; import { EventEmitter, Inject, Injectable, NgZone } from '@angular/core';
import { PermissionsService } from '@services/permissions.service'; import { PermissionsService } from '@services/permissions.service';
import { ManualAnnotationService } from './manual-annotation.service'; import { ManualAnnotationService } from '../../../services/manual-annotation.service';
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { getFirstRelevantTextPart } from '@utils/functions'; import { getFirstRelevantTextPart } from '@utils/functions';
import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { AnnotationPermissions } from '@models/file/annotation.permissions';
import { DossiersDialogService } from './dossiers-dialog.service'; 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, File, 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'; import { translateQuads } from '@utils/pdf-coordinates';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import Annotation = Core.Annotations.Annotation; import Annotation = Core.Annotations.Annotation;

View File

@ -5,10 +5,11 @@ import { AppStateService } from '@state/app-state.service';
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { UserPreferenceService } from '@services/user-preference.service'; import { UserPreferenceService } from '@services/user-preference.service';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { RedactionLogService } from './redaction-log.service'; import { RedactionLogService } from '../../../services/redaction-log.service';
import { environment } from '@environments/environment'; import { environment } from '@environments/environment';
import { IRectangle, ISectionGrid, ISectionRectangle } from '@red/domain'; import { IRectangle, ISectionGrid, ISectionRectangle } from '@red/domain';
import { SkippedService } from './skipped.service';
import Annotation = Core.Annotations.Annotation; import Annotation = Core.Annotations.Annotation;
@Injectable() @Injectable()
@ -18,6 +19,7 @@ export class AnnotationDrawService {
private readonly _dossiersService: DossiersService, private readonly _dossiersService: DossiersService,
private readonly _redactionLogService: RedactionLogService, private readonly _redactionLogService: RedactionLogService,
private readonly _userPreferenceService: UserPreferenceService, private readonly _userPreferenceService: UserPreferenceService,
private readonly _skippedService: SkippedService,
) {} ) {}
async drawAnnotations( async drawAnnotations(
@ -25,7 +27,6 @@ export class AnnotationDrawService {
annotationWrappers: AnnotationWrapper[], annotationWrappers: AnnotationWrapper[],
fileId: string, fileId: string,
dossierId: string, dossierId: string,
hideSkipped = false,
compareMode = false, compareMode = false,
) { ) {
if (!activeViewer) { if (!activeViewer) {
@ -36,7 +37,7 @@ export class AnnotationDrawService {
await pdfNet.runWithCleanup( await pdfNet.runWithCleanup(
async () => { async () => {
await this._drawAnnotations(activeViewer, annotationWrappers, fileId, dossierId, hideSkipped, compareMode); await this._drawAnnotations(activeViewer, annotationWrappers, fileId, dossierId, compareMode);
}, },
environment.licenseKey ? atob(environment.licenseKey) : null, environment.licenseKey ? atob(environment.licenseKey) : null,
); );
@ -82,12 +83,9 @@ export class AnnotationDrawService {
annotationWrappers: AnnotationWrapper[], annotationWrappers: AnnotationWrapper[],
fileId: string, fileId: string,
dossierId: string, dossierId: string,
hideSkipped: boolean,
compareMode: boolean, compareMode: boolean,
) { ) {
const annotations = annotationWrappers.map(annotation => const annotations = annotationWrappers.map(annotation => this._computeAnnotation(activeViewer, annotation, dossierId, compareMode));
this._computeAnnotation(activeViewer, annotation, dossierId, hideSkipped, compareMode),
);
const annotationManager = activeViewer.Core.annotationManager; const annotationManager = activeViewer.Core.annotationManager;
annotationManager.addAnnotations(annotations, { imported: true }); annotationManager.addAnnotations(annotations, { imported: true });
await annotationManager.drawAnnotationsFromList(annotations); await annotationManager.drawAnnotationsFromList(annotations);
@ -143,7 +141,6 @@ export class AnnotationDrawService {
activeViewer: WebViewerInstance, activeViewer: WebViewerInstance,
annotationWrapper: AnnotationWrapper, annotationWrapper: AnnotationWrapper,
dossierId: string, dossierId: string,
hideSkipped: boolean,
compareMode: boolean, compareMode: boolean,
) { ) {
const pageNumber = compareMode ? annotationWrapper.pageNumber * 2 - 1 : annotationWrapper.pageNumber; const pageNumber = compareMode ? annotationWrapper.pageNumber * 2 - 1 : annotationWrapper.pageNumber;
@ -177,7 +174,7 @@ export class AnnotationDrawService {
annotation.Hidden = annotation.Hidden =
annotationWrapper.isChangeLogRemoved || annotationWrapper.isChangeLogRemoved ||
(hideSkipped && annotationWrapper.isSkipped) || (this._skippedService.hideSkipped && annotationWrapper.isSkipped) ||
annotationWrapper.isOCR || annotationWrapper.isOCR ||
annotationWrapper.hidden; annotationWrapper.hidden;
annotation.setCustomData('redact-manager', 'true'); annotation.setCustomData('redact-manager', 'true');

View File

@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { skip } from 'rxjs/operators';
import { shareDistinctLast } from '@iqser/common-ui';
@Injectable()
export class SkippedService {
readonly hideSkipped$: Observable<boolean>;
private readonly _hideSkipped$ = new BehaviorSubject(false);
constructor() {
this.hideSkipped$ = this._hideSkipped$.pipe(shareDistinctLast(), skip(1));
}
get hideSkipped(): boolean {
return this._hideSkipped$.value;
}
toggleSkipped($event): void {
$event.stopPropagation();
$event.preventDefault();
this._hideSkipped$.next(!this.hideSkipped);
}
}