Pull request #287: VM/ForceReanalyseAction

Merge in RED/ui from VM/ForceReanalyseAction to master

* commit '6b802a769ea14a74f13aa8faf1e7857be4c650eb':
  updated logic to force the reanalysis only while the 'command' or 'ctrl' keys are pressed
  added directive to determine long press of 'command' or 'ctrl' keys to can force the reanalysis of documents
This commit is contained in:
Valentin-Gabriel Mihai 2021-09-23 11:39:23 +02:00 committed by Timo Bejan
commit 332b71c7de
4 changed files with 46 additions and 4 deletions

View File

@ -7,7 +7,7 @@
<ng-container *ngTemplateOutlet="actions"></ng-container>
</ng-container>
<ng-template #actions>
<ng-template #actions redactionLongPress (longPress)="forceReanalysisAction($event)">
<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,8 @@ 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';
import { LongPressEvent } from '../../../shared/directives/long-press.directive';
@Component({
selector: 'redaction-file-actions',
@ -51,7 +53,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();
}
@ -206,6 +209,12 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
}
}
forceReanalysisAction($event: LongPressEvent) {
if (this._userPreferenceService.areDevFeaturesEnabled) {
this.canReanalyse = $event.touchEnd ? this.permissionsService.canReanalyseFile(this.fileStatus) : true;
}
}
private _setFileApproved() {
this.addSubscription = this._fileActionService.setFileApproved(this.fileStatus).subscribe(() => {
this.reloadDossiers('set-approved');

View File

@ -0,0 +1,33 @@
import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
const LONG_PRESS_TIMEOUT = 500;
export interface LongPressEvent {
touchEnd?: boolean;
}
@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);
this.longPress.emit({ touchEnd: true });
}
}

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];