added directive to determine long press of 'command' or 'ctrl' keys to can force the reanalysis of documents

This commit is contained in:
Valentin 2021-09-22 00:31:50 +03:00
parent c26fae8ef1
commit 8b5b78b775
4 changed files with 46 additions and 5 deletions

View File

@ -7,7 +7,7 @@
<ng-container *ngTemplateOutlet="actions"></ng-container>
</ng-container>
<ng-template #actions>
<ng-template #actions redactionLongPress (longPress)="forceReanalysisAction()">
<div class="file-actions" *ngIf="fileStatus">
<iqser-circle-button
(action)="openDeleteFileDialog($event)"
@ -136,7 +136,6 @@
icon="iqser:refresh"
[type]="circleButtonTypes.dark"
></iqser-circle-button>
<!-- exclude from redaction -->
<div class="iqser-input-group">
<mat-slide-toggle

View File

@ -10,6 +10,7 @@ import { FileManagementControllerService, FileStatus } from '@redaction/red-ui-h
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { filter } from 'rxjs/operators';
import { UserPreferenceService } from '../../../../services/user-preference.service';
@Component({
selector: 'redaction-file-actions',
@ -43,6 +44,8 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
readyForApproval: boolean;
canToggleAnalysis: boolean;
private _reanalysisHasBeenForced = false;
constructor(
readonly permissionsService: PermissionsService,
readonly appStateService: AppStateService,
@ -51,7 +54,8 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
private readonly _loadingService: LoadingService,
private readonly _fileManagementControllerService: FileManagementControllerService,
private readonly _userService: UserService,
private readonly _toaster: Toaster
private readonly _toaster: Toaster,
private readonly _userPreferenceService: UserPreferenceService
) {
super();
}
@ -194,6 +198,13 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
}
}
forceReanalysisAction() {
if (this._userPreferenceService.areDevFeaturesEnabled) {
this.canReanalyse = true;
this._reanalysisHasBeenForced = true;
}
}
private _setup() {
this.statusBarConfig = [{ color: this.fileStatus.status, length: 1 }];
this.tooltipPosition = this.screen === 'file-preview' ? 'below' : 'above';
@ -208,7 +219,9 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
this.canAssignToSelf = this.permissionsService.canAssignToSelf(this.fileStatus);
this.canAssign = this.permissionsService.canAssignUser(this.fileStatus);
this.canDelete = this.permissionsService.canDeleteFile(this.fileStatus);
this.canReanalyse = this.permissionsService.canReanalyseFile(this.fileStatus);
if (!this._reanalysisHasBeenForced) {
this.canReanalyse = this.permissionsService.canReanalyseFile(this.fileStatus);
}
this.canSetToUnderReview = this.permissionsService.canSetUnderReview(this.fileStatus);
this.canSetToUnderApproval = this.permissionsService.canSetUnderApproval(this.fileStatus);
this.readyForApproval = this.permissionsService.isReadyForApproval(this.fileStatus);

View File

@ -0,0 +1,28 @@
import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
const LONG_PRESS_TIMEOUT = 500;
@Directive({
selector: '[redactionLongPress]'
})
export class LongPressDirective {
private _touchTimeout: any;
@Output() longPress = new EventEmitter();
constructor() {}
@HostListener('window:keydown.control')
@HostListener('window:keydown.meta')
touchStart() {
this._touchTimeout = setTimeout(() => {
this.longPress.emit({});
}, LONG_PRESS_TIMEOUT);
}
@HostListener('window:keyup.control')
@HostListener('window:keyup.meta')
touchEnd() {
clearTimeout(this._touchTimeout);
}
}

View File

@ -24,6 +24,7 @@ import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { AssignUserDropdownComponent } from './components/assign-user-dropdown/assign-user-dropdown.component';
import { PageHeaderComponent } from './components/page-header/page-header.component';
import { DatePipe } from '@shared/pipes/date.pipe';
import { LongPressDirective } from '@shared/directives/long-press.directive';
const buttons = [FileDownloadBtnComponent, UserButtonComponent];
@ -44,7 +45,7 @@ const components = [
...buttons
];
const utils = [DatePipe, NavigateLastDossiersScreenDirective];
const utils = [DatePipe, NavigateLastDossiersScreenDirective, LongPressDirective];
const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, CommonUiModule];