remove file from annotation actions

This commit is contained in:
Dan Percic 2022-02-01 12:50:58 +02:00
parent 60acd1abc1
commit 2a58fb7b8c
3 changed files with 12 additions and 23 deletions

View File

@ -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<AnnotationWrapper>();
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper>();
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<void> {
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,
);

View File

@ -54,7 +54,6 @@
[alwaysVisible]="true"
[annotations]="selectedAnnotations"
[canPerformAnnotationActions]="!isReadOnly"
[file]="file"
[viewer]="viewer"
buttonType="primary"
tooltipPosition="above"

View File

@ -115,7 +115,6 @@
(annotationsChanged)="annotationsChangedByReviewAction($event)"
[annotations]="[annotation]"
[canPerformAnnotationActions]="canPerformAnnotationActions$ | async"
[file]="file"
[viewer]="activeViewer"
></redaction-annotation-actions>
</ng-template>