diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.ts index e95cd0367..b147cfcec 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.ts @@ -5,13 +5,10 @@ import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { AnnotationActionsService } from '../../services/annotation-actions.service'; import { WebViewerInstance } from '@pdftron/webviewer'; import { UserService } from '@services/user.service'; -import { Dossier, File } from '@red/domain'; -import { Required } from '@iqser/common-ui'; -import { DossiersService } from '@services/entity-services/dossiers.service'; -import { MatDialog } from '@angular/material/dialog'; -import { ManualAnnotationService } from '../../../../services/manual-annotation.service'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { MultiSelectService } from '../../services/multi-select.service'; +import { FilePreviewStateService } from '../../services/file-preview-state.service'; +import { firstValueFrom } from 'rxjs'; export const AnnotationButtonTypes = { dark: 'dark', @@ -31,19 +28,16 @@ export class AnnotationActionsComponent implements OnChanges { @Input() canPerformAnnotationActions: boolean; @Input() viewer: WebViewerInstance; @Input() alwaysVisible: boolean; - @Input() @Required() file!: File; - @Output() annotationsChanged = new EventEmitter(); + @Output() readonly annotationsChanged = new EventEmitter(); annotationPermissions: AnnotationPermissions; constructor( - private readonly _manualAnnotationService: ManualAnnotationService, - readonly annotationActionsService: AnnotationActionsService, - readonly annotationReferencesService: AnnotationReferencesService, + private readonly _userService: UserService, readonly multiSelectService: MultiSelectService, private readonly _permissionsService: PermissionsService, - private readonly _dossiersService: DossiersService, - private readonly _userService: UserService, - private readonly _dialog: MatDialog, + readonly annotationActionsService: AnnotationActionsService, + private readonly _screenStateService: FilePreviewStateService, + readonly annotationReferencesService: AnnotationReferencesService, ) {} private _annotations: AnnotationWrapper[]; @@ -77,12 +71,8 @@ export class AnnotationActionsComponent implements OnChanges { return this.annotations?.length === 1 && this.annotations?.[0].resizing; } - private get _dossier(): Dossier { - return this._dossiersService.find(this.file.dossierId); - } - - ngOnChanges(): void { - this._setPermissions(); + async ngOnChanges(): Promise { + await this._setPermissions(); } removeOrSuggestRemoveAnnotation($event: MouseEvent, removeFromDict: boolean) { @@ -124,9 +114,10 @@ export class AnnotationActionsComponent implements OnChanges { this.annotationActionsService.cancelResize($event, this.viewer, this.annotations[0], this.annotationsChanged); } - private _setPermissions() { + private async _setPermissions() { + const dossier = await firstValueFrom(this._screenStateService.dossier$); this.annotationPermissions = AnnotationPermissions.forUser( - this._permissionsService.isApprover(this._dossier), + this._permissionsService.isApprover(dossier), this._userService.currentUser, this.annotations, ); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html index 71c41366d..4375d14c1 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html @@ -54,7 +54,6 @@ [alwaysVisible]="true" [annotations]="selectedAnnotations" [canPerformAnnotationActions]="!isReadOnly" - [file]="file" [viewer]="viewer" buttonType="primary" tooltipPosition="above" diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index 6e5a51511..aaf57ede5 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -115,7 +115,6 @@ (annotationsChanged)="annotationsChangedByReviewAction($event)" [annotations]="[annotation]" [canPerformAnnotationActions]="canPerformAnnotationActions$ | async" - [file]="file" [viewer]="activeViewer" >