RED-3495: OCR warning after manual changes

This commit is contained in:
Adina Țeudan 2022-03-15 21:44:19 +02:00
parent 9583eac24c
commit 77dda678a6
6 changed files with 37 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, forwardRef, Injector } from '@angular/core';
import { ChangeDetectionStrategy, Component, forwardRef, Injector, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DefaultListingServicesTmp, EntitiesService, ListingComponent } from '@iqser/common-ui';
import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.service';
@ -17,7 +17,7 @@ import { tap } from 'rxjs/operators';
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ArchivedDossiersScreenComponent extends ListingComponent<Dossier> {
export class ArchivedDossiersScreenComponent extends ListingComponent<Dossier> implements OnInit {
readonly tableColumnConfigs = this._configService.tableConfig;
readonly tableHeaderLabel = _('archived-dossiers-listing.table-header.title');

View File

@ -37,7 +37,7 @@ import { ExcludedPagesService } from '../../../../file-preview/services/excluded
import { tap } from 'rxjs/operators';
import { DocumentInfoService } from '../../../../file-preview/services/document-info.service';
import { ExpandableFileActionsComponent } from '@shared/components/expandable-file-actions/expandable-file-actions.component';
import { firstValueFrom } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { RedactionImportService } from '../../services/redaction-import.service';
import { PageRotationService } from '../../../../file-preview/services/page-rotation.service';
@ -325,6 +325,17 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
this._setup();
}
#showOCRConfirmationDialog(): Observable<boolean> {
const data = new ConfirmationDialogInput({
title: _('ocr.confirmation-dialog.title'),
question: _('ocr.confirmation-dialog.question'),
denyText: _('ocr.confirmation-dialog.cancel'),
});
const ref = this._dialogService.openDialog('confirm', null, data);
return ref.afterClosed();
}
private _triggerImportRedactions($event: MouseEvent) {
$event.stopPropagation();
this.importRedactionsInput.nativeElement.click();
@ -388,6 +399,12 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
private async _ocrFile($event: MouseEvent) {
$event.stopPropagation();
if (this.file.lastManualChangeDate) {
const confirm = await firstValueFrom(this.#showOCRConfirmationDialog());
if (!confirm) {
return;
}
}
if (this._pageRotationService) {
await firstValueFrom(this._pageRotationService.showConfirmationDialogIfHasRotations());
}

View File

@ -1578,6 +1578,13 @@
},
"title": "Benachrichtigungseinstellungen"
},
"ocr": {
"confirmation-dialog": {
"cancel": "",
"question": "",
"title": ""
}
},
"overwrite-files-dialog": {
"options": {
"cancel": "Alle Uploads abbrechen",

View File

@ -1578,6 +1578,13 @@
},
"title": "Notifications Preferences"
},
"ocr": {
"confirmation-dialog": {
"cancel": "Cancel",
"question": "Manual changes could get lost if OCR makes changes at those positions. Are you sure you want to proceed?",
"title": "Warning: the file has manual adjustments!"
}
},
"overwrite-files-dialog": {
"options": {
"cancel": "Cancel all uploads",

View File

@ -42,6 +42,7 @@ export class File extends Entity<IFile> implements IFile, IRouterPath {
readonly workflowStatus: WorkflowFileStatus;
readonly fileManipulationDate: string;
readonly redactionModificationDate: string;
readonly lastManualChangeDate?: string;
readonly statusSort: number;
readonly cacheIdentifier?: string;
@ -100,6 +101,7 @@ export class File extends Entity<IFile> implements IFile, IRouterPath {
this.hasSuggestions = !!file.hasSuggestions;
this.fileManipulationDate = file.fileManipulationDate ?? '';
this.redactionModificationDate = file.redactionModificationDate ?? '';
this.lastManualChangeDate = file.lastManualChangeDate;
this.statusSort = StatusSorter[this.workflowStatus];
this.cacheIdentifier = btoa(this.fileManipulationDate ?? '');

View File

@ -152,4 +152,5 @@ export interface IFile {
*/
readonly fileManipulationDate: string | null;
readonly redactionModificationDate: string | null;
readonly lastManualChangeDate?: string;
}