Merge branch 'RED-7296' into 'master'

RED-7296: implemented rectangle deletion by pressing esc.

See merge request redactmanager/red-ui!289
This commit is contained in:
Dan Percic 2024-02-06 14:40:09 +01:00
commit 7656cd6000
4 changed files with 43 additions and 7 deletions

View File

@ -11,6 +11,7 @@ import { JustificationsService } from '@services/entity-services/justifications.
import { Roles } from '@users/roles'; import { Roles } from '@users/roles';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
import { ManualRedactionService } from '../../services/manual-redaction.service'; import { ManualRedactionService } from '../../services/manual-redaction.service';
import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service';
export interface LegalBasisOption { export interface LegalBasisOption {
label?: string; label?: string;
@ -40,6 +41,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
activeDossiersService: ActiveDossiersService, activeDossiersService: ActiveDossiersService,
private readonly _dictionaryService: DictionaryService, private readonly _dictionaryService: DictionaryService,
protected readonly _dialogRef: MatDialogRef<ManualAnnotationDialogComponent>, protected readonly _dialogRef: MatDialogRef<ManualAnnotationDialogComponent>,
private readonly _annotationManager: REDAnnotationManager,
@Inject(MAT_DIALOG_DATA) readonly data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string; file: File }, @Inject(MAT_DIALOG_DATA) readonly data: { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string; file: File },
) { ) {
super(_dialogRef); super(_dialogRef);
@ -111,6 +113,13 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
} }
} }
close() {
super.close();
if (this.isRectangle) {
this._annotationManager.delete(this._annotationManager.selected[0].Id);
}
}
#getRectangles() { #getRectangles() {
const quads = this.data.manualRedactionEntryWrapper.manualRedactionEntry.positions.find(a => !!a); const quads = this.data.manualRedactionEntryWrapper.manualRedactionEntry.positions.find(a => !!a);
const value: string = this.form.get('multiplePages').value.replace(/[^0-9-,]/g, ''); const value: string = this.form.get('multiplePages').value.replace(/[^0-9-,]/g, '');

View File

@ -294,11 +294,13 @@ export class FilePreviewScreenComponent
this._viewerHeaderService.enableLoadAllAnnotations(); // Reset the button state (since the viewer is reused between files) this._viewerHeaderService.enableLoadAllAnnotations(); // Reset the button state (since the viewer is reused between files)
super.ngOnDetach(); super.ngOnDetach();
document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener); document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.off('esc');
this._changeRef.markForCheck(); this._changeRef.markForCheck();
} }
ngOnDestroy() { ngOnDestroy() {
document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener); document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.off('esc');
super.ngOnDestroy(); super.ngOnDestroy();
} }
@ -309,6 +311,19 @@ export class FilePreviewScreenComponent
} }
} }
@Bind()
handleDeleteRectangleOnEsc($event: KeyboardEvent) {
$event.preventDefault();
if (!!this._annotationManager.selected[0]) {
const doesHaveWrapper = this._fileDataService.find(this._annotationManager.selected[0]?.Id);
if (!doesHaveWrapper) {
this._annotationManager.delete(this._annotationManager.selected[0]?.Id);
} else {
this._annotationManager.deselect(this._annotationManager.selected[0]?.Id);
}
}
}
async ngOnAttach(previousRoute: ActivatedRouteSnapshot) { async ngOnAttach(previousRoute: ActivatedRouteSnapshot) {
if (!this.state.file().canBeOpened) { if (!this.state.file().canBeOpened) {
return this.#navigateToDossier(); return this.#navigateToDossier();
@ -341,7 +356,7 @@ export class FilePreviewScreenComponent
this.pdfProxyService.configureElements(); this.pdfProxyService.configureElements();
this.#restoreOldFilters(); this.#restoreOldFilters();
document.documentElement.addEventListener('fullscreenchange', this.fullscreenListener); document.documentElement.addEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.on('esc', this.handleDeleteRectangleOnEsc);
this.#openComponentLogDialogIfDefault(); this.#openComponentLogDialogIfDefault();
this._viewerHeaderService.resetLayers(); this._viewerHeaderService.resetLayers();
} }

View File

@ -266,12 +266,18 @@ export class PdfViewer {
} }
#listenForEsc() { #listenForEsc() {
this.#instance.UI.hotkeys.on('esc', e => { this.#instance.UI.hotkeys.on('esc', {
e.preventDefault(); keydown: e => {
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) { e.preventDefault();
this.#focusViewer(); },
this.deactivateSearch(); keyup: e => {
} e.preventDefault();
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
this.#focusViewer();
this.deactivateSearch();
}
this.#clickSelectToolButton();
},
}); });
} }
@ -382,4 +388,9 @@ export class PdfViewer {
this.instance.UI.iframeWindow.document.getElementById('SearchPanel__input').blur(); this.instance.UI.iframeWindow.document.getElementById('SearchPanel__input').blur();
this.instance.UI.iframeWindow.focus(); this.instance.UI.iframeWindow.focus();
} }
#clickSelectToolButton() {
const selectButton = this.instance.UI.iframeWindow.document.querySelector('[data-element="selectToolButton"]') as HTMLElement;
selectButton.click();
}
} }

View File

@ -65,6 +65,7 @@ export const DISABLED_HOTKEYS = [
'SPACE', 'SPACE',
'UP', 'UP',
'DOWN', 'DOWN',
'ESCAPE',
'R', 'R',
'P', 'P',
'A', 'A',