RED-7155 update resize redactions dialog
This commit is contained in:
parent
cbba7a1e12
commit
fc3d3cb87e
@ -1,5 +1,5 @@
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { Dictionary } from '@red/domain';
|
||||
|
||||
export const canUndo = (annotation: AnnotationWrapper, isApprover: boolean) =>
|
||||
@ -39,7 +39,9 @@ export const canRecategorizeAnnotation = (annotation: AnnotationWrapper, canReca
|
||||
|
||||
export const canResizeAnnotation = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
|
||||
canAddRedaction &&
|
||||
!annotation.isSkipped &&
|
||||
!annotation.pending &&
|
||||
(((annotation.isRedacted || annotation.isImage) && !annotation.isSuggestion) ||
|
||||
annotation.isSuggestionResize ||
|
||||
annotation.isRecommendation) &&
|
||||
!annotation.pending;
|
||||
annotation.isDictBasedHint ||
|
||||
annotation.isRecommendation);
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { Dictionary } from '@red/domain';
|
||||
import { isArray } from 'lodash-es';
|
||||
import { IqserPermissionsService } from '@iqser/common-ui';
|
||||
import { Dictionary } from '@red/domain';
|
||||
import { Roles } from '@users/roles';
|
||||
import { isArray } from 'lodash-es';
|
||||
import {
|
||||
canAcceptRecommendation,
|
||||
canChangeLegalBasis,
|
||||
@ -16,6 +15,7 @@ import {
|
||||
canResizeAnnotation,
|
||||
canUndo,
|
||||
} from './annotation-permissions.utils';
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
|
||||
export class AnnotationPermissions {
|
||||
canUndo = true;
|
||||
@ -64,6 +64,22 @@ export class AnnotationPermissions {
|
||||
return summedPermissions;
|
||||
}
|
||||
|
||||
static reduce(permissions: AnnotationPermissions[]): AnnotationPermissions {
|
||||
const result = new AnnotationPermissions();
|
||||
result.canResizeAnnotation = permissions.length === 1 && permissions[0].canResizeAnnotation;
|
||||
result.canChangeLegalBasis = permissions.reduce((acc, next) => acc && next.canChangeLegalBasis, true);
|
||||
result.canRecategorizeAnnotation = permissions.reduce((acc, next) => acc && next.canRecategorizeAnnotation, true);
|
||||
result.canRemoveFromDictionary = permissions.reduce((acc, next) => acc && next.canRemoveFromDictionary, true);
|
||||
result.canAcceptRecommendation = permissions.reduce((acc, next) => acc && next.canAcceptRecommendation, true);
|
||||
result.canMarkAsFalsePositive = permissions.reduce((acc, next) => acc && next.canMarkAsFalsePositive, true);
|
||||
result.canForceRedaction = permissions.reduce((acc, next) => acc && next.canForceRedaction, true);
|
||||
result.canForceHint = permissions.reduce((acc, next) => acc && next.canForceHint, true);
|
||||
result.canRemoveOnlyHere = permissions.reduce((acc, next) => acc && next.canRemoveOnlyHere, true);
|
||||
result.canRemoveRedaction = permissions.reduce((acc, next) => acc && next.canRemoveRedaction, true);
|
||||
result.canUndo = permissions.reduce((acc, next) => acc && next.canUndo, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
private _merge(permissions: AnnotationPermissions) {
|
||||
for (const key of Object.keys(this)) {
|
||||
if (typeof this[key] === 'boolean') {
|
||||
|
||||
@ -17,6 +17,7 @@ import {
|
||||
IRectangle,
|
||||
IRedactionLogEntry,
|
||||
LogEntryEngine,
|
||||
LogEntryEngines,
|
||||
LogEntryStatuses,
|
||||
LowLevelFilterTypes,
|
||||
ManualRedactionTypes,
|
||||
@ -180,6 +181,10 @@ export class AnnotationWrapper implements IListable {
|
||||
return 'square';
|
||||
}
|
||||
|
||||
get isDictBasedHint() {
|
||||
return this.isHint && this.engines.includes(LogEntryEngines.DICTIONARY);
|
||||
}
|
||||
|
||||
get isIgnoredHint() {
|
||||
return this.superType === SuperTypes.IgnoredHint;
|
||||
}
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
||||
import { Dictionary, Dossier, SuperTypes } from '@red/domain';
|
||||
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { Dictionary, SuperTypes } from '@red/domain';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||
import { Roles } from '@users/roles';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
import { IMAGE_CATEGORIES } from '../../utils/constants';
|
||||
import { getEditRedactionOptions, RedactOrHintOption } from '../../utils/dialog-options';
|
||||
import { EditRedactionData, EditRedactResult } from '../../utils/dialog-types';
|
||||
import { IMAGE_CATEGORIES } from '../../utils/constants';
|
||||
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
|
||||
@Component({
|
||||
templateUrl: './edit-redaction-dialog.component.html',
|
||||
@ -19,6 +19,8 @@ export class EditRedactionDialogComponent
|
||||
extends IqserDialogComponent<EditRedactionDialogComponent, EditRedactionData, EditRedactResult>
|
||||
implements OnInit
|
||||
{
|
||||
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
|
||||
readonly #applyToAllDossiers = this.data.applyToAllDossiers;
|
||||
readonly roles = Roles;
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
readonly redactedText: string;
|
||||
@ -28,24 +30,17 @@ export class EditRedactionDialogComponent
|
||||
readonly showLegalReason: boolean;
|
||||
readonly isHint: boolean;
|
||||
readonly showExtras: boolean;
|
||||
|
||||
options: DetailsRadioOption<RedactOrHintOption>[] | undefined;
|
||||
legalOptions: LegalBasisOption[] = [];
|
||||
dictionaries: Dictionary[] = [];
|
||||
form: UntypedFormGroup;
|
||||
readonly #dossier: Dossier;
|
||||
|
||||
#applyToAllDossiers: boolean;
|
||||
readonly form;
|
||||
|
||||
constructor(
|
||||
private readonly _justificationsService: JustificationsService,
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
) {
|
||||
super();
|
||||
this.#dossier = this._activeDossiersService.find(this.data.dossierId);
|
||||
this.#applyToAllDossiers = this.data.applyToAllDossiers;
|
||||
const annotations = this.data.annotations;
|
||||
const firstEntry = annotations[0];
|
||||
this.isImage = [...IMAGE_CATEGORIES, 'ocr'].includes(firstEntry.type);
|
||||
@ -126,7 +121,7 @@ export class EditRedactionDialogComponent
|
||||
);
|
||||
}
|
||||
|
||||
#getForm(): UntypedFormGroup {
|
||||
#getForm() {
|
||||
return this._formBuilder.group({
|
||||
reason: [null],
|
||||
comment: [null],
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
<section class="dialog">
|
||||
<form (submit)="save()" [formGroup]="form">
|
||||
<div class="dialog-header heading-l" [translate]="'recategorize-image-dialog.header'"></div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<div class="iqser-input-group required w-400">
|
||||
<label [translate]="'recategorize-image-dialog.content.type'"></label>
|
||||
<mat-form-field>
|
||||
<mat-select
|
||||
[placeholder]="'recategorize-image-dialog.content.type-placeholder' | translate"
|
||||
class="full-width"
|
||||
formControlName="type"
|
||||
>
|
||||
<mat-option *ngFor="let option of typeOptions" [value]="option">
|
||||
{{ translations[option] | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="iqser-input-group w-300">
|
||||
<label [translate]="'recategorize-image-dialog.content.comment'"></label>
|
||||
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<iqser-icon-button
|
||||
[disabled]="disabled"
|
||||
[label]="'recategorize-image-dialog.actions.save' | translate"
|
||||
[submit]="true"
|
||||
[type]="iconButtonTypes.primary"
|
||||
></iqser-icon-button>
|
||||
|
||||
<div class="all-caps-label cancel" mat-dialog-close [translate]="'recategorize-image-dialog.actions.cancel'"></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
|
||||
</section>
|
||||
@ -1,41 +0,0 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { imageCategoriesTranslations } from '@translations/image-categories-translations';
|
||||
import { Dossier, ImageCategory } from '@red/domain';
|
||||
import { BaseDialogComponent } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
templateUrl: './recategorize-image-dialog.component.html',
|
||||
})
|
||||
export class RecategorizeImageDialogComponent extends BaseDialogComponent implements OnInit {
|
||||
readonly typeOptions: ImageCategory[] = ['signature', 'logo', 'formula', 'image'];
|
||||
readonly translations = imageCategoriesTranslations;
|
||||
|
||||
constructor(
|
||||
protected readonly _dialogRef: MatDialogRef<RecategorizeImageDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) readonly data: { annotations: AnnotationWrapper[]; dossier: Dossier },
|
||||
) {
|
||||
super(_dialogRef);
|
||||
}
|
||||
|
||||
get changed(): boolean {
|
||||
return this.form.get('type').value !== this.data.annotations[0].type;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.form = this._formBuilder.group({
|
||||
type: [this.data.annotations[0].type, Validators.required],
|
||||
comment: [null],
|
||||
});
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
}
|
||||
|
||||
save() {
|
||||
this._dialogRef.close({
|
||||
type: this.form.get('type').value,
|
||||
comment: this.form.get('comment').value,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,19 @@
|
||||
<section class="dialog">
|
||||
<form (submit)="save()" [formGroup]="form">
|
||||
<div
|
||||
[innerHTML]="'resize-redaction.dialog.header' | translate : { type: redaction.hint ? 'hint' : 'redaction' }"
|
||||
[innerHTML]="'resize-redaction.dialog.header' | translate: { type: redaction.hint ? 'hint' : 'redaction' }"
|
||||
class="dialog-header heading-l"
|
||||
></div>
|
||||
|
||||
<div class="dialog-content redaction">
|
||||
<div class="iqser-input-group w-450">
|
||||
<div *ngIf="!redaction.isImage" class="iqser-input-group w-450">
|
||||
<label [translate]="'resize-redaction.dialog.content.original-text'" class="selected-text"></label>
|
||||
{{ redaction.value }}
|
||||
<span class="pl-20">{{ redaction.value }}</span>
|
||||
</div>
|
||||
|
||||
<div class="iqser-input-group w-450">
|
||||
<div *ngIf="!redaction.isImage" class="iqser-input-group w-450">
|
||||
<label [translate]="'resize-redaction.dialog.content.resized-text'" class="selected-text"></label>
|
||||
{{ data.text }}
|
||||
<span class="pl-20">{{ data.text }}</span>
|
||||
</div>
|
||||
|
||||
<iqser-details-radio [options]="options" formControlName="option"></iqser-details-radio>
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { OverlayModule } from '@angular/cdk/overlay';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
|
||||
import {
|
||||
CapitalizePipe,
|
||||
CircleButtonComponent,
|
||||
@ -20,58 +23,54 @@ import {
|
||||
RoundCheckboxComponent,
|
||||
StopPropagationDirective,
|
||||
} from '@iqser/common-ui';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { FilePreviewScreenComponent } from './file-preview-screen.component';
|
||||
import { FileWorkloadComponent } from './components/file-workload/file-workload.component';
|
||||
import { AnnotationDetailsComponent } from './components/annotation-details/annotation-details.component';
|
||||
import { AnnotationsListComponent } from './components/annotations-list/annotations-list.component';
|
||||
import { PageIndicatorComponent } from './components/page-indicator/page-indicator.component';
|
||||
import { PageExclusionComponent } from './components/page-exclusion/page-exclusion.component';
|
||||
import { AnnotationActionsComponent } from './components/annotation-actions/annotation-actions.component';
|
||||
import { CommentsComponent } from './components/comments/comments.component';
|
||||
import { DocumentInfoComponent } from './components/document-info/document-info.component';
|
||||
import { OverlayModule } from '@angular/cdk/overlay';
|
||||
import { ViewSwitchComponent } from './components/view-switch/view-switch.component';
|
||||
import { UserManagementComponent } from './components/user-management/user-management.component';
|
||||
import { AnnotationReferencesListComponent } from './components/annotation-references-list/annotation-references-list.component';
|
||||
import { AcceptRecommendationDialogComponent } from './dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
|
||||
import { AnnotationCardComponent } from './components/annotation-card/annotation-card.component';
|
||||
import { AnnotationReferencesPageIndicatorComponent } from './components/annotation-references-page-indicator/annotation-references-page-indicator.component';
|
||||
import { HighlightsSeparatorComponent } from './components/highlights-separator/highlights-separator.component';
|
||||
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
|
||||
import { ManualAnnotationDialogComponent } from './dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { ForceAnnotationDialogComponent } from './dialogs/force-redaction-dialog/force-annotation-dialog.component';
|
||||
import { ResizeRedactionDialogComponent } from './dialogs/resize-redaction-dialog/resize-redaction-dialog.component';
|
||||
import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
||||
import { RecategorizeImageDialogComponent } from './dialogs/recategorize-image-dialog/recategorize-image-dialog.component';
|
||||
import { HighlightActionDialogComponent } from './dialogs/highlight-action-dialog/highlight-action-dialog.component';
|
||||
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
|
||||
import { DocumentInfoDialogComponent } from './dialogs/document-info-dialog/document-info-dialog.component';
|
||||
import { ManualRedactionService } from './services/manual-redaction.service';
|
||||
import { AnnotationWrapperComponent } from './components/annotation-wrapper/annotation-wrapper.component';
|
||||
import { AnnotationReferenceComponent } from './components/annotation-reference/annotation-reference.component';
|
||||
import { ImportRedactionsDialogComponent } from './dialogs/import-redactions-dialog/import-redactions-dialog';
|
||||
import { DocumentUnloadedGuard } from './services/document-unloaded.guard';
|
||||
import { FilePreviewRightContainerComponent } from './components/right-container/file-preview-right-container.component';
|
||||
import { ReadonlyBannerComponent } from './components/readonly-banner/readonly-banner.component';
|
||||
import { PagesComponent } from './components/pages/pages.component';
|
||||
import { SharedModule } from '@shared/shared.module';
|
||||
import { SharedDossiersModule } from '../shared-dossiers/shared-dossiers.module';
|
||||
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
|
||||
import { RemoveRedactionDialogComponent } from './dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
|
||||
import { IqserUsersModule } from '@iqser/common-ui/lib/users';
|
||||
import { IqserFiltersModule } from '@iqser/common-ui/lib/filtering';
|
||||
import { StatusBarComponent } from '@iqser/common-ui/lib/shared';
|
||||
import { TenantPipe } from '@iqser/common-ui/lib/tenants';
|
||||
import { IqserUsersModule } from '@iqser/common-ui/lib/users';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SharedModule } from '@shared/shared.module';
|
||||
import { SharedDossiersModule } from '../shared-dossiers/shared-dossiers.module';
|
||||
import { AnnotationActionsComponent } from './components/annotation-actions/annotation-actions.component';
|
||||
import { AnnotationCardComponent } from './components/annotation-card/annotation-card.component';
|
||||
import { AnnotationDetailsComponent } from './components/annotation-details/annotation-details.component';
|
||||
import { AnnotationReferenceComponent } from './components/annotation-reference/annotation-reference.component';
|
||||
import { AnnotationReferencesListComponent } from './components/annotation-references-list/annotation-references-list.component';
|
||||
import { AnnotationReferencesPageIndicatorComponent } from './components/annotation-references-page-indicator/annotation-references-page-indicator.component';
|
||||
import { AnnotationWrapperComponent } from './components/annotation-wrapper/annotation-wrapper.component';
|
||||
import { AnnotationsListComponent } from './components/annotations-list/annotations-list.component';
|
||||
import { CommentsComponent } from './components/comments/comments.component';
|
||||
import { DocumentInfoComponent } from './components/document-info/document-info.component';
|
||||
import { FileWorkloadComponent } from './components/file-workload/file-workload.component';
|
||||
import { HighlightsSeparatorComponent } from './components/highlights-separator/highlights-separator.component';
|
||||
import { PageExclusionComponent } from './components/page-exclusion/page-exclusion.component';
|
||||
import { PageIndicatorComponent } from './components/page-indicator/page-indicator.component';
|
||||
import { PagesComponent } from './components/pages/pages.component';
|
||||
import { ReadonlyBannerComponent } from './components/readonly-banner/readonly-banner.component';
|
||||
import { FilePreviewRightContainerComponent } from './components/right-container/file-preview-right-container.component';
|
||||
import { UserManagementComponent } from './components/user-management/user-management.component';
|
||||
import { ViewSwitchComponent } from './components/view-switch/view-switch.component';
|
||||
import { AcceptRecommendationDialogComponent } from './dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
|
||||
import { AddHintDialogComponent } from './dialogs/add-hint-dialog/add-hint-dialog.component';
|
||||
import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
||||
import { AddAnnotationDialogComponent } from './dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component';
|
||||
import { EditAnnotationDialogComponent } from './dialogs/docu-mine/edit-annotation-dialog/edit-annotation-dialog.component';
|
||||
import { RemoveAnnotationDialogComponent } from './dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component';
|
||||
import { ResizeAnnotationDialogComponent } from './dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component';
|
||||
import { EditAnnotationDialogComponent } from './dialogs/docu-mine/edit-annotation-dialog/edit-annotation-dialog.component';
|
||||
import { DocumentInfoDialogComponent } from './dialogs/document-info-dialog/document-info-dialog.component';
|
||||
import { EditRedactionDialogComponent } from './dialogs/edit-redaction-dialog/edit-redaction-dialog.component';
|
||||
import { TablesService } from './services/tables.service';
|
||||
import { ForceAnnotationDialogComponent } from './dialogs/force-redaction-dialog/force-annotation-dialog.component';
|
||||
import { HighlightActionDialogComponent } from './dialogs/highlight-action-dialog/highlight-action-dialog.component';
|
||||
import { ImportRedactionsDialogComponent } from './dialogs/import-redactions-dialog/import-redactions-dialog';
|
||||
import { ManualAnnotationDialogComponent } from './dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { RedactRecommendationDialogComponent } from './dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component';
|
||||
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
|
||||
import { RemoveRedactionDialogComponent } from './dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
|
||||
import { ResizeRedactionDialogComponent } from './dialogs/resize-redaction-dialog/resize-redaction-dialog.component';
|
||||
import { FilePreviewScreenComponent } from './file-preview-screen.component';
|
||||
import { DocumentUnloadedGuard } from './services/document-unloaded.guard';
|
||||
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
|
||||
import { ManualRedactionService } from './services/manual-redaction.service';
|
||||
import { TablesService } from './services/tables.service';
|
||||
|
||||
const routes: IqserRoutes = [
|
||||
{
|
||||
@ -87,7 +86,6 @@ const dialogs = [
|
||||
ForceAnnotationDialogComponent,
|
||||
ResizeRedactionDialogComponent,
|
||||
ChangeLegalBasisDialogComponent,
|
||||
RecategorizeImageDialogComponent,
|
||||
HighlightActionDialogComponent,
|
||||
AcceptRecommendationDialogComponent,
|
||||
DocumentInfoDialogComponent,
|
||||
|
||||
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { IqserDialog } from '@common-ui/dialog/iqser-dialog.service';
|
||||
import { getConfig } from '@iqser/common-ui';
|
||||
import { List, log } from '@iqser/common-ui/lib/utils';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { Core } from '@pdftron/webviewer';
|
||||
import {
|
||||
@ -44,7 +45,7 @@ import { SkippedService } from './skipped.service';
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationActionsService {
|
||||
readonly #isDocumine;
|
||||
readonly #isDocumine = getConfig().IS_DOCUMINE;
|
||||
|
||||
constructor(
|
||||
private readonly _manualRedactionService: ManualRedactionService,
|
||||
@ -59,9 +60,7 @@ export class AnnotationActionsService {
|
||||
private readonly _skippedService: SkippedService,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
) {
|
||||
this.#isDocumine = getConfig().IS_DOCUMINE;
|
||||
}
|
||||
) {}
|
||||
|
||||
removeHighlights(highlights: AnnotationWrapper[]): void {
|
||||
const data = this.#getHighlightOperationData(EarmarkOperation.REMOVE, highlights);
|
||||
@ -73,18 +72,6 @@ export class AnnotationActionsService {
|
||||
this._dialogService.openDialog('highlightAction', data);
|
||||
}
|
||||
|
||||
rejectSuggestion(annotations: AnnotationWrapper[]) {
|
||||
const { dossierId, fileId } = this._state;
|
||||
this.#processObsAndEmit(
|
||||
this._manualRedactionService.declineOrRemove(
|
||||
annotations.map(a => a.id),
|
||||
dossierId,
|
||||
fileId,
|
||||
annotations[0].isModifyDictionary,
|
||||
),
|
||||
).then();
|
||||
}
|
||||
|
||||
forceAnnotation(annotations: AnnotationWrapper[], hint: boolean = false) {
|
||||
const { dossierId, fileId } = this._state;
|
||||
const data = { dossier: this._state.dossier(), annotations, hint };
|
||||
@ -147,7 +134,7 @@ export class AnnotationActionsService {
|
||||
await this.#processObsAndEmit(zip(requests).pipe(log()));
|
||||
}
|
||||
|
||||
async removeRedaction(redaction: AnnotationWrapper, permissions) {
|
||||
async removeRedaction(redaction: AnnotationWrapper, permissions: AnnotationPermissions) {
|
||||
const removePermissions: RemoveRedactionPermissions = {
|
||||
canRemoveOnlyHere: permissions.canRemoveOnlyHere,
|
||||
canRemoveFromDictionary: permissions.canRemoveFromDictionary,
|
||||
@ -181,19 +168,6 @@ export class AnnotationActionsService {
|
||||
}
|
||||
}
|
||||
|
||||
recategorizeImages(annotations: AnnotationWrapper[]) {
|
||||
const data = { annotations, dossier: this._state.dossier() };
|
||||
const { dossierId, fileId } = this._state;
|
||||
this._dialogService.openDialog('recategorizeImage', data, ({ comment, type }: { type: string; comment: string }) => {
|
||||
const body: List<IRecategorizationRequest> = annotations.map(({ id }) => ({
|
||||
annotationId: id,
|
||||
type,
|
||||
comment,
|
||||
}));
|
||||
this.#processObsAndEmit(this._manualRedactionService.recategorizeRedactions(body, dossierId, fileId)).then();
|
||||
});
|
||||
}
|
||||
|
||||
undoDirectAction(annotations: AnnotationWrapper[]) {
|
||||
const { dossierId, fileId } = this._state;
|
||||
const modifyDictionary = annotations[0].isModifyDictionary;
|
||||
@ -333,9 +307,7 @@ export class AnnotationActionsService {
|
||||
}
|
||||
|
||||
async #processObsAndEmit(obs: Observable<unknown>) {
|
||||
await firstValueFrom(obs)
|
||||
.then(() => this._fileDataService.annotationsChanged())
|
||||
.catch(() => this._fileDataService.annotationsChanged());
|
||||
await firstValueFrom(obs).finally(() => this._fileDataService.annotationsChanged());
|
||||
}
|
||||
|
||||
#getFalsePositiveText(annotation: AnnotationWrapper) {
|
||||
@ -389,7 +361,7 @@ export class AnnotationActionsService {
|
||||
rect.topLeft.x + rect.width - 2,
|
||||
rect.topLeft.y + rect.height - percentHeightOffset,
|
||||
);
|
||||
const quadWords = await this._extractTextFromRect(page, pdfNetRect);
|
||||
const quadWords = await this.#extractTextFromRect(page, pdfNetRect);
|
||||
words.push(...quadWords);
|
||||
}
|
||||
|
||||
@ -411,7 +383,7 @@ export class AnnotationActionsService {
|
||||
};
|
||||
}
|
||||
|
||||
private async _extractTextFromRect(page: Core.PDFNet.Page, rect: Core.PDFNet.Rect) {
|
||||
async #extractTextFromRect(page: Core.PDFNet.Page, rect: Core.PDFNet.Rect) {
|
||||
const txt = await this._pdf.PDFNet.TextExtractor.create();
|
||||
await txt.begin(page, rect); // Read the page.
|
||||
|
||||
|
||||
@ -1,23 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ForceAnnotationDialogComponent } from '../dialogs/force-redaction-dialog/force-annotation-dialog.component';
|
||||
import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component';
|
||||
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
||||
import { RecategorizeImageDialogComponent } from '../dialogs/recategorize-image-dialog/recategorize-image-dialog.component';
|
||||
import { ConfirmationDialogComponent, DialogConfig, DialogService } from '@iqser/common-ui';
|
||||
import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
||||
import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component';
|
||||
import { ForceAnnotationDialogComponent } from '../dialogs/force-redaction-dialog/force-annotation-dialog.component';
|
||||
import { HighlightActionDialogComponent } from '../dialogs/highlight-action-dialog/highlight-action-dialog.component';
|
||||
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { StructuredComponentManagementDialogComponent } from '../dialogs/structured-component-management-dialog/structured-component-management-dialog.component';
|
||||
|
||||
type DialogType =
|
||||
| 'confirm'
|
||||
| 'documentInfo'
|
||||
| 'rss'
|
||||
| 'recategorizeImage'
|
||||
| 'changeLegalBasis'
|
||||
| 'forceAnnotation'
|
||||
| 'manualAnnotation'
|
||||
| 'highlightAction';
|
||||
type DialogType = 'confirm' | 'documentInfo' | 'rss' | 'changeLegalBasis' | 'forceAnnotation' | 'manualAnnotation' | 'highlightAction';
|
||||
|
||||
@Injectable()
|
||||
export class FilePreviewDialogService extends DialogService<DialogType> {
|
||||
@ -30,9 +21,6 @@ export class FilePreviewDialogService extends DialogService<DialogType> {
|
||||
component: DocumentInfoDialogComponent,
|
||||
dialogConfig: { autoFocus: true },
|
||||
},
|
||||
recategorizeImage: {
|
||||
component: RecategorizeImageDialogComponent,
|
||||
},
|
||||
changeLegalBasis: {
|
||||
component: ChangeLegalBasisDialogComponent,
|
||||
},
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import { inject, Injectable, NgZone } from '@angular/core';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
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 { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service';
|
||||
import { IqserPermissionsService } from '@iqser/common-ui';
|
||||
import { BASE_HREF_FN } from '@iqser/common-ui/lib/utils';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { IHeaderElement } from '@red/domain';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service';
|
||||
import { AnnotationActionsService } from './annotation-actions.service';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
|
||||
@Injectable()
|
||||
export class PdfAnnotationActionsService {
|
||||
@ -27,7 +27,7 @@ export class PdfAnnotationActionsService {
|
||||
const permissions = this.#getAnnotationsPermissions(annotations);
|
||||
|
||||
// you can only resize one annotation at a time
|
||||
if (permissions.canResize) {
|
||||
if (permissions.canResizeAnnotation) {
|
||||
const firstAnnotation = annotations[0];
|
||||
// if we already entered resize-mode previously
|
||||
if (firstAnnotation.id === this.#annotationManager.resizingAnnotationId) {
|
||||
@ -103,22 +103,11 @@ export class PdfAnnotationActionsService {
|
||||
};
|
||||
}
|
||||
|
||||
#getAnnotationsPermissions(annotations: AnnotationWrapper[]) {
|
||||
#getAnnotationsPermissions(annotations: AnnotationWrapper[]): AnnotationPermissions {
|
||||
const dossier = this.#state.dossier();
|
||||
const isApprover = this.#permissionsService.isApprover(dossier);
|
||||
const dictionaries = this.#state.dictionaries;
|
||||
const permissions = annotations.map(a => AnnotationPermissions.forUser(isApprover, a, dictionaries, this.#iqserPermissionsService));
|
||||
return {
|
||||
canResize: permissions.length === 1 && permissions[0].canResizeAnnotation,
|
||||
canChangeLegalBasis: permissions.reduce((acc, next) => acc && next.canChangeLegalBasis, true),
|
||||
canRecategorizeAnnotation: permissions.reduce((acc, next) => acc && next.canRecategorizeAnnotation, true),
|
||||
canRemoveFromDictionary: permissions.reduce((acc, next) => acc && next.canRemoveFromDictionary, true),
|
||||
canAcceptRecommendation: permissions.reduce((acc, next) => acc && next.canAcceptRecommendation, true),
|
||||
canMarkAsFalsePositive: permissions.reduce((acc, next) => acc && next.canMarkAsFalsePositive, true),
|
||||
canForceRedaction: permissions.reduce((acc, next) => acc && next.canForceRedaction, true),
|
||||
canForceHint: permissions.reduce((acc, next) => acc && next.canForceHint, true),
|
||||
canRemoveOnlyHere: permissions.reduce((acc, next) => acc && next.canRemoveOnlyHere, true),
|
||||
canRemoveRedaction: permissions.reduce((acc, next) => acc && next.canRemoveRedaction, true),
|
||||
};
|
||||
return AnnotationPermissions.reduce(permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit c9abddb3017082bb169ef6da2c1a63b0b3cdf837
|
||||
Subproject commit 45622e7fd65f0e9115c5317774d1aefc2ab21090
|
||||
Loading…
x
Reference in New Issue
Block a user