RED-3747: check pages not out of bounds, fix rectangle deletion time
This commit is contained in:
parent
a42c2364bc
commit
ffac0fb420
@ -415,13 +415,11 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
const quads = [this._annotationDrawService.annotationToQuads(activeAnnotation)];
|
||||
const manualRedactionEntry = this._getManualRedaction({ [activePage]: quads });
|
||||
this._cleanUpSelectionAndButtonState();
|
||||
this.pdfViewer.deleteAnnotations([activeAnnotation.Id]);
|
||||
|
||||
this.manualAnnotationRequested.emit({ manualRedactionEntry, type: 'REDACTION' });
|
||||
}
|
||||
|
||||
private _cleanUpSelectionAndButtonState() {
|
||||
this.pdfViewer.deselectAllAnnotations();
|
||||
this._headerConfigService.disable([HeaderElements.SHAPE_TOOL_GROUP_BUTTON]);
|
||||
this._headerConfigService.enable([HeaderElements.SHAPE_TOOL_GROUP_BUTTON]);
|
||||
}
|
||||
|
||||
@ -88,11 +88,16 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="isRectangle" class="apply-on-multiple-pages iqser-input-group w-450">
|
||||
<mat-checkbox #checkbox class="mb-15" color="primary">
|
||||
<mat-checkbox
|
||||
(change)="applyOnMultiplePages = !applyOnMultiplePages"
|
||||
[checked]="applyOnMultiplePages"
|
||||
class="mb-15"
|
||||
color="primary"
|
||||
>
|
||||
{{ 'manual-annotation.dialog.content.apply-on-multiple-pages' | translate }}
|
||||
</mat-checkbox>
|
||||
|
||||
<div *ngIf="checkbox.checked">
|
||||
<div *ngIf="applyOnMultiplePages">
|
||||
<input
|
||||
[placeholder]="'manual-annotation.dialog.content.apply-on-multiple-pages-placeholder' | translate"
|
||||
class="full-width"
|
||||
|
||||
@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
|
||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||
import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain';
|
||||
import { Dictionary, Dossier, File, IAddRedactionRequest } from '@red/domain';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
import { BaseDialogComponent, CircleButtonTypes, Toaster } from '@iqser/common-ui';
|
||||
@ -26,6 +26,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
isDictionaryRequest: boolean;
|
||||
isFalsePositiveRequest: boolean;
|
||||
isEditingSelectedText = false;
|
||||
applyOnMultiplePages = false;
|
||||
|
||||
possibleDictionaries: Dictionary[] = [];
|
||||
legalOptions: LegalBasisOption[] = [];
|
||||
@ -41,7 +42,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
protected readonly _injector: Injector,
|
||||
protected readonly _toaster: Toaster,
|
||||
protected readonly _dialogRef: MatDialogRef<ManualAnnotationDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) readonly data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string },
|
||||
@Inject(MAT_DIALOG_DATA) readonly data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string; file: File },
|
||||
) {
|
||||
super(_injector, _dialogRef);
|
||||
this._dossier = this._activeDossiersService.find(this.data.dossierId);
|
||||
@ -70,7 +71,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
}
|
||||
|
||||
get disabled() {
|
||||
return this.form.invalid;
|
||||
return this.form.invalid || (this.applyOnMultiplePages && !this.form.get('multiplePages')?.value);
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
@ -116,11 +117,14 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
const splitted = range.split('-');
|
||||
const startPage = parseInt(splitted[0], 10);
|
||||
const endPage = splitted.length > 1 ? parseInt(splitted[1], 10) : startPage;
|
||||
if (!startPage || !endPage) {
|
||||
if (!startPage || !endPage || startPage > this.data.file.numberOfPages || endPage > this.data.file.numberOfPages) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
for (let page = startPage; page <= endPage; page++) {
|
||||
if (page === wrapper.manualRedactionEntry.positions[0].page) {
|
||||
continue;
|
||||
}
|
||||
const manualRedactionEntry = { ...entry, positions: [{ ...quads, page }] };
|
||||
wrappers.push({ ...wrapper, manualRedactionEntry });
|
||||
}
|
||||
|
||||
@ -250,13 +250,18 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
openManualAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
|
||||
this._ngZone.run(() => {
|
||||
return this._ngZone.run(async () => {
|
||||
const file = await this.state.file;
|
||||
|
||||
this.dialogRef = this._dialogService.openDialog(
|
||||
'manualAnnotation',
|
||||
null,
|
||||
{ manualRedactionEntryWrapper, dossierId: this.dossierId },
|
||||
async (wrappers: ManualRedactionEntryWrapper[]) => {
|
||||
const file = await this.state.file;
|
||||
{ manualRedactionEntryWrapper, dossierId: this.dossierId, file },
|
||||
(wrappers: ManualRedactionEntryWrapper[]) => {
|
||||
const selectedAnnotations = this.pdf.annotationManager.getSelectedAnnotations();
|
||||
if (selectedAnnotations.length > 0) {
|
||||
this.pdf.deleteAnnotations([selectedAnnotations[0].Id]);
|
||||
}
|
||||
const add$ = this._manualRedactionService.addAnnotation(
|
||||
wrappers.map(w => w.manualRedactionEntry).filter(e => e.positions[0].page <= file.numberOfPages),
|
||||
this.dossierId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user