RED-6082: hide file actions when file not processed
This commit is contained in:
parent
2bff5039e8
commit
854c580908
@ -1,15 +1,4 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
HostBinding,
|
||||
Injector,
|
||||
Input,
|
||||
OnChanges,
|
||||
Optional,
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, HostBinding, Injector, Input, OnChanges, Optional, SimpleChanges, ViewChild } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses, User } from '@red/domain';
|
||||
import { DossiersDialogService } from '../../services/dossiers-dialog.service';
|
||||
@ -17,13 +6,16 @@ import {
|
||||
CircleButtonType,
|
||||
CircleButtonTypes,
|
||||
ConfirmationDialogInput,
|
||||
getCurrentUser,
|
||||
IqserPermissionsService,
|
||||
IqserTooltipPosition,
|
||||
LoadingService,
|
||||
OverlappingElements,
|
||||
ScrollableParentView,
|
||||
ScrollableParentViews,
|
||||
Toaster,
|
||||
} from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@users/user.service';
|
||||
import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
@ -40,17 +32,15 @@ import { FileAssignService } from '../../services/file-assign.service';
|
||||
import { ViewerHeaderService } from '../../../pdf-viewer/services/viewer-header.service';
|
||||
import { ROTATION_ACTION_BUTTONS } from '../../../pdf-viewer/utils/constants';
|
||||
import { ROLES } from '@users/roles';
|
||||
import { OverlappingElements, ScrollableParentView, ScrollableParentViews } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-file-actions [file] [type] [dossier]',
|
||||
templateUrl: './file-actions.component.html',
|
||||
styleUrls: ['./file-actions.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class FileActionsComponent implements OnChanges {
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly currentUser: User;
|
||||
readonly currentUser = getCurrentUser<User>();
|
||||
|
||||
@Input() file: File;
|
||||
@Input() dossier: Dossier;
|
||||
@ -94,7 +84,6 @@ export class FileActionsComponent implements OnChanges {
|
||||
private readonly _expandableActionsComponent: ExpandableFileActionsComponent;
|
||||
|
||||
constructor(
|
||||
userService: UserService,
|
||||
private readonly _injector: Injector,
|
||||
private readonly _filesService: FilesService,
|
||||
private readonly _changeRef: ChangeDetectorRef,
|
||||
@ -104,22 +93,22 @@ export class FileActionsComponent implements OnChanges {
|
||||
private readonly _reanalysisService: ReanalysisService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _iqserPermissionsService: IqserPermissionsService,
|
||||
private readonly _pageRotationService: PageRotationService,
|
||||
private readonly _viewerHeaderService: ViewerHeaderService,
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
@Optional() private readonly _documentInfoService: DocumentInfoService,
|
||||
@Optional() private readonly _excludedPagesService: ExcludedPagesService,
|
||||
) {
|
||||
this.currentUser = userService.currentUser;
|
||||
}
|
||||
) {}
|
||||
|
||||
@HostBinding('class.keep-visible')
|
||||
get expanded() {
|
||||
return !!this._expandableActionsComponent?.expanded;
|
||||
}
|
||||
|
||||
get overlappingElements() {
|
||||
return this.fileActionsHelpModeKey === 'editor_document_features' ? [OverlappingElements.USER_MENU] : [];
|
||||
}
|
||||
|
||||
private get _toggleTooltip(): string {
|
||||
if (!this.canToggleAnalysis) {
|
||||
return _('file-preview.toggle-analysis.only-managers');
|
||||
@ -164,7 +153,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
files: [this.file],
|
||||
dossier: this.dossier,
|
||||
tooltipClass: 'small',
|
||||
show: this._permissionsService.canDownloadRedactedFile(),
|
||||
show: this._permissionsService.canDownloadRedactedFile() && !!this.file.lastProcessed,
|
||||
disabled: this.file.processingStatus === ProcessingFileStatuses.ERROR,
|
||||
},
|
||||
{
|
||||
@ -184,7 +173,6 @@ export class FileActionsComponent implements OnChanges {
|
||||
icon: 'red:exclude-pages',
|
||||
show:
|
||||
!!this._excludedPagesService &&
|
||||
!this.file.excluded &&
|
||||
this._permissionsService.canExcludePages(this.file, this.dossier) &&
|
||||
!this._iqserPermissionsService.has(ROLES.getRss),
|
||||
},
|
||||
@ -423,6 +411,13 @@ export class FileActionsComponent implements OnChanges {
|
||||
|
||||
this.assignTooltip = this.file.isUnderApproval ? _('dossier-overview.assign-approver') : _('dossier-overview.assign-reviewer');
|
||||
this.buttonType = this.isFilePreview ? CircleButtonTypes.default : CircleButtonTypes.dark;
|
||||
this.showAssign =
|
||||
(this._permissionsService.canAssignUser(this.file, this.dossier) ||
|
||||
this._permissionsService.canUnassignUser(this.file, this.dossier)) &&
|
||||
this.isDossierOverview;
|
||||
|
||||
this.showAssignToSelf = this._permissionsService.canAssignToSelf(this.file, this.dossier) && this.isDossierOverview;
|
||||
this.showImportRedactions = this._permissionsService.canImportRedactions(this.file, this.dossier);
|
||||
|
||||
this.showSetToNew = this._permissionsService.canSetToNew(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
this.showUndoApproval = this._permissionsService.canUndoApproval(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
@ -431,7 +426,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
this.showApprove = this._permissionsService.isReadyForApproval(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
|
||||
this.canToggleAnalysis = this._permissionsService.canToggleAnalysis(this.file, this.dossier);
|
||||
this.showToggleAnalysis = this._permissionsService.showToggleAnalysis(this.dossier);
|
||||
this.showToggleAnalysis = !!this.file.lastProcessed && this._permissionsService.showToggleAnalysis(this.dossier);
|
||||
this.toggleTooltip = this._toggleTooltip;
|
||||
|
||||
this.showDelete = this._permissionsService.canSoftDeleteFile(this.file, this.dossier);
|
||||
@ -442,14 +437,6 @@ export class FileActionsComponent implements OnChanges {
|
||||
|
||||
this.showStatusBar = !this.file.isError && !this.file.isUnprocessed && this.isDossierOverviewList;
|
||||
|
||||
this.showAssignToSelf = this._permissionsService.canAssignToSelf(this.file, this.dossier) && this.isDossierOverview;
|
||||
this.showAssign =
|
||||
(this._permissionsService.canAssignUser(this.file, this.dossier) ||
|
||||
this._permissionsService.canUnassignUser(this.file, this.dossier)) &&
|
||||
this.isDossierOverview;
|
||||
|
||||
this.showImportRedactions = this._permissionsService.canImportRedactions(this.file, this.dossier);
|
||||
|
||||
const showReanalyse = this.canReanalyse || this.file.excludedFromAutomaticAnalysis || this.analysisForced;
|
||||
|
||||
this.showReanalyseFilePreview = showReanalyse && this.isFilePreview && !this.file.isApproved;
|
||||
@ -472,8 +459,4 @@ export class FileActionsComponent implements OnChanges {
|
||||
await firstValueFrom(this._filesService.setToNewFor([this.file], this.file.dossierId));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
get overlappingElements() {
|
||||
return this.fileActionsHelpModeKey === 'editor_document_features' ? [OverlappingElements.USER_MENU] : [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,6 +237,7 @@ export class PermissionsService {
|
||||
!file.isError &&
|
||||
!file.isFullProcessing &&
|
||||
!file.excluded &&
|
||||
!!file.lastProcessed &&
|
||||
(file.isUnderReview || file.isUnderApproval) &&
|
||||
this.isFileAssignee(file)
|
||||
);
|
||||
@ -340,7 +341,11 @@ export class PermissionsService {
|
||||
|
||||
canImportRedactions(file: File, dossier: Dossier) {
|
||||
return (
|
||||
this._iqserPermissionsService.has(ROLES.redactions.write) && dossier.isActive && this.isFileAssignee(file) && !file.isApproved
|
||||
this._iqserPermissionsService.has(ROLES.redactions.write) &&
|
||||
dossier.isActive &&
|
||||
this.isFileAssignee(file) &&
|
||||
!file.isApproved &&
|
||||
!!file.lastProcessed
|
||||
);
|
||||
}
|
||||
|
||||
@ -357,11 +362,21 @@ export class PermissionsService {
|
||||
}
|
||||
|
||||
private _canOcrFile(file: File, dossier: Dossier): boolean {
|
||||
return dossier.isActive && file.canBeOCRed && ((this.isDossierMember(dossier) && !file.assignee) || this.isFileAssignee(file));
|
||||
return (
|
||||
dossier.isActive &&
|
||||
!!file.lastProcessed &&
|
||||
file.canBeOCRed &&
|
||||
((this.isDossierMember(dossier) && !file.assignee) || this.isFileAssignee(file))
|
||||
);
|
||||
}
|
||||
|
||||
private _canToggleAnalysis(file: File, dossier: Dossier): boolean {
|
||||
return dossier.isActive && this.isFileAssignee(file) && (file.isNew || file.isUnderReview || file.isUnderApproval);
|
||||
return (
|
||||
dossier.isActive &&
|
||||
!!file.lastProcessed &&
|
||||
this.isFileAssignee(file) &&
|
||||
(file.isNew || file.isUnderReview || file.isUnderApproval)
|
||||
);
|
||||
}
|
||||
|
||||
private _canSoftDeleteFile(file: File, dossier: Dossier): boolean {
|
||||
@ -381,11 +396,15 @@ export class PermissionsService {
|
||||
}
|
||||
|
||||
private _canEnableAutoAnalysis(file: File, dossier: Dossier): boolean {
|
||||
return dossier.isActive && file.excludedFromAutomaticAnalysis && this.isFileAssignee(file) && !file.isApproved;
|
||||
return (
|
||||
dossier.isActive && !!file.lastProcessed && file.excludedFromAutomaticAnalysis && this.isFileAssignee(file) && !file.isApproved
|
||||
);
|
||||
}
|
||||
|
||||
private _canDisableAutoAnalysis(file: File, dossier: Dossier): boolean {
|
||||
return dossier.isActive && !file.excludedFromAutomaticAnalysis && this.isFileAssignee(file) && !file.isApproved;
|
||||
return (
|
||||
dossier.isActive && !file.excludedFromAutomaticAnalysis && this.isFileAssignee(file) && !file.isApproved && !!file.lastProcessed
|
||||
);
|
||||
}
|
||||
|
||||
/** UNDER_REVIEW => NEW */
|
||||
@ -422,7 +441,7 @@ export class PermissionsService {
|
||||
}
|
||||
|
||||
private _assignmentPrecondition(file: File, dossier: Dossier): boolean {
|
||||
return dossier.isActive && !file.isError && !file.isProcessing;
|
||||
return dossier.isActive && !file.isError && !file.isProcessing && !!file.lastProcessed;
|
||||
}
|
||||
|
||||
private _canAssignToSelf(file: File, dossier: Dossier): boolean {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit a6d59a82b9bade66f0e49bbaaa8e9cc7e8f626a8
|
||||
Subproject commit c217b5f07f57a9a3fb37bb795b5b52066788a790
|
||||
Loading…
x
Reference in New Issue
Block a user