accept multiple recommendations

This commit is contained in:
Dan Percic 2022-01-26 19:20:53 +02:00
parent a6ca95e7f0
commit 125a9a2cb0
5 changed files with 653 additions and 179 deletions

View File

@ -6,7 +6,7 @@ import { AnnotationActionsService } from '../../services/annotation-actions.serv
import { WebViewerInstance } from '@pdftron/webviewer';
import { UserService } from '@services/user.service';
import { Dossier, File } from '@red/domain';
import { Required } from '@iqser/common-ui';
import { defaultDialogConfig, Required } from '@iqser/common-ui';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { MatDialog } from '@angular/material/dialog';
import {
@ -103,20 +103,16 @@ export class AnnotationActionsComponent implements OnChanges {
}
acceptRecommendation($event: MouseEvent) {
if (this.annotations.length > 1) {
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.file, this.annotationsChanged);
}
const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>(
AcceptRecommendationDialogComponent,
{ autoFocus: true, data: { annotation: this.annotations[0], file: this.file } },
{ ...defaultDialogConfig, autoFocus: true, data: { annotations: this.annotations, file: this.file } },
);
const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotation));
dialogClosed.subscribe(({ annotation, comment: commentText }) => {
const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotations));
dialogClosed.subscribe(({ annotations, comment: commentText }) => {
const comment = commentText ? { text: commentText } : undefined;
this.annotationActionsService.convertRecommendationToAnnotation(
$event,
[annotation],
annotations,
this.file,
this.annotationsChanged,
comment,

View File

@ -4,9 +4,13 @@
<div class="dialog-content">
<div class="iqser-input-group">
<label translate="manual-annotation.dialog.content.text"></label>
<label *ngIf="data.annotations.length === 1" translate="manual-annotation.dialog.content.text"></label>
</div>
{{ format(data.annotation.value) }}
{{
data.annotations.length === 1
? format(data.annotations[0].value)
: ('accept-recommendation-dialog.multiple-values' | translate)
}}
<div class="iqser-input-group required w-400">
<label translate="manual-annotation.dialog.content.dictionary"></label>

View File

@ -11,12 +11,12 @@ import { ManualAnnotationService } from '../../../../services/manual-annotation.
import { AnnotationWrapper } from '../../../../../../models/file/annotation.wrapper';
export interface AcceptRecommendationData {
readonly annotation: AnnotationWrapper;
readonly annotations: AnnotationWrapper[];
readonly file: File;
}
export interface AcceptRecommendationReturnType {
readonly annotation: AnnotationWrapper;
readonly annotations: AnnotationWrapper[];
readonly comment: string;
}
@ -63,16 +63,15 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp
this._dossier.dossierId,
);
this.form.patchValue({
dictionary: this.possibleDictionaries.find(dict => dict.type === this.data.annotation.recommendationType).type,
dictionary: this.possibleDictionaries.find(dict => dict.type === this.data.annotations[0].recommendationType).type,
});
}
save() {
const recommendationType = this.form.get('dictionary').value;
const annotation = Object.assign({}, this.data.annotation);
annotation.recommendationType = recommendationType;
this.data.annotations.forEach(a => (a.recommendationType = recommendationType));
this._dialogRef.close({
annotation,
annotations: this.data.annotations,
comment: this.form.get('comment').value as string,
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1332,6 +1332,10 @@
}
}
},
"accept-recommendation-dialog": {
"header": "Accept recommendation",
"multiple-values": "Multiple recommendations selected"
},
"months": {
"apr": "Apr.",
"aug": "Aug.",