RED-7550: wip
This commit is contained in:
parent
aa53e14afc
commit
77a8f36878
@ -16,6 +16,7 @@ import {
|
||||
canUndo,
|
||||
} from './annotation-permissions.utils';
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { IMAGE_CATEGORIES } from '../../modules/file-preview/utils/constants';
|
||||
|
||||
export class AnnotationPermissions {
|
||||
canUndo = true;
|
||||
@ -30,6 +31,8 @@ export class AnnotationPermissions {
|
||||
canRecategorizeAnnotation = true;
|
||||
canForceHint = true;
|
||||
canEditAnnotations = true;
|
||||
canEditHints = true;
|
||||
canEditImages = true;
|
||||
|
||||
static forUser(
|
||||
isApprover: boolean,
|
||||
@ -58,7 +61,22 @@ export class AnnotationPermissions {
|
||||
permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canAddRedaction);
|
||||
permissions.canRecategorizeAnnotation = canRecategorizeAnnotation(annotation, canAddRedaction);
|
||||
permissions.canResizeAnnotation = canResizeAnnotation(annotation, canAddRedaction);
|
||||
permissions.canEditAnnotations = annotation.isSkipped || annotation.isRedacted;
|
||||
|
||||
// if (isDocumine) {
|
||||
// annotation.isSkipped || annotation.isRedacted;
|
||||
// } else {
|
||||
// annotation.isImage || annotation.isOCR;
|
||||
// annotation.isSkipped || annotation.isRedacted;
|
||||
// annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint;
|
||||
// }
|
||||
// const skippedRedacted = annotation.isSkipped || annotation.isRedacted;
|
||||
// const ignoredHints = annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint;
|
||||
// const image = annotation
|
||||
|
||||
permissions.canEditAnnotations = (annotation.isSkipped || annotation.isRedacted) && !annotation.isImage;
|
||||
permissions.canEditHints =
|
||||
annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint;
|
||||
permissions.canEditImages = [...IMAGE_CATEGORIES, 'ocr'].includes(annotation.type);
|
||||
|
||||
summedPermissions._merge(permissions);
|
||||
}
|
||||
@ -79,6 +97,8 @@ export class AnnotationPermissions {
|
||||
result.canRemoveRedaction = permissions.reduce((acc, next) => acc && next.canRemoveRedaction, true);
|
||||
result.canUndo = permissions.reduce((acc, next) => acc && next.canUndo, true);
|
||||
result.canEditAnnotations = permissions.reduce((acc, next) => acc && next.canEditAnnotations, true);
|
||||
result.canEditHints = permissions.reduce((acc, next) => acc && next.canEditHints, true);
|
||||
result.canEditImages = permissions.reduce((acc, next) => acc && next.canEditImages, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,13 @@
|
||||
></div>
|
||||
|
||||
<div class="dialog-content redaction">
|
||||
<div *ngIf="!allRectangles && redactedText" class="iqser-input-group w-450">
|
||||
<label [translate]="'edit-redaction.dialog.content.redacted-text'" class="selected-text"></label>
|
||||
{{ redactedText }}
|
||||
<div *ngIf="!allRectangles && redactedTexts" class="iqser-input-group w-450">
|
||||
<label
|
||||
[translate]="'edit-redaction.dialog.content.redacted-text'"
|
||||
[translateParams]="{ length: redactedTexts.length }"
|
||||
class="selected-text"
|
||||
></label>
|
||||
{{ redactedTexts }}
|
||||
</div>
|
||||
|
||||
<div *ngIf="!isManualRedaction" class="iqser-input-group required w-450">
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { FormBuilder, FormControl } from '@angular/forms';
|
||||
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
||||
import { Dictionary, SuperTypes } from '@red/domain';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
@ -21,7 +21,7 @@ export class EditRedactionDialogComponent
|
||||
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
|
||||
readonly #applyToAllDossiers = this.data.applyToAllDossiers;
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
readonly redactedText: string;
|
||||
readonly redactedTexts?: string[];
|
||||
readonly isModifyDictionary: boolean;
|
||||
readonly isImage: boolean;
|
||||
readonly isManualRedaction: boolean;
|
||||
@ -32,27 +32,23 @@ export class EditRedactionDialogComponent
|
||||
options: DetailsRadioOption<RedactOrHintOption>[] | undefined;
|
||||
legalOptions: LegalBasisOption[] = [];
|
||||
dictionaries: Dictionary[] = [];
|
||||
readonly form = new FormGroup({
|
||||
reason: new FormControl<LegalBasisOption>(null),
|
||||
comment: new FormControl<string>(null),
|
||||
type: new FormControl<string>(this.data.annotations[0].type),
|
||||
section: new FormControl<string>(this.data.annotations[0].section),
|
||||
option: new FormControl<LegalBasisOption>(null),
|
||||
value: new FormControl<string>(this.allRectangles ? this.data.annotations[0].value : null),
|
||||
});
|
||||
readonly form = this.#getForm();
|
||||
|
||||
constructor(
|
||||
private readonly _justificationsService: JustificationsService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
) {
|
||||
super();
|
||||
const annotations = this.data.annotations;
|
||||
const firstEntry = annotations[0];
|
||||
this.isImage = [...IMAGE_CATEGORIES, 'ocr'].includes(firstEntry.type);
|
||||
this.redactedText = annotations.length === 1 && !this.isImage ? firstEntry.value : null;
|
||||
this.isModifyDictionary = firstEntry.isModifyDictionary;
|
||||
this.isManualRedaction = firstEntry.type === SuperTypes.ManualRedaction;
|
||||
this.isHint = firstEntry.isHint;
|
||||
const testImage = annotations.reduce((acc, next) => acc && [...IMAGE_CATEGORIES, 'ocr'].includes(next.type), true);
|
||||
console.log(testImage);
|
||||
this.redactedTexts = !testImage ? annotations.map(annotation => annotation.value) : null;
|
||||
this.isModifyDictionary = annotations.every(annotation => annotation.isModifyDictionary);
|
||||
this.isManualRedaction = annotations.every(annotation => annotation.type === SuperTypes.ManualRedaction);
|
||||
this.isHint = annotations.every(annotation => annotation.isHint);
|
||||
this.showExtras = !(this.isImage || this.isHint);
|
||||
}
|
||||
|
||||
@ -125,4 +121,17 @@ export class EditRedactionDialogComponent
|
||||
{ emitEvent: false },
|
||||
);
|
||||
}
|
||||
|
||||
#getForm() {
|
||||
const sameType = new Set(this.data.annotations.map(annotation => annotation.type)).size === 1;
|
||||
const sameSection = new Set(this.data.annotations.map(annotation => annotation.section)).size === 1;
|
||||
return this._formBuilder.group({
|
||||
reason: new FormControl<LegalBasisOption>(null),
|
||||
comment: new FormControl<string>(null),
|
||||
type: new FormControl<string>(sameType ? this.data.annotations[0].type : null),
|
||||
section: new FormControl<string>(sameSection ? this.data.annotations[0].section : null),
|
||||
option: new FormControl<LegalBasisOption>(null),
|
||||
value: new FormControl<string>(this.allRectangles ? this.data.annotations[0].value : null),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ export class AnnotationActionsService {
|
||||
};
|
||||
|
||||
const result = await this.#getEditRedactionDialog(data).result();
|
||||
console.log(result);
|
||||
|
||||
const requests: Observable<unknown>[] = [];
|
||||
|
||||
@ -113,13 +114,11 @@ export class AnnotationActionsService {
|
||||
}));
|
||||
requests.push(this._manualRedactionService.changeLegalBasis(changeLegalBasisBody, dossierId, fileId));
|
||||
}
|
||||
if (this.#isDocumine) {
|
||||
const recategorizeBody: List<IRecategorizationRequest> = annotations.map(annotation => ({
|
||||
annotationId: annotation.id,
|
||||
type: result.type ?? annotation.type,
|
||||
}));
|
||||
requests.push(this._manualRedactionService.recategorizeRedactions(recategorizeBody, dossierId, fileId));
|
||||
}
|
||||
const recategorizeBody: List<IRecategorizationRequest> = annotations.map(annotation => ({
|
||||
annotationId: annotation.id,
|
||||
type: result.type ?? annotation.type,
|
||||
}));
|
||||
requests.push(this._manualRedactionService.recategorizeRedactions(recategorizeBody, dossierId, fileId));
|
||||
|
||||
if (!requests.length) {
|
||||
return;
|
||||
|
||||
@ -48,12 +48,25 @@ export class PdfAnnotationActionsService {
|
||||
|
||||
availableActions.push(resizeButton);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
console.log(annotations);
|
||||
console.log(annotations.map(annotation => annotation.type));
|
||||
console.log(permissions);
|
||||
const canEditRedactions =
|
||||
permissions.canChangeLegalBasis ||
|
||||
permissions.canRecategorizeAnnotation ||
|
||||
permissions.canForceHint ||
|
||||
permissions.canForceRedaction;
|
||||
const canEdit = this.#isDocumine && annotations.length > 1 ? permissions.canEditAnnotations : canEditRedactions;
|
||||
const canEdit =
|
||||
annotations.length > 1
|
||||
? this.#isDocumine
|
||||
? permissions.canEditAnnotations
|
||||
: permissions.canEditHints || permissions.canEditImages || permissions.canEditAnnotations
|
||||
: canEditRedactions;
|
||||
if (canEdit) {
|
||||
const editButton = this.#getButton('edit', _('annotation-actions.edit-redaction.label'), () =>
|
||||
this.#annotationActionsService.editRedaction(annotations),
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"ADMIN_CONTACT_URL": null,
|
||||
"API_URL": "https://dan.iqser.cloud",
|
||||
"APP_NAME": "RedactManager",
|
||||
"IS_DOCUMINE": true,
|
||||
"IS_DOCUMINE": false,
|
||||
"RULE_EDITOR_DEV_ONLY": false,
|
||||
"AUTO_READ_TIME": 3,
|
||||
"BACKEND_APP_VERSION": "4.4.40",
|
||||
@ -18,8 +18,8 @@
|
||||
"SELECTION_MODE": "structural",
|
||||
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
||||
"ANNOTATIONS_THRESHOLD": 1000,
|
||||
"THEME": "scm",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/",
|
||||
"THEME": "redact",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/",
|
||||
"AVAILABLE_NOTIFICATIONS_DAYS": 30,
|
||||
"AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60,
|
||||
"NOTIFICATIONS_THRESHOLD": 1000,
|
||||
|
||||
@ -2056,7 +2056,7 @@
|
||||
"label": "Remove here"
|
||||
}
|
||||
},
|
||||
"redacted-text": ""
|
||||
"redacted-text": "Redacted {length, plural, one{text} other {texts}}"
|
||||
},
|
||||
"title": "Remove {count, plural, one{annotation} other {annotations}}"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user