fix show accept recommendation dialog
This commit is contained in:
parent
f1da4661e4
commit
0f60660c95
@ -6,15 +6,9 @@ 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 { defaultDialogConfig, Required } from '@iqser/common-ui';
|
||||
import { Required } from '@iqser/common-ui';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {
|
||||
AcceptRecommendationData,
|
||||
AcceptRecommendationDialogComponent,
|
||||
AcceptRecommendationReturnType,
|
||||
} from '../../dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { ManualAnnotationService } from '../../../../services/manual-annotation.service';
|
||||
import { AnnotationReferencesService } from '../../services/annotation-references.service';
|
||||
import { MultiSelectService } from '../../services/multi-select.service';
|
||||
@ -107,21 +101,7 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
acceptRecommendation($event: MouseEvent) {
|
||||
const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>(
|
||||
AcceptRecommendationDialogComponent,
|
||||
{ ...defaultDialogConfig, autoFocus: true, data: { annotations: this.annotations, file: this.file } },
|
||||
);
|
||||
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,
|
||||
annotations,
|
||||
this.file,
|
||||
this.annotationsChanged,
|
||||
comment,
|
||||
);
|
||||
});
|
||||
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.file, this.annotationsChanged);
|
||||
}
|
||||
|
||||
hideAnnotation($event: MouseEvent) {
|
||||
|
||||
@ -15,6 +15,14 @@ import { toPosition } from '../../../utils/pdf-calculation.utils';
|
||||
import { AnnotationDrawService } from './annotation-draw.service';
|
||||
import { translateQuads } from '@utils/pdf-coordinates';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import {
|
||||
AcceptRecommendationData,
|
||||
AcceptRecommendationDialogComponent,
|
||||
AcceptRecommendationReturnType,
|
||||
} from '../dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
|
||||
import { defaultDialogConfig } from '@iqser/common-ui';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
@Injectable()
|
||||
@ -27,6 +35,7 @@ export class AnnotationActionsService {
|
||||
private readonly _manualAnnotationService: ManualAnnotationService,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _dialog: MatDialog,
|
||||
private readonly _annotationDrawService: AnnotationDrawService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
) {}
|
||||
@ -181,19 +190,26 @@ export class AnnotationActionsService {
|
||||
|
||||
convertRecommendationToAnnotation(
|
||||
$event: any,
|
||||
annotations: AnnotationWrapper[],
|
||||
recommendations: AnnotationWrapper[],
|
||||
file: File,
|
||||
annotationsChanged: EventEmitter<AnnotationWrapper>,
|
||||
comment?: { text: string },
|
||||
) {
|
||||
$event?.stopPropagation();
|
||||
|
||||
annotations.forEach(annotation => {
|
||||
this._processObsAndEmit(
|
||||
this._manualAnnotationService.addRecommendation(annotation, file, comment),
|
||||
annotation,
|
||||
annotationsChanged,
|
||||
);
|
||||
const dialogRef = this._dialog.open<AcceptRecommendationDialogComponent, AcceptRecommendationData, AcceptRecommendationReturnType>(
|
||||
AcceptRecommendationDialogComponent,
|
||||
{ ...defaultDialogConfig, autoFocus: true, data: { annotations: recommendations, file } },
|
||||
);
|
||||
const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotations));
|
||||
dialogClosed.subscribe(({ annotations, comment: commentText }) => {
|
||||
const comment = commentText ? { text: commentText } : undefined;
|
||||
annotations.forEach(annotation => {
|
||||
this._processObsAndEmit(
|
||||
this._manualAnnotationService.addRecommendation(annotation, file, comment),
|
||||
annotation,
|
||||
annotationsChanged,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import { annotationActionsTranslations } from '../translations/annotation-action
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class ManualAnnotationService extends GenericService<IManualAddResponse> {
|
||||
@ -54,7 +55,13 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
|
||||
};
|
||||
}
|
||||
|
||||
_makeRequest(mode: AnnotationActionMode, file: File, body: any, secondParam: any = null, modifyDictionary = false) {
|
||||
_makeRequest(
|
||||
mode: AnnotationActionMode,
|
||||
file: File,
|
||||
body: any,
|
||||
secondParam: any = null,
|
||||
modifyDictionary = false,
|
||||
): Observable<unknown> {
|
||||
const obs = !secondParam
|
||||
? this[this.CONFIG[mode]](body, file.dossierId, file.id)
|
||||
: this[this.CONFIG[mode]](body, secondParam, file.dossierId, file.id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user