Merge branch 'DM-412' into 'master'
DM-412: Apply bulk delete permissions in pdf actions service Closes DM-412 See merge request redactmanager/red-ui!80
This commit is contained in:
commit
6b8dc11fda
@ -25,8 +25,9 @@ export const canRemoveFromDictionary = (annotation: AnnotationWrapper) =>
|
||||
!annotation.pending &&
|
||||
!annotation.hasBeenResized;
|
||||
|
||||
export const canRemoveRedaction = (permissions: AnnotationPermissions) =>
|
||||
permissions.canRemoveOnlyHere || permissions.canRemoveFromDictionary || permissions.canMarkAsFalsePositive;
|
||||
export const canRemoveRedaction = (annotation: AnnotationWrapper, permissions: AnnotationPermissions) =>
|
||||
!annotation.isIgnoredHint &&
|
||||
(permissions.canRemoveOnlyHere || permissions.canRemoveFromDictionary || permissions.canMarkAsFalsePositive);
|
||||
|
||||
export const canChangeLegalBasis = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
|
||||
canAddRedaction && annotation.isRedacted && !annotation.pending;
|
||||
|
||||
@ -54,7 +54,7 @@ export class AnnotationPermissions {
|
||||
permissions.canMarkAsFalsePositive = canMarkAsFalsePositive(annotation, annotationEntity);
|
||||
permissions.canRemoveOnlyHere = canRemoveOnlyHere(annotation, canAddRedaction);
|
||||
permissions.canRemoveFromDictionary = canRemoveFromDictionary(annotation);
|
||||
permissions.canRemoveRedaction = canRemoveRedaction(permissions);
|
||||
permissions.canRemoveRedaction = canRemoveRedaction(annotation, permissions);
|
||||
permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canAddRedaction);
|
||||
permissions.canRecategorizeAnnotation = canRecategorizeAnnotation(annotation, canAddRedaction);
|
||||
permissions.canResizeAnnotation = canResizeAnnotation(annotation, canAddRedaction);
|
||||
|
||||
@ -60,14 +60,7 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
get canRemoveRedaction(): boolean {
|
||||
if (this.annotationPermissions.canRemoveRedaction) {
|
||||
if (this.annotations.length > 1) {
|
||||
const foundIgnoredHint = this.annotations.find(a => a.isIgnoredHint);
|
||||
return !foundIgnoredHint && this.#sameType;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.annotationPermissions.canRemoveRedaction && this.#sameType;
|
||||
}
|
||||
|
||||
get viewerAnnotations() {
|
||||
@ -78,6 +71,11 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.#annotations?.length === 1 && this.#annotations?.[0].id === this._annotationManager.resizingAnnotationId;
|
||||
}
|
||||
|
||||
get #sameType() {
|
||||
const type = this.annotations[0].superType;
|
||||
return this.annotations.every(a => a.superType === type);
|
||||
}
|
||||
|
||||
constructor(
|
||||
readonly viewModeService: ViewModeService,
|
||||
readonly helpModeService: HelpModeService,
|
||||
@ -126,6 +124,10 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.annotationActionsService.cancelResize(this.#annotations[0]);
|
||||
}
|
||||
|
||||
helpModeKey(action: string) {
|
||||
return this.#isDocumine ? `${action}_annotation` : '';
|
||||
}
|
||||
|
||||
#setPermissions() {
|
||||
this.annotationPermissions = AnnotationPermissions.forUser(
|
||||
this._permissionsService.isApprover(this._state.dossier()),
|
||||
@ -134,13 +136,4 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
this._iqserPermissionsService,
|
||||
);
|
||||
}
|
||||
|
||||
helpModeKey(action: string) {
|
||||
return this.#isDocumine ? `${action}_annotation` : '';
|
||||
}
|
||||
|
||||
get #sameType() {
|
||||
const type = this.annotations[0].superType;
|
||||
return this.annotations.every(a => a.superType === type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ export class PdfAnnotationActionsService {
|
||||
get(annotations: AnnotationWrapper[]): 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) {
|
||||
@ -82,7 +83,7 @@ export class PdfAnnotationActionsService {
|
||||
availableActions.push(forceHintButton);
|
||||
}
|
||||
|
||||
if (permissions.canRemoveRedaction) {
|
||||
if (permissions.canRemoveRedaction && sameType) {
|
||||
const removeRedactionButton = this.#getButton('trash', _('annotation-actions.remove-annotation.remove-redaction'), () =>
|
||||
this.#annotationActionsService.removeRedaction(annotations, permissions),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user