RED-6325: fix recommendation file actions on resize
This commit is contained in:
parent
defe2aa98d
commit
d58bd68918
@ -9,6 +9,7 @@
|
||||
readonly trackBy = trackByFactory();
|
||||
```
|
||||
* Don't use `setInterval` without calling `clearInterval` in `ngOnDestroy`
|
||||
* Never call getters in HTML templates
|
||||
|
||||
## Keycloak Staging Config
|
||||
|
||||
|
||||
@ -49,8 +49,7 @@ export class PdfProxyService {
|
||||
);
|
||||
canPerformActions = true;
|
||||
|
||||
instance = this._pdf.instance;
|
||||
canPerformAnnotationActions$: Observable<boolean>;
|
||||
readonly canPerformAnnotationActions$: Observable<boolean>;
|
||||
readonly #visibilityOffIcon = this._convertPath('/assets/icons/general/visibility-off.svg');
|
||||
readonly #visibilityIcon = this._convertPath('/assets/icons/general/visibility.svg');
|
||||
readonly #falsePositiveIcon = this._convertPath('/assets/icons/general/pdftron-action-false-positive.svg');
|
||||
@ -177,6 +176,14 @@ export class PdfProxyService {
|
||||
// When resizing a rectangle, the original annotation is removed and triggers a deselect event and a new one is created
|
||||
// So we want to skip the first deselect event.
|
||||
const wrapper = this._fileDataService.find(annotation.Id);
|
||||
if (!wrapper) {
|
||||
// It might be a recommendation,
|
||||
// which is automatically converted to redaction when resized,
|
||||
// so the original annotation(wrapper) is removed
|
||||
this._annotationManager.resizingAnnotationId = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(wrapper.rectangle || wrapper.isImage || wrapper.imported) &&
|
||||
annotation.ToolName !== AnnotationToolNames.AnnotationCreateRectangle
|
||||
@ -204,42 +211,42 @@ export class PdfProxyService {
|
||||
if (allAnnotationsHaveImageAction) {
|
||||
const allAreVisible = viewerAnnotations.reduce((acc, next) => next.isVisible() && acc, true);
|
||||
|
||||
this.instance.UI.annotationPopup.add([
|
||||
{
|
||||
type: 'actionButton',
|
||||
img: allAreVisible ? this.#visibilityOffIcon : this.#visibilityIcon,
|
||||
title: this._translateService.instant(`annotation-actions.${allAreVisible ? 'hide' : 'show'}`),
|
||||
onClick: () => {
|
||||
this._ngZone.run(() => {
|
||||
if (allAreVisible) {
|
||||
this._annotationManager.hide(viewerAnnotations);
|
||||
this._annotationManager.addToHidden(viewerAnnotations[0].Id);
|
||||
} else {
|
||||
this._annotationManager.show(viewerAnnotations);
|
||||
this._annotationManager.removeFromHidden(viewerAnnotations[0].Id);
|
||||
}
|
||||
this._annotationManager.deselect();
|
||||
});
|
||||
},
|
||||
const visibilityButton = {
|
||||
type: 'actionButton',
|
||||
img: allAreVisible ? this.#visibilityOffIcon : this.#visibilityIcon,
|
||||
title: this._translateService.instant(`annotation-actions.${allAreVisible ? 'hide' : 'show'}`),
|
||||
onClick: () => {
|
||||
this._ngZone.run(() => {
|
||||
if (allAreVisible) {
|
||||
this._annotationManager.hide(viewerAnnotations);
|
||||
this._annotationManager.addToHidden(viewerAnnotations[0].Id);
|
||||
} else {
|
||||
this._annotationManager.show(viewerAnnotations);
|
||||
this._annotationManager.removeFromHidden(viewerAnnotations[0].Id);
|
||||
}
|
||||
this._annotationManager.deselect();
|
||||
});
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
this._pdf.instance.UI.annotationPopup.add([visibilityButton]);
|
||||
}
|
||||
|
||||
const actions = this._pdfAnnotationActionsService.get(annotationWrappers);
|
||||
this.instance.UI.annotationPopup.add(actions);
|
||||
this._pdf.instance.UI.annotationPopup.add(actions);
|
||||
}
|
||||
|
||||
private _configureRectangleAnnotationPopup(annotation: Annotation) {
|
||||
if (!this._pdf.isCompare || annotation.getPageNumber() % 2 === 1) {
|
||||
this.instance.UI.annotationPopup.add([
|
||||
{
|
||||
type: 'actionButton',
|
||||
dataElement: TextPopups.ADD_RECTANGLE,
|
||||
img: this.#addRedactionIcon,
|
||||
title: this.#getTitle(ManualRedactionEntryTypes.REDACTION),
|
||||
onClick: () => this._addRectangleManualRedaction(),
|
||||
},
|
||||
]);
|
||||
const addRectangleButton = {
|
||||
type: 'actionButton',
|
||||
dataElement: TextPopups.ADD_RECTANGLE,
|
||||
img: this.#addRedactionIcon,
|
||||
title: this.#getTitle(ManualRedactionEntryTypes.REDACTION),
|
||||
onClick: () => this._addRectangleManualRedaction(),
|
||||
};
|
||||
|
||||
this._pdf.instance.UI.annotationPopup.add([addRectangleButton]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user