RED-7155 - save and abort actions no more available when there is no change when resize

This commit is contained in:
Valentin Mihai 2023-07-25 22:43:28 +03:00
parent 860c989a44
commit 7612de56dd
4 changed files with 17 additions and 8 deletions

View File

@ -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();

View File

@ -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'), () =>

View File

@ -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;
}

View File

@ -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]);
}
});
}