updated logic to force the reanalysis only while the 'command' or 'ctrl' keys are pressed

This commit is contained in:
Valentin 2021-09-22 21:35:58 +03:00
parent 8b5b78b775
commit ef03714b3e
3 changed files with 10 additions and 9 deletions

View File

@ -7,7 +7,7 @@
<ng-container *ngTemplateOutlet="actions"></ng-container>
</ng-container>
<ng-template #actions redactionLongPress (longPress)="forceReanalysisAction()">
<ng-template #actions redactionLongPress (longPress)="forceReanalysisAction($event)">
<div class="file-actions" *ngIf="fileStatus">
<iqser-circle-button
(action)="openDeleteFileDialog($event)"

View File

@ -11,6 +11,7 @@ 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';
import { LongPressEvent } from '../../../shared/directives/long-press.directive';
@Component({
selector: 'redaction-file-actions',
@ -44,8 +45,6 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
readyForApproval: boolean;
canToggleAnalysis: boolean;
private _reanalysisHasBeenForced = false;
constructor(
readonly permissionsService: PermissionsService,
readonly appStateService: AppStateService,
@ -198,10 +197,9 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
}
}
forceReanalysisAction() {
forceReanalysisAction($event: LongPressEvent) {
if (this._userPreferenceService.areDevFeaturesEnabled) {
this.canReanalyse = true;
this._reanalysisHasBeenForced = true;
this.canReanalyse = $event.touchEnd ? this.permissionsService.canReanalyseFile(this.fileStatus) : true;
}
}
@ -219,9 +217,7 @@ 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);
if (!this._reanalysisHasBeenForced) {
this.canReanalyse = this.permissionsService.canReanalyseFile(this.fileStatus);
}
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

@ -2,6 +2,10 @@ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
const LONG_PRESS_TIMEOUT = 500;
export interface LongPressEvent {
touchEnd?: boolean;
}
@Directive({
selector: '[redactionLongPress]'
})
@ -24,5 +28,6 @@ export class LongPressDirective {
@HostListener('window:keyup.meta')
touchEnd() {
clearTimeout(this._touchTimeout);
this.longPress.emit({ touchEnd: true });
}
}