From 7612de56dddfa4bbc2fcc89eb8d447d563b37cf0 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 25 Jul 2023 22:43:28 +0300 Subject: [PATCH] RED-7155 - save and abort actions no more available when there is no change when resize --- .../services/annotation-actions.service.ts | 1 + .../services/pdf-annotation-actions.service.ts | 18 ++++++++++-------- .../file-preview/services/pdf-proxy.service.ts | 1 + .../services/annotation-manager.service.ts | 5 +++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index adb5cc314..7f0cf09fd 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -259,6 +259,7 @@ export class AnnotationActionsService { async cancelResize(annotationWrapper: AnnotationWrapper) { this._annotationManager.resizingAnnotationId = undefined; + this._annotationManager.resizingHasStarted = false; this._annotationManager.delete(annotationWrapper); await this._annotationDrawService.draw([annotationWrapper], this._skippedService.hideSkipped(), this._state.dossierTemplateId); this._annotationManager.deselect(); diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts index 1a2082fc2..e1c2418d6 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts @@ -8,7 +8,6 @@ import { AnnotationActionsService } from './annotation-actions.service'; import { IqserPermissionsService } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { IHeaderElement } from '@red/domain'; -import { Roles } from '@users/roles'; import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service'; import { BASE_HREF_FN } from '@iqser/common-ui/lib/utils'; @@ -32,14 +31,17 @@ export class PdfAnnotationActionsService { const firstAnnotation = annotations[0]; // if we already entered resize-mode previously if (firstAnnotation.id === this.#annotationManager.resizingAnnotationId) { - const acceptResizeButton = this.#getButton('check', _('annotation-actions.resize-accept.label'), () => - this.#annotationActionsService.acceptResize(firstAnnotation), - ); - const cancelResizeButton = this.#getButton('close', _('annotation-actions.resize-cancel.label'), () => - this.#annotationActionsService.cancelResize(firstAnnotation), - ); + if (this.#annotationManager.resizingHasStarted) { + const acceptResizeButton = this.#getButton('check', _('annotation-actions.resize-accept.label'), () => + this.#annotationActionsService.acceptResize(firstAnnotation), + ); + const cancelResizeButton = this.#getButton('close', _('annotation-actions.resize-cancel.label'), () => + this.#annotationActionsService.cancelResize(firstAnnotation), + ); - return [acceptResizeButton, cancelResizeButton]; + return [acceptResizeButton, cancelResizeButton]; + } + return []; } const resizeButton = this.#getButton('resize', _('annotation-actions.resize.label'), () => diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index d8ecf8b89..96c4f81fb 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -346,6 +346,7 @@ export class PdfProxyService { // which is automatically converted to redaction when resized, // so the original annotation(wrapper) is removed this._annotationManager.resizingAnnotationId = undefined; + this._annotationManager.resizingHasStarted = false; return; } diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts index 004d735a9..1e0ae111c 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts @@ -19,6 +19,7 @@ export class REDAnnotationManager { readonly #annotationSelected$ = new Subject<[Annotation[], string]>(); readonly annotationSelected$ = this.#annotationSelected$.asObservable(); resizingAnnotationId?: string = undefined; + resizingHasStarted = false; readonly hidden = this.#hidden.asReadonly(); get selected() { @@ -144,6 +145,10 @@ export class REDAnnotationManager { this.#manager.selectAnnotations(annotations); annotations[0].disableRotationControl(); } + if (action === 'modify' && options.source === 'resize' && !this.resizingHasStarted) { + this.resizingHasStarted = true; + this.#annotationSelected$.next([annotations, action]); + } }); }