DM-588 - Do not allow any annotations or annotation changes while auto-analysis is disabled

This commit is contained in:
Valentin Mihai 2023-11-21 21:12:21 +02:00
parent afc46ac7a7
commit 212481f44f
5 changed files with 30 additions and 16 deletions

View File

@ -27,7 +27,7 @@
<ng-container *ngIf="!resizing">
<iqser-circle-button
(action)="resize()"
*ngIf="annotationPermissions.canResizeAnnotation && annotations.length === 1"
*ngIf="canResize"
[attr.help-mode-key]="helpModeKey('resize')"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.resize.label' | translate"

View File

@ -68,17 +68,24 @@ export class AnnotationActionsComponent implements OnChanges {
this.annotationPermissions.canRecategorizeAnnotation ||
this.annotationPermissions.canForceHint ||
this.annotationPermissions.canForceRedaction;
return this.annotations.length > 1
? this.#isDocumine
? this.annotationPermissions.canEditAnnotations
: this.annotationPermissions.canEditHints ||
this.annotationPermissions.canEditImages ||
this.annotationPermissions.canEditAnnotations
: canEditRedactions;
return (
this.#annotationChangesAllowed &&
(this.annotations.length > 1
? this.#isDocumine
? this.annotationPermissions.canEditAnnotations
: this.annotationPermissions.canEditHints ||
this.annotationPermissions.canEditImages ||
this.annotationPermissions.canEditAnnotations
: canEditRedactions)
);
}
get canResize(): boolean {
return this.#annotationChangesAllowed && this.annotationPermissions.canResizeAnnotation && this.annotations.length === 1;
}
get canRemoveRedaction(): boolean {
return this.annotationPermissions.canRemoveRedaction && this.#sameType;
return this.#annotationChangesAllowed && this.annotationPermissions.canRemoveRedaction && this.#sameType;
}
get viewerAnnotations() {
@ -148,4 +155,8 @@ export class AnnotationActionsComponent implements OnChanges {
this._iqserPermissionsService,
);
}
get #annotationChangesAllowed() {
return !this.#isDocumine || !this._state.file().excludedFromAutomaticAnalysis;
}
}

View File

@ -23,13 +23,13 @@ export class PdfAnnotationActionsService {
readonly #annotationManager = inject(REDAnnotationManager);
readonly #isDocumine = getConfig().IS_DOCUMINE;
get(annotations: AnnotationWrapper[]): IHeaderElement[] {
get(annotations: AnnotationWrapper[], annotationChangesAllowed: boolean): IHeaderElement[] {
const availableActions: IHeaderElement[] = [];
const permissions = this.#getAnnotationsPermissions(annotations);
const sameType = annotations.every(a => a.type === annotations[0].type);
// you can only resize one annotation at a time
if (permissions.canResizeAnnotation) {
if (permissions.canResizeAnnotation && annotationChangesAllowed) {
const firstAnnotation = annotations[0];
// if we already entered resize-mode previously
if (firstAnnotation.id === this.#annotationManager.resizingAnnotationId) {
@ -61,11 +61,11 @@ export class PdfAnnotationActionsService {
permissions.canForceHint ||
permissions.canForceRedaction;
const canEdit =
annotations.length > 1
(annotations.length > 1
? this.#isDocumine
? permissions.canEditAnnotations
: permissions.canEditHints || permissions.canEditImages || permissions.canEditAnnotations
: canEditRedactions;
: canEditRedactions) && annotationChangesAllowed;
if (canEdit) {
const editButton = this.#getButton('edit', _('annotation-actions.edit-redaction.label'), () =>
this.#annotationActionsService.editRedaction(annotations),
@ -94,7 +94,7 @@ export class PdfAnnotationActionsService {
availableActions.push(forceHintButton);
}
if (permissions.canRemoveRedaction && sameType) {
if (permissions.canRemoveRedaction && sameType && annotationChangesAllowed) {
const removeRedactionButton = this.#getButton('trash', _('annotation-actions.remove-annotation.remove-redaction'), () =>
this.#annotationActionsService.removeRedaction(annotations, permissions),
);

View File

@ -386,7 +386,10 @@ export class PdfProxyService {
actions.push(visibilityButton);
}
actions = this._multiSelectService.inactive() ? [...actions, ...this._pdfAnnotationActionsService.get(annotationWrappers)] : [];
const annotationChangesAllowed = !this.#isDocumine || !this._state.file().excludedFromAutomaticAnalysis;
actions = this._multiSelectService.inactive()
? [...actions, ...this._pdfAnnotationActionsService.get(annotationWrappers, annotationChangesAllowed)]
: [];
this._pdf.instance.UI.annotationPopup.update(actions);
}

@ -1 +1 @@
Subproject commit 87e1c8845276faa17b2f5d29c9bf4b3601aae0c0
Subproject commit 2bb459961af80944c5cd56bac8bff1fc786dbebc