added flag to AnnotationWrapper to not lose hidden annotations when they are reloaded
This commit is contained in:
parent
ec1203b9cc
commit
62d32f8849
@ -49,6 +49,7 @@ export class AnnotationWrapper {
|
||||
manual?: boolean;
|
||||
|
||||
image?: boolean;
|
||||
isHidden?: boolean;
|
||||
force?: boolean;
|
||||
|
||||
textAfter?: string;
|
||||
|
||||
@ -80,12 +80,14 @@ export class AnnotationActionsComponent implements OnInit {
|
||||
$event.stopPropagation();
|
||||
this.viewer.annotManager.hideAnnotations(this.viewerAnnotations);
|
||||
this.viewer.annotManager.deselectAllAnnotations();
|
||||
this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, true);
|
||||
}
|
||||
|
||||
showAnnotation($event: MouseEvent) {
|
||||
$event.stopPropagation();
|
||||
this.viewer.annotManager.showAnnotations(this.viewerAnnotations);
|
||||
this.viewer.annotManager.deselectAllAnnotations();
|
||||
this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, false);
|
||||
}
|
||||
|
||||
private _setPermissions() {
|
||||
|
||||
@ -31,8 +31,8 @@ import { loadCompareDocumentWrapper } from '../../utils/compare-mode.utils';
|
||||
import { PdfViewerUtils } from '../../utils/pdf-viewer.utils';
|
||||
import { ViewMode } from '@models/file/view-mode';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import TextTool = Tools.TextTool;
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import TextTool = Tools.TextTool;
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-pdf-viewer',
|
||||
@ -406,7 +406,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
img: allAreVisible
|
||||
? this._convertPath('/assets/icons/general/visibility-off.svg')
|
||||
: this._convertPath('/assets/icons/general/visibility.svg'),
|
||||
title: this._translateService.instant('annotation-actions.hide'),
|
||||
title: this._translateService.instant(`annotation-actions.${allAreVisible ? 'hide' : 'show'}`),
|
||||
onClick: () => {
|
||||
this._ngZone.run(() => {
|
||||
if (allAreVisible) {
|
||||
@ -415,6 +415,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
this.instance.annotManager.showAnnotations(viewerAnnotations);
|
||||
}
|
||||
this.instance.annotManager.deselectAllAnnotations();
|
||||
this._annotationActionsService.updateHiddenAnnotation(this.annotations, viewerAnnotations, allAreVisible);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,12 +267,17 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
console.log('[REDACTION] Delete previous annotations time: ' + (new Date().getTime() - startTime) + 'ms');
|
||||
const processStartTime = new Date().getTime();
|
||||
this.annotationData = this.fileData.getAnnotations(
|
||||
const newAnnotationsData = this.fileData.getAnnotations(
|
||||
this.appStateService.dictionaryData[this.appStateService.activeDossier.dossierTemplateId],
|
||||
this.userService.currentUser,
|
||||
this.viewMode,
|
||||
this.userPreferenceService.areDevFeaturesEnabled
|
||||
);
|
||||
if (this.annotationData) {
|
||||
this._setIsHiddenPropertyToNewAnnotations(newAnnotationsData.visibleAnnotations, this.annotationData.visibleAnnotations);
|
||||
this._setIsHiddenPropertyToNewAnnotations(newAnnotationsData.allAnnotations, this.annotationData.allAnnotations);
|
||||
}
|
||||
this.annotationData = newAnnotationsData;
|
||||
const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this.annotations);
|
||||
const primaryFilters = this._filterService.getGroup('primaryFilters')?.filters;
|
||||
this._filterService.addFilterGroup({
|
||||
@ -526,6 +531,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
window.open(`/html-debug/${this.dossierId}/${this.fileId}`, '_blank');
|
||||
}
|
||||
|
||||
private _setIsHiddenPropertyToNewAnnotations(newAnnotations: AnnotationWrapper[], oldAnnotations: AnnotationWrapper[]) {
|
||||
newAnnotations.map((newAnnotation: AnnotationWrapper) => {
|
||||
const oldAnnotation = oldAnnotations.find((a: AnnotationWrapper) => a.annotationId === newAnnotation.annotationId);
|
||||
if (oldAnnotation) {
|
||||
newAnnotation.isHidden = oldAnnotation.isHidden;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async _doStampExcludedPages(excludedPages: number[]) {
|
||||
if (excludedPages && excludedPages.length > 0) {
|
||||
const document = await this._instance.docViewer.getDocument().getPDFDoc();
|
||||
|
||||
@ -10,6 +10,7 @@ import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { DossiersDialogService } from './dossiers-dialog.service';
|
||||
import { BASE_HREF } from '../../../tokens';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { Annotations } from '@pdftron/webviewer';
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationActionsService {
|
||||
@ -280,6 +281,12 @@ export class AnnotationActionsService {
|
||||
return availableActions;
|
||||
}
|
||||
|
||||
updateHiddenAnnotation(annotations: AnnotationWrapper[], viewerAnnotations: Annotations.Annotation[], isHidden: boolean) {
|
||||
const annotationId = (viewerAnnotations[0] as any).Tw;
|
||||
const annotationToBeUpdated = annotations.find((a: AnnotationWrapper) => a.annotationId === annotationId);
|
||||
annotationToBeUpdated.isHidden = isHidden;
|
||||
}
|
||||
|
||||
private _processObsAndEmit(obs: Observable<any>, annotation: AnnotationWrapper, annotationsChanged: EventEmitter<AnnotationWrapper>) {
|
||||
obs.subscribe(
|
||||
() => {
|
||||
|
||||
@ -91,8 +91,11 @@ export class AnnotationDrawService {
|
||||
highlight.ReadOnly = true;
|
||||
// change log entries are drawn lighter
|
||||
highlight.Opacity = annotationWrapper.isChangeLogRemoved ? 0.2 : 1;
|
||||
highlight.Hidden = annotationWrapper.isChangeLogRemoved || (hideSkipped && annotationWrapper.isSkipped) || annotationWrapper.isOCR;
|
||||
|
||||
highlight.Hidden =
|
||||
annotationWrapper.isChangeLogRemoved ||
|
||||
(hideSkipped && annotationWrapper.isSkipped) ||
|
||||
annotationWrapper.isOCR ||
|
||||
annotationWrapper.isHidden;
|
||||
highlight.setCustomData('redacto-manager', true);
|
||||
highlight.setCustomData('redaction', annotationWrapper.isRedacted);
|
||||
highlight.setCustomData('skipped', annotationWrapper.isSkipped);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user