RED-3837: fix annotations pop-ups

This commit is contained in:
Dan Percic 2022-06-23 16:36:23 +03:00
parent 4bd7db2a80
commit bcab1cdfa2
2 changed files with 15 additions and 17 deletions

View File

@ -417,7 +417,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
#getAnnotationsToDraw(oldAnnotations: AnnotationWrapper[], newAnnotations: AnnotationWrapper[]) {
const currentPage = this.pdf.currentPage;
const currentPageAnnotations = this._annotationManager.get(a => a.getPageNumber() === currentPage);
const existingAnnotations = currentPageAnnotations.map(a => oldAnnotations.find(byId(a.Id))).filter(a => !!a);
const existingAnnotations = currentPageAnnotations
.map(a => oldAnnotations.find(byId(a.Id)) || newAnnotations.find(byId(a.Id)))
.filter(a => !!a);
if (existingAnnotations.length > 0) {
return this.#findAnnotationsToDraw(newAnnotations, oldAnnotations, existingAnnotations);
@ -470,11 +472,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
return newAnnotations.filter(newAnnotation => {
const oldAnnotation = oldAnnotations.find(byId(newAnnotation.id));
if (!oldAnnotation) {
return true;
}
if (!hasChanges(oldAnnotation, newAnnotation)) {
if (!oldAnnotation || !hasChanges(oldAnnotation, newAnnotation)) {
return selectToDrawIfDoesNotExist(newAnnotation);
}

View File

@ -28,7 +28,6 @@ import { combineLatest, Observable, Subject } from 'rxjs';
import { ViewModeService } from './view-mode.service';
import { PermissionsService } from '../../../services/permissions.service';
import { AnnotationsListingService } from './annotations-listing.service';
import { byPage } from '../../../utils';
import Annotation = Core.Annotations.Annotation;
import Quad = Core.Math.Quad;
@ -118,9 +117,16 @@ export class PdfProxyService {
// Remove deselected annotations from selected list
nextAnnotations = this._annotationManager.selected.filter(ann => !annotations.some(a => a.Id === ann.Id));
this._pdf.disable(TextPopups.ADD_RECTANGLE);
this.#configureAnnotationSpecificActions(nextAnnotations);
const currentPage = this._pdf.currentPage;
if (nextAnnotations.some(a => a.getPageNumber() === currentPage)) {
this.#configureAnnotationSpecificActions(nextAnnotations);
} else {
this._pdf.resetAnnotationActions();
}
return nextAnnotations.map(ann => ann.Id);
} else if (!this._multiSelectService.isEnabled) {
}
if (!this._multiSelectService.isEnabled) {
// Only choose the last selected annotation, to bypass viewer multi select
nextAnnotations = annotations;
const notSelected = this._fileDataService.all.filter(wrapper => !nextAnnotations.some(ann => ann.Id === wrapper.id));
@ -130,7 +136,7 @@ export class PdfProxyService {
nextAnnotations = this._annotationManager.selected;
}
this.#configureAnnotationSpecificActions(annotations);
this.#configureAnnotationSpecificActions(nextAnnotations);
if (!(annotations.length === 1 && annotations[0].ReadOnly)) {
this._pdf.enable(TextPopups.ADD_RECTANGLE);
@ -154,15 +160,9 @@ export class PdfProxyService {
const annotationWrappers = viewerAnnotations.map(va => this._fileDataService.find(va.Id)).filter(va => !!va);
this._pdf.resetAnnotationActions();
const currentPageAnnotations = annotationWrappers.filter(byPage(this._pdf.currentPage));
if (currentPageAnnotations.length === 0) {
return this._pdf.resetAnnotationActions();
}
if (annotationWrappers.length === 0) {
this._configureRectangleAnnotationPopup(viewerAnnotations[0]);
return;
return this._configureRectangleAnnotationPopup(viewerAnnotations[0]);
}
// Add hide action as last item