Merge branch 'RED-8183' into 'master'

Resolve RED-8183

Closes RED-8183

See merge request redactmanager/red-ui!301
This commit is contained in:
Dan Percic 2024-02-13 11:48:29 +01:00
commit 5be95976d6

View File

@ -1,4 +1,4 @@
import { Component, computed, HostListener } from '@angular/core';
import { Component, computed, HostListener, NgZone, OnDestroy, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { LoadingService, Toaster } from '@iqser/common-ui';
import { getCurrentUser } from '@iqser/common-ui/lib/users';
@ -10,13 +10,15 @@ import { UserService } from '@users/user.service';
import { moveElementInArray } from '@utils/functions';
import { FileAssignService } from '../../../shared-dossiers/services/file-assign.service';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { PdfViewer } from '../../../pdf-viewer/services/pdf-viewer.service';
import { Bind } from '@common-ui/utils';
@Component({
selector: 'redaction-user-management',
templateUrl: './user-management.component.html',
styleUrls: ['./user-management.component.scss'],
})
export class UserManagementComponent {
export class UserManagementComponent implements OnInit, OnDestroy {
protected readonly _canAssignToSelf = computed(() => this.permissionsService.canAssignToSelf(this.state.file(), this.state.dossier()));
protected readonly _canAssignUser = computed(() => this.permissionsService.canAssignUser(this.state.file(), this.state.dossier()));
protected readonly _canUnassignUser = computed(() => this.permissionsService.canUnassignUser(this.state.file(), this.state.dossier()));
@ -53,6 +55,8 @@ export class UserManagementComponent {
readonly toaster: Toaster,
readonly loadingService: LoadingService,
readonly state: FilePreviewStateService,
readonly pdf: PdfViewer,
readonly ngZone: NgZone,
) {}
async assignReviewer(file: File, user: User | string) {
@ -75,13 +79,35 @@ export class UserManagementComponent {
this.editingReviewer = false;
}
@HostListener('document:click', ['$event'])
clickOutside($event: MouseEvent) {
ngOnInit() {
this.pdf.instance.UI.iframeWindow.document.addEventListener('click', this.handleViewerClick);
}
ngOnDestroy() {
this.pdf.instance.UI.iframeWindow.document.removeEventListener('click', this.handleViewerClick);
}
@Bind()
handleViewerClick() {
this.ngZone.run(() => {
this.editingReviewer = false;
});
}
@HostListener('document:click')
clickOutside() {
if (this.editingReviewer) {
this.editingReviewer = false;
}
}
@HostListener('document:keyup', ['$event'])
handleEsc($event: KeyboardEvent) {
if ($event.key === 'Escape' && this.editingReviewer) {
this.editingReviewer = false;
}
}
#customSort(ids: string[]) {
let sorted = [...ids].sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
sorted = moveElementInArray(sorted, this._currentUserId, 0);