From 74b4c1a11f85503b1308f6a8ee4f59ad5a50b73f Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Mon, 19 Aug 2024 10:19:53 +0300 Subject: [PATCH] reload entity log when file is assigned to current user --- .../user-management.component.html | 2 +- .../user-management.component.ts | 30 ++++++++++++++----- .../services/annotation-actions.service.ts | 2 +- .../file-actions/file-actions.component.ts | 19 +++++++----- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html b/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html index cdb189220..4b188f4c3 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html @@ -41,7 +41,7 @@ > [{ length: 1, color: this.state.file().workflowStatus }]); readonly assignTooltip = computed(() => { @@ -72,6 +74,13 @@ export class UserManagementComponent implements OnInit, OnDestroy { readonly ngZone: NgZone, ) {} + async assignToMe(file: File) { + await this.fileAssignService.assignToMe([file]); + //TODO: check which one to call + // await firstValueFrom(this.fileDataService.updateAnnotations(file, file.numberOfAnalyses)); + await this.fileDataService.loadEntityLog(); + } + async assignReviewer(file: File, user: User | string) { const assigneeId = typeof user === 'string' ? user : user?.id; @@ -85,6 +94,11 @@ export class UserManagementComponent implements OnInit, OnDestroy { await this.filesService.setUnderApproval(file, assigneeId); } + if (assigneeId === this._currentUserId) { + // await firstValueFrom(this.fileDataService.updateAnnotations(file, file.numberOfAnalyses)); + await this.fileDataService.loadEntityLog(); + } + this.loadingService.stop(); const translateParams = { reviewerName: this.userService.getName(assigneeId), filename: file.filename }; diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index 2568abb13..c45c0ffed 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -450,7 +450,7 @@ export class AnnotationActionsService { isHint, includeUnprocessed, ); - this.#processObsAndEmit(req$).then(() => this._fileDataService.removeAnnotations(redactions.map(r => r.id))); + this.#processObsAndEmit(req$).then(); } #getRemoveRedactionDialog(data: RemoveRedactionData) { diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts index 19a721f98..f53228d4f 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts @@ -1,7 +1,9 @@ -import { ChangeDetectorRef, Component, HostBinding, Injector, Input, OnChanges, Optional, ViewChild } from '@angular/core'; +import { NgIf, NgTemplateOutlet } from '@angular/common'; +import { ChangeDetectorRef, Component, HostBinding, inject, Injector, Input, OnChanges, Optional, ViewChild } from '@angular/core'; import { toObservable } from '@angular/core/rxjs-interop'; import { Router } from '@angular/router'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { StatusBarComponent } from '@common-ui/shared'; import { CircleButtonTypes, getConfig, @@ -21,6 +23,7 @@ import { FilesService } from '@services/files/files.service'; import { PermissionsService } from '@services/permissions.service'; import { ReanalysisService, ReanalyzeQueryParams } from '@services/reanalysis.service'; import { ExpandableFileActionsComponent } from '@shared/components/expandable-file-actions/expandable-file-actions.component'; +import { ProcessingIndicatorComponent } from '@shared/components/processing-indicator/processing-indicator.component'; import { LongPressDirective, LongPressEvent } from '@shared/directives/long-press.directive'; import { Roles } from '@users/roles'; import { UserPreferenceService } from '@users/user-preference.service'; @@ -28,14 +31,12 @@ import { setLocalStorageDataByFileId } from '@utils/local-storage'; import { firstValueFrom, Observable } from 'rxjs'; import { DocumentInfoService } from '../../../file-preview/services/document-info.service'; import { ExcludedPagesService } from '../../../file-preview/services/excluded-pages.service'; +import { FileDataService } from '../../../file-preview/services/file-data.service'; import { PageRotationService } from '../../../pdf-viewer/services/page-rotation.service'; import { ViewerHeaderService } from '../../../pdf-viewer/services/viewer-header.service'; import { AssignReviewerApproverDialogComponent } from '../../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component'; import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { FileAssignService } from '../../services/file-assign.service'; -import { ProcessingIndicatorComponent } from '@shared/components/processing-indicator/processing-indicator.component'; -import { StatusBarComponent } from '@common-ui/shared'; -import { NgIf, NgTemplateOutlet } from '@angular/common'; @Component({ selector: 'redaction-file-actions', @@ -45,6 +46,10 @@ import { NgIf, NgTemplateOutlet } from '@angular/common'; imports: [ProcessingIndicatorComponent, StatusBarComponent, LongPressDirective, ExpandableFileActionsComponent, NgTemplateOutlet, NgIf], }) export class FileActionsComponent implements OnChanges { + @ViewChild(ExpandableFileActionsComponent) + private readonly _expandableActionsComponent: ExpandableFileActionsComponent; + readonly #isDocumine = getConfig().IS_DOCUMINE; + readonly #fileDataService = inject(FileDataService, { optional: true }); @Input({ required: true }) file: File; @Input({ required: true }) dossier: Dossier; @Input({ required: true }) type: 'file-preview' | 'dossier-overview-list' | 'dossier-overview-workflow'; @@ -82,9 +87,6 @@ export class FileActionsComponent implements OnChanges { isDossierMember = false; tooltipPosition = IqserTooltipPositions.above; buttons: Action[]; - @ViewChild(ExpandableFileActionsComponent) - private readonly _expandableActionsComponent: ExpandableFileActionsComponent; - readonly #isDocumine = getConfig().IS_DOCUMINE; constructor( private readonly _injector: Injector, @@ -379,6 +381,9 @@ export class FileActionsComponent implements OnChanges { async #assignToMe() { await this._fileAssignService.assignToMe([this.file]); + // TODO: check which one to call + // await firstValueFrom(this.#fileDataService?.updateAnnotations(this.file, this.file.numberOfAnalyses)); + await this.#fileDataService?.loadEntityLog(); } async #reanalyseFile() {