RED-4051: Update dictionary option when resizing annotation

This commit is contained in:
Adina Țeudan 2022-05-18 22:09:00 +03:00
parent bde56e7ada
commit 6435931682
10 changed files with 42 additions and 28 deletions

View File

@ -7,6 +7,12 @@
<label translate="resize-annotation-dialog.content.comment"></label>
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
</div>
<div *ngIf="form.get('updateDictionary')" class="iqser-input-group">
<mat-checkbox color="primary" formControlName="updateDictionary">
{{ 'resize-annotation-dialog.content.update-dictionary' | translate: { text: this.text } }}
</mat-checkbox>
</div>
</div>
<div class="dialog-actions">
@ -17,5 +23,5 @@
</div>
</form>
<iqser-circle-button class="dialog-close" icon="iqser:close" (action)="close()"></iqser-circle-button>
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
</section>

View File

@ -1,8 +1,8 @@
import { Component, Inject, Injector, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { FormBuilder } from '@angular/forms';
import { Dossier } from '@red/domain';
import { BaseDialogComponent } from '@iqser/common-ui';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
@Component({
templateUrl: './resize-annotation-dialog.component.html',
@ -12,7 +12,7 @@ export class ResizeAnnotationDialogComponent extends BaseDialogComponent impleme
private readonly _formBuilder: FormBuilder,
protected readonly _injector: Injector,
protected readonly _dialogRef: MatDialogRef<ResizeAnnotationDialogComponent>,
@Inject(MAT_DIALOG_DATA) private readonly _data: { dossier: Dossier },
@Inject(MAT_DIALOG_DATA) private readonly _data: { annotation: AnnotationWrapper; text?: string },
) {
super(_injector, _dialogRef);
}
@ -21,16 +21,24 @@ export class ResizeAnnotationDialogComponent extends BaseDialogComponent impleme
return !this.valid;
}
get text(): string {
return this._data.text;
}
ngOnInit() {
super.ngOnInit();
this.form = this._formBuilder.group({ comment: [null] });
const controlsConfig = { comment: [null] };
if (this._data.annotation.isModifyDictionary) {
controlsConfig['updateDictionary'] = [false];
}
this.form = this._formBuilder.group(controlsConfig);
this.initialFormValue = this.form.getRawValue();
}
save() {
this._dialogRef.close({
comment: this.form.get('comment').value,
});
this._dialogRef.close(this.form.getRawValue());
}
}

View File

@ -217,8 +217,8 @@ export class AnnotationActionsService {
img: this._convertPath('/assets/icons/general/check.svg'),
title: this._translateService.instant('annotation-actions.resize-accept.label'),
onClick: () =>
this._ngZone.run(() => {
this.acceptResize(null, firstAnnotation);
this._ngZone.run(async () => {
await this.acceptResize(null, firstAnnotation);
}),
});
availableActions.push({
@ -412,22 +412,21 @@ export class AnnotationActionsService {
this._pdf.annotationManager.selectAnnotation(viewerAnnotation);
}
acceptResize($event: MouseEvent, annotationWrapper: AnnotationWrapper) {
const data = { dossier: this._dossier };
async acceptResize($event: MouseEvent, annotation: AnnotationWrapper): Promise<void> {
const fileId = this._state.fileId;
this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string }) => {
const textAndPositions = await this._extractTextAndPositions(annotationWrapper.id);
const text =
annotationWrapper.value === 'Rectangle' ? 'Rectangle' : annotationWrapper.isImage ? 'Image' : textAndPositions.text;
const textAndPositions = await this._extractTextAndPositions(annotation.id);
const text = annotation.value === 'Rectangle' ? 'Rectangle' : annotation.isImage ? 'Image' : textAndPositions.text;
const data = { annotation, text };
this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string; updateDictionary: boolean }) => {
const resizeRequest: IResizeRequest = {
annotationId: annotationWrapper.id,
annotationId: annotation.id,
comment: result.comment,
positions: textAndPositions.positions,
value: text,
updateDictionary: result.updateDictionary,
};
this._processObsAndEmit(this._manualRedactionService.resizeOrSuggestResize([resizeRequest], data.dossier.id, fileId));
this._processObsAndEmit(this._manualRedactionService.resizeOrSuggestResize([resizeRequest], this._dossier.id, fileId));
});
}
@ -559,8 +558,6 @@ export class AnnotationActionsService {
words.push(...quadWords);
}
console.log(words.join(' '));
return {
text: words.join(' '),
positions: rectangles,

View File

@ -1,4 +1,4 @@
import { AnnotationWrapper } from '../../../models/file/annotation.wrapper';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { Injectable } from '@angular/core';
import { EntitiesService, FilterService, ListingService, SearchService } from '@iqser/common-ui';
import { filter, tap } from 'rxjs/operators';

View File

@ -1,7 +1,7 @@
import { ChangeType, File, IRedactionLog, IRedactionLogEntry, IViewedPage, ViewMode, ViewModes } from '@red/domain';
import { AnnotationWrapper } from '../../../models/file/annotation.wrapper';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { BehaviorSubject, firstValueFrom, iif, Observable, Subject } from 'rxjs';
import { RedactionLogEntry } from '../../../models/file/redaction-log.entry';
import { RedactionLogEntry } from '@models/file/redaction-log.entry';
import { Injectable, Injector } from '@angular/core';
import { FilePreviewStateService } from './file-preview-state.service';
import { ViewedPagesService } from '@services/files/viewed-pages.service';

View File

@ -3,7 +3,7 @@ import { GenericService, RequiredParam, Toaster, Validate } from '@iqser/common-
import { Highlight, TextHighlightOperation, TextHighlightResponse } from '@red/domain';
import { catchError, map, tap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { AnnotationWrapper } from '../../models/file/annotation.wrapper';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Injectable({

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1",
"API_URL": "https://dev-05.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -16,7 +16,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction",
"OAUTH_URL": "https://dev-05.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview"

View File

@ -1815,7 +1815,8 @@
"save": "Änderungen speichern"
},
"content": {
"comment": "Kommentar"
"comment": "Kommentar",
"update-dictionary": ""
},
"header": "Schwärzung ändern"
},

View File

@ -1815,7 +1815,8 @@
"save": "Save Changes"
},
"content": {
"comment": "Comment"
"comment": "Comment",
"update-dictionary": "Update dictionary: {text}"
},
"header": "Resize Redaction"
},

View File

@ -5,4 +5,5 @@ export interface IResizeRequest {
comment: string;
positions: IRectangle[];
value: string;
updateDictionary?: boolean;
}