RED-10363: check for rules on analysis btn click; refactor to signals.
This commit is contained in:
parent
9bea3c487a
commit
b00ff1186d
@ -1,8 +1,8 @@
|
||||
<ng-container (longPress)="forceReanalysisAction($event)" *ngIf="selectedFiles.length" redactionLongPress>
|
||||
<ng-container (longPress)="forceReanalysisAction($event)" *ngIf="selectedFiles().length" redactionLongPress>
|
||||
<redaction-expandable-file-actions
|
||||
[actions]="buttons"
|
||||
[buttonType]="buttonType"
|
||||
[maxWidth]="maxWidth"
|
||||
[actions]="buttons()"
|
||||
[buttonType]="buttonType()"
|
||||
[maxWidth]="maxWidth()"
|
||||
[tooltipPosition]="IqserTooltipPositions.above"
|
||||
>
|
||||
</redaction-expandable-file-actions>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, computed, Input, OnChanges } from '@angular/core';
|
||||
import { Component, computed, input, signal } from '@angular/core';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { CircleButtonType, CircleButtonTypes } from '@iqser/common-ui';
|
||||
import { CircleButtonType, CircleButtonTypes, Toaster } from '@iqser/common-ui';
|
||||
import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses } from '@red/domain';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { LongPressDirective, LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
@ -10,6 +10,7 @@ import { ExpandableFileActionsComponent } from '@shared/components/expandable-fi
|
||||
import { IqserTooltipPositions } from '@common-ui/utils';
|
||||
import { NgIf } from '@angular/common';
|
||||
import { RulesService } from '../../../admin/services/rules.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-overview-bulk-actions [dossier] [selectedFiles]',
|
||||
@ -18,221 +19,194 @@ import { RulesService } from '../../../admin/services/rules.service';
|
||||
standalone: true,
|
||||
imports: [LongPressDirective, ExpandableFileActionsComponent, NgIf],
|
||||
})
|
||||
export class DossierOverviewBulkActionsComponent implements OnChanges {
|
||||
#analysisForced: boolean;
|
||||
#canAssignToSelf: boolean;
|
||||
#canAssign: boolean;
|
||||
#canDelete: boolean;
|
||||
#canReanalyse: boolean;
|
||||
#canDisableAutoAnalysis: boolean;
|
||||
#canEnableAutoAnalysis: boolean;
|
||||
#canOcr: boolean;
|
||||
#canSetToNew: boolean;
|
||||
#canSetToUnderReview: boolean;
|
||||
#canSetToUnderApproval: boolean;
|
||||
#isReadyForApproval: boolean;
|
||||
#canApprove: boolean;
|
||||
#canUndoApproval: boolean;
|
||||
#canToggleAnalysis: boolean;
|
||||
#assignTooltip: string;
|
||||
#toggleAnalysisTooltip: string;
|
||||
#allFilesAreExcluded: boolean;
|
||||
#canMoveToSameState: boolean;
|
||||
@Input() dossier: Dossier;
|
||||
@Input() selectedFiles: File[];
|
||||
@Input() buttonType: CircleButtonType = CircleButtonTypes.default;
|
||||
@Input() maxWidth: number;
|
||||
buttons: Action[];
|
||||
export class DossierOverviewBulkActionsComponent {
|
||||
readonly dossier = input<Dossier>();
|
||||
readonly selectedFiles = input<File[]>();
|
||||
readonly buttonType = input<CircleButtonType>(CircleButtonTypes.default);
|
||||
readonly maxWidth = input<number>();
|
||||
readonly buttons = computed(() => this.#buttons);
|
||||
readonly IqserTooltipPositions = IqserTooltipPositions;
|
||||
readonly areRulesLocked = computed(() => this._rulesService.currentTemplateRules().timeoutDetected);
|
||||
readonly #areRulesLocked = computed(() => this._rulesService.currentTemplateRules().timeoutDetected);
|
||||
readonly #allFilesAreUnderReviewOrUnassigned = computed(() =>
|
||||
this.selectedFiles().reduce((acc, file) => acc && (file.isUnderReview || file.isNew), true),
|
||||
);
|
||||
readonly #allFilesAreUnderApproval = computed(() => this.selectedFiles().reduce((acc, file) => acc && file.isUnderApproval, true));
|
||||
readonly #allFilesAreExcluded = computed(() => this.selectedFiles().reduce((acc, file) => acc && file.excluded, true));
|
||||
readonly #allFilesAreApproved = computed(() => this.selectedFiles().reduce((acc, file) => acc && file.isApproved, true));
|
||||
readonly #canMoveToSameState = computed(
|
||||
() => this.#allFilesAreUnderReviewOrUnassigned() || this.#allFilesAreUnderApproval() || this.#allFilesAreApproved(),
|
||||
);
|
||||
readonly #canAssign = computed(
|
||||
() =>
|
||||
this.#canMoveToSameState() &&
|
||||
(this._permissionsService.canAssignUser(this.selectedFiles(), this.dossier()) ||
|
||||
this._permissionsService.canUnassignUser(this.selectedFiles(), this.dossier())),
|
||||
);
|
||||
readonly #canAssignToSelf = computed(
|
||||
() => this.#canMoveToSameState() && this._permissionsService.canAssignToSelf(this.selectedFiles(), this.dossier()),
|
||||
);
|
||||
readonly #canDelete = computed(() => this._permissionsService.canSoftDeleteFile(this.selectedFiles(), this.dossier()));
|
||||
readonly #canReanalyse = computed(() => this._permissionsService.canReanalyseFile(this.selectedFiles(), this.dossier()));
|
||||
readonly #canDisableAutoAnalysis = computed(() =>
|
||||
this._permissionsService.canDisableAutoAnalysis(this.selectedFiles(), this.dossier()),
|
||||
);
|
||||
readonly #canEnableAutoAnalysis = computed(() => this._permissionsService.canEnableAutoAnalysis(this.selectedFiles(), this.dossier()));
|
||||
readonly #canToggleAnalysis = computed(() => this._permissionsService.canToggleAnalysis(this.selectedFiles(), this.dossier()));
|
||||
readonly #canOcr = computed(() => this._permissionsService.canOcrFile(this.selectedFiles(), this.dossier()));
|
||||
readonly #canSetToNew = computed(() => this._permissionsService.canSetToNew(this.selectedFiles(), this.dossier()));
|
||||
readonly #canSetToUnderReview = computed(() => this._permissionsService.canSetUnderReview(this.selectedFiles(), this.dossier()));
|
||||
readonly #canSetToUnderApproval = computed(() => this._permissionsService.canSetUnderApproval(this.selectedFiles(), this.dossier()));
|
||||
readonly #isReadyForApproval = computed(() => this._permissionsService.isReadyForApproval(this.selectedFiles(), this.dossier()));
|
||||
readonly #canApprove = computed(() => this._permissionsService.canBeApproved(this.selectedFiles(), this.dossier()));
|
||||
readonly #canUndoApproval = computed(() => this._permissionsService.canUndoApproval(this.selectedFiles(), this.dossier()));
|
||||
readonly #assignTooltip = computed(() =>
|
||||
this.#allFilesAreUnderApproval() ? _('dossier-overview.assign-approver') : _('dossier-overview.assign-reviewer'),
|
||||
);
|
||||
readonly #toggleAnalysisTooltip = computed(() =>
|
||||
this.#allFilesAreExcluded() ? _('file-preview.toggle-analysis.enable') : _('file-preview.toggle-analysis.disable'),
|
||||
);
|
||||
readonly #analysisForced = signal(false);
|
||||
|
||||
constructor(
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
private readonly _bulkActionsService: BulkActionsService,
|
||||
private readonly _rulesService: RulesService,
|
||||
private readonly _toaster: Toaster,
|
||||
) {}
|
||||
|
||||
private get _buttons(): Action[] {
|
||||
get #buttons(): Action[] {
|
||||
const actions: Action[] = [
|
||||
{
|
||||
id: 'delete-files-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.delete(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.delete(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.bulk.delete'),
|
||||
icon: 'iqser:trash',
|
||||
show: this.#canDelete,
|
||||
show: this.#canDelete(),
|
||||
},
|
||||
{
|
||||
id: 'assign-files-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.assign(this.selectedFiles),
|
||||
tooltip: this.#assignTooltip,
|
||||
action: () => this._bulkActionsService.assign(this.selectedFiles()),
|
||||
tooltip: this.#assignTooltip(),
|
||||
icon: 'red:assign',
|
||||
show: this.#canAssign,
|
||||
show: this.#canAssign(),
|
||||
},
|
||||
{
|
||||
id: 'assign-files-to-me-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.assignToMe(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.assignToMe(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.assign-me'),
|
||||
icon: 'red:assign-me',
|
||||
show: this.#canAssignToSelf,
|
||||
show: this.#canAssignToSelf(),
|
||||
},
|
||||
{
|
||||
id: 'to-new-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.setToNew(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.setToNew(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.back-to-new'),
|
||||
icon: 'red:undo',
|
||||
show: this.#canSetToNew,
|
||||
show: this.#canSetToNew(),
|
||||
},
|
||||
{
|
||||
id: 'to-under-approval-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.setToUnderApproval(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.setToUnderApproval(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.under-approval'),
|
||||
icon: 'red:ready-for-approval',
|
||||
show: this.#canSetToUnderApproval,
|
||||
show: this.#canSetToUnderApproval(),
|
||||
},
|
||||
{
|
||||
id: 'to-under-review-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.backToUnderReview(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.backToUnderReview(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.under-review'),
|
||||
icon: 'red:undo',
|
||||
show: this.#canSetToUnderReview,
|
||||
show: this.#canSetToUnderReview(),
|
||||
},
|
||||
{
|
||||
id: 'download-files-btn',
|
||||
type: ActionTypes.downloadBtn,
|
||||
show: !this.selectedFiles.some(file => file.processingStatus === ProcessingFileStatuses.ERROR || !file.lastProcessed),
|
||||
files: this.selectedFiles,
|
||||
dossier: this.dossier,
|
||||
show: !this.selectedFiles().some(file => file.processingStatus === ProcessingFileStatuses.ERROR || !file.lastProcessed),
|
||||
files: this.selectedFiles(),
|
||||
dossier: this.dossier(),
|
||||
},
|
||||
{
|
||||
id: 'approve-files-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.approve(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.approve(this.selectedFiles()),
|
||||
disabled: !this.#canApprove,
|
||||
tooltip: this.#canApprove ? _('dossier-overview.approve') : _('dossier-overview.approve-disabled'),
|
||||
icon: 'red:approved',
|
||||
show: this.#isReadyForApproval,
|
||||
show: this.#isReadyForApproval(),
|
||||
},
|
||||
{
|
||||
id: 'set-under-approval-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.setToUnderApproval(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.setToUnderApproval(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.under-approval'),
|
||||
icon: 'red:undo',
|
||||
show: this.#canUndoApproval,
|
||||
show: this.#canUndoApproval(),
|
||||
},
|
||||
{
|
||||
id: 'ocr-files-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.ocr(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.ocr(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.ocr-file'),
|
||||
icon: 'iqser:ocr',
|
||||
show: this.#canOcr,
|
||||
show: this.#canOcr(),
|
||||
},
|
||||
{
|
||||
id: 'reanalyse-files-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.reanalyse(this.selectedFiles),
|
||||
tooltip: this.areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('dossier-overview.bulk.reanalyse'),
|
||||
action: () => this.#reanalyseBulk(this.selectedFiles()),
|
||||
tooltip: this.#areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('dossier-overview.bulk.reanalyse'),
|
||||
icon: 'iqser:refresh',
|
||||
disabled: this.areRulesLocked(),
|
||||
disabled: this.#areRulesLocked(),
|
||||
show:
|
||||
this.#canReanalyse &&
|
||||
(this.#analysisForced || this.#canEnableAutoAnalysis || this.selectedFiles.every(file => file.isError)),
|
||||
this.#canReanalyse() &&
|
||||
(this.#analysisForced() || this.#canEnableAutoAnalysis() || this.selectedFiles().every(file => file.isError)),
|
||||
},
|
||||
{
|
||||
id: 'stop-automatic-analysis-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.toggleAutomaticAnalysis(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.toggleAutomaticAnalysis(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.stop-auto-analysis'),
|
||||
icon: 'red:disable-analysis',
|
||||
show: this.#canDisableAutoAnalysis,
|
||||
show: this.#canDisableAutoAnalysis(),
|
||||
},
|
||||
{
|
||||
id: 'start-automatic-analysis-btn',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this._bulkActionsService.toggleAutomaticAnalysis(this.selectedFiles),
|
||||
action: () => this._bulkActionsService.toggleAutomaticAnalysis(this.selectedFiles()),
|
||||
tooltip: _('dossier-overview.start-auto-analysis'),
|
||||
icon: 'red:enable-analysis',
|
||||
show: this.#canEnableAutoAnalysis,
|
||||
show: this.#canEnableAutoAnalysis(),
|
||||
},
|
||||
{
|
||||
id: 'toggle-analysis-btn',
|
||||
type: ActionTypes.toggle,
|
||||
action: () => this._bulkActionsService.toggleAnalysis(this.selectedFiles, !this.#allFilesAreExcluded),
|
||||
tooltip: this.#toggleAnalysisTooltip,
|
||||
checked: !this.#allFilesAreExcluded,
|
||||
show: this.#canToggleAnalysis,
|
||||
action: () => this._bulkActionsService.toggleAnalysis(this.selectedFiles(), !this.#allFilesAreExcluded()),
|
||||
tooltip: this.#toggleAnalysisTooltip(),
|
||||
checked: !this.#allFilesAreExcluded(),
|
||||
show: this.#canToggleAnalysis(),
|
||||
},
|
||||
];
|
||||
|
||||
return actions.filter(btn => btn.show);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this._setup();
|
||||
}
|
||||
|
||||
forceReanalysisAction($event: LongPressEvent) {
|
||||
this.#analysisForced = !$event.touchEnd && this._userPreferenceService.isIqserDevMode;
|
||||
this._setup();
|
||||
this.#analysisForced.set(!$event.touchEnd && this._userPreferenceService.isIqserDevMode);
|
||||
}
|
||||
|
||||
private _setup() {
|
||||
if (!this.selectedFiles.length) {
|
||||
async #reanalyseBulk(selectedFiles: File[]) {
|
||||
const rules = await firstValueFrom(this._rulesService.getFor(this.dossier().dossierTemplateId));
|
||||
if (rules.timeoutDetected) {
|
||||
this._toaster.error(_('dossier-listing.rules.timeoutError'));
|
||||
return;
|
||||
}
|
||||
const allFilesAreUnderReviewOrUnassigned = this.selectedFiles.reduce(
|
||||
(acc, file) => acc && (file.isUnderReview || file.isNew),
|
||||
true,
|
||||
);
|
||||
const allFilesAreUnderApproval = this.selectedFiles.reduce((acc, file) => acc && file.isUnderApproval, true);
|
||||
const allFilesAreApproved = this.selectedFiles.reduce((acc, file) => acc && file.isApproved, true);
|
||||
this.#allFilesAreExcluded = this.selectedFiles.reduce((acc, file) => acc && file.excluded, true);
|
||||
this.#canMoveToSameState = allFilesAreUnderReviewOrUnassigned || allFilesAreUnderApproval || allFilesAreApproved;
|
||||
|
||||
this.#canAssign =
|
||||
this.#canMoveToSameState &&
|
||||
(this._permissionsService.canAssignUser(this.selectedFiles, this.dossier) ||
|
||||
this._permissionsService.canUnassignUser(this.selectedFiles, this.dossier));
|
||||
this.#canAssignToSelf = this.#canMoveToSameState && this._permissionsService.canAssignToSelf(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canDelete = this._permissionsService.canSoftDeleteFile(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canReanalyse = this._permissionsService.canReanalyseFile(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canDisableAutoAnalysis = this._permissionsService.canDisableAutoAnalysis(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canEnableAutoAnalysis = this._permissionsService.canEnableAutoAnalysis(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canToggleAnalysis = this._permissionsService.canToggleAnalysis(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canOcr = this._permissionsService.canOcrFile(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canSetToNew = this._permissionsService.canSetToNew(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canSetToUnderReview = this._permissionsService.canSetUnderReview(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canSetToUnderApproval = this._permissionsService.canSetUnderApproval(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#isReadyForApproval = this._permissionsService.isReadyForApproval(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canApprove = this._permissionsService.canBeApproved(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#canUndoApproval = this._permissionsService.canUndoApproval(this.selectedFiles, this.dossier);
|
||||
|
||||
this.#assignTooltip = allFilesAreUnderApproval ? _('dossier-overview.assign-approver') : _('dossier-overview.assign-reviewer');
|
||||
|
||||
this.#toggleAnalysisTooltip = this.#allFilesAreExcluded
|
||||
? _('file-preview.toggle-analysis.enable')
|
||||
: _('file-preview.toggle-analysis.disable');
|
||||
|
||||
this.buttons = this._buttons;
|
||||
await this._bulkActionsService.reanalyse(selectedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import {
|
||||
DisableStopPropagationDirective,
|
||||
EntitiesService,
|
||||
getConfig,
|
||||
IqserAllowDirective,
|
||||
IqserListingModule,
|
||||
ListingService,
|
||||
LoadingService,
|
||||
@ -25,7 +24,6 @@ import { Router } from '@angular/router';
|
||||
import { Roles } from '@users/roles';
|
||||
import { SortingService } from '@iqser/common-ui/lib/sorting';
|
||||
import { List, some } from '@iqser/common-ui/lib/utils';
|
||||
import { MatMenu, MatMenuItem, MatMenuTrigger } from '@angular/material/menu';
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FileDownloadBtnComponent } from '@shared/components/buttons/file-download-btn/file-download-btn.component';
|
||||
@ -39,16 +37,12 @@ import { RulesService } from '../../../admin/services/rules.service';
|
||||
imports: [
|
||||
IqserListingModule,
|
||||
CircleButtonComponent,
|
||||
MatMenuTrigger,
|
||||
IqserAllowDirective,
|
||||
AsyncPipe,
|
||||
TranslateModule,
|
||||
FileDownloadBtnComponent,
|
||||
NgIf,
|
||||
ViewModeSelectionComponent,
|
||||
DisableStopPropagationDirective,
|
||||
MatMenu,
|
||||
MatMenuItem,
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
@ -94,6 +88,11 @@ export class DossierOverviewScreenHeaderComponent implements OnInit {
|
||||
|
||||
async reanalyseDossier() {
|
||||
this._loadingService.start();
|
||||
const rules = await firstValueFrom(this._rulesService.getFor(this.dossier().dossierTemplateId));
|
||||
if (rules.timeoutDetected) {
|
||||
this._toaster.error(_('dossier-listing.rules.timeoutError'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this._reanalysisService.reanalyzeDossier(this.dossier(), true);
|
||||
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
<div *ngIf="isDossierOverviewList && fileAttributesService.isEditingFileAttribute() === false" class="action-buttons">
|
||||
<div *ngIf="isDossierOverviewList() && fileAttributesService.isEditingFileAttribute() === false" class="action-buttons">
|
||||
<ng-container *ngTemplateOutlet="actions"></ng-container>
|
||||
|
||||
<redaction-processing-indicator *ngIf="showStatusBar" [file]="file"></redaction-processing-indicator>
|
||||
<redaction-processing-indicator *ngIf="showStatusBar()" [file]="file()"></redaction-processing-indicator>
|
||||
|
||||
<iqser-status-bar *ngIf="showStatusBar" [configs]="[{ color: file.workflowStatus, length: 1 }]"></iqser-status-bar>
|
||||
<iqser-status-bar *ngIf="showStatusBar()" [configs]="[{ color: file().workflowStatus, length: 1 }]"></iqser-status-bar>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="isFilePreview || isDossierOverviewWorkflow">
|
||||
<ng-container *ngIf="isFilePreview() || isDossierOverviewWorkflow()">
|
||||
<ng-container *ngTemplateOutlet="actions"></ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #actions (longPress)="forceReanalysisAction($event)" redactionLongPress>
|
||||
<div class="file-actions">
|
||||
<redaction-expandable-file-actions
|
||||
[actions]="buttons"
|
||||
[id]="'actions-for-' + file.fileId"
|
||||
[maxWidth]="maxWidth"
|
||||
[minWidth]="minWidth"
|
||||
[actions]="buttons()"
|
||||
[id]="'actions-for-' + file().fileId"
|
||||
[maxWidth]="maxWidth()"
|
||||
[minWidth]="minWidth()"
|
||||
[tooltipPosition]="tooltipPosition"
|
||||
[helpModeKeyPrefix]="helpModeKeyPrefix"
|
||||
[isDossierOverviewWorkflow]="isDossierOverviewWorkflow"
|
||||
[singleEntityAction]="singleEntityAction"
|
||||
[helpModeKeyPrefix]="helpModeKeyPrefix()"
|
||||
[isDossierOverviewWorkflow]="isDossierOverviewWorkflow()"
|
||||
[singleEntityAction]="singleEntityAction()"
|
||||
></redaction-expandable-file-actions>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@ -1,15 +1,4 @@
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
computed,
|
||||
HostBinding,
|
||||
Injector,
|
||||
Input,
|
||||
OnChanges,
|
||||
Optional,
|
||||
signal,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { Component, computed, HostBinding, Injector, input, Optional, signal, ViewChild } from '@angular/core';
|
||||
import { toObservable } from '@angular/core/rxjs-interop';
|
||||
import { Router } from '@angular/router';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
@ -57,53 +46,92 @@ import { RulesService } from '../../../admin/services/rules.service';
|
||||
standalone: true,
|
||||
imports: [ProcessingIndicatorComponent, StatusBarComponent, LongPressDirective, ExpandableFileActionsComponent, NgTemplateOutlet, NgIf],
|
||||
})
|
||||
export class FileActionsComponent implements OnChanges {
|
||||
@Input({ required: true }) file: File;
|
||||
@Input({ required: true }) dossier: Dossier;
|
||||
@Input({ required: true }) type: 'file-preview' | 'dossier-overview-list' | 'dossier-overview-workflow';
|
||||
@Input() maxWidth: number;
|
||||
@Input() minWidth: number;
|
||||
@Input() helpModeKeyPrefix: 'dossier' | 'editor' = 'dossier';
|
||||
@Input() singleEntityAction = false;
|
||||
readonly currentUser = getCurrentUser<User>();
|
||||
toggleTooltip?: string;
|
||||
assignTooltip?: string;
|
||||
showDownload = false;
|
||||
showSetToNew = false;
|
||||
showUndoApproval = false;
|
||||
showAssignToSelf = false;
|
||||
showImportRedactions = false;
|
||||
showAssign = false;
|
||||
showDelete = false;
|
||||
showOCR = false;
|
||||
canReanalyse = false;
|
||||
canDisableAutoAnalysis = false;
|
||||
canEnableAutoAnalysis = false;
|
||||
showUnderReview = false;
|
||||
showUnderApproval = false;
|
||||
showApprove = false;
|
||||
canToggleAnalysis = false;
|
||||
showToggleAnalysis = false;
|
||||
showStatusBar = false;
|
||||
showReanalyseFilePreview = false;
|
||||
showReanalyseDossierOverview = false;
|
||||
analysisForced = false;
|
||||
isDossierOverview = false;
|
||||
isDossierOverviewList = false;
|
||||
isDossierOverviewWorkflow = false;
|
||||
isFilePreview = false;
|
||||
isDossierMember = false;
|
||||
tooltipPosition = IqserTooltipPositions.above;
|
||||
buttons: Action[];
|
||||
export class FileActionsComponent {
|
||||
@ViewChild(ExpandableFileActionsComponent)
|
||||
private readonly _expandableActionsComponent: ExpandableFileActionsComponent;
|
||||
readonly file = input.required<File>();
|
||||
readonly dossier = input.required<Dossier>();
|
||||
readonly type = input.required<'file-preview' | 'dossier-overview-list' | 'dossier-overview-workflow'>();
|
||||
readonly maxWidth = input<number>();
|
||||
readonly minWidth = input<number>();
|
||||
readonly helpModeKeyPrefix = input<'dossier' | 'editor'>('dossier');
|
||||
readonly singleEntityAction = input(false);
|
||||
readonly currentUser = getCurrentUser<User>();
|
||||
readonly tooltipPosition = IqserTooltipPositions.above;
|
||||
|
||||
readonly isDossierOverview = computed(() => this.type().startsWith('dossier-overview'));
|
||||
readonly isDossierOverviewList = computed(() => this.type() === 'dossier-overview-list');
|
||||
readonly isDossierOverviewWorkflow = computed(() => this.type() === 'dossier-overview-workflow');
|
||||
readonly isFilePreview = computed(() => this.type() === 'file-preview');
|
||||
readonly buttons = computed(() => this.#buttons);
|
||||
readonly showStatusBar = computed(() => !this.file().isError && !this.file().isUnprocessed && this.isDossierOverviewList());
|
||||
readonly #assignTooltip? = computed(() =>
|
||||
this.file().isUnderApproval ? _('dossier-overview.assign-approver') : _('dossier-overview.assign-reviewer'),
|
||||
);
|
||||
readonly #showSetToNew = computed(
|
||||
() => this._permissionsService.canSetToNew(this.file(), this.dossier()) && !this.isDossierOverviewWorkflow(),
|
||||
);
|
||||
readonly #showUndoApproval = computed(
|
||||
() => this._permissionsService.canUndoApproval(this.file(), this.dossier()) && !this.isDossierOverviewWorkflow(),
|
||||
);
|
||||
readonly #showAssignToSelf = computed(
|
||||
() => this._permissionsService.canAssignToSelf(this.file(), this.dossier()) && this.isDossierOverview(),
|
||||
);
|
||||
readonly #showImportRedactions = computed(() => this._permissionsService.canImportRedactions(this.file(), this.dossier()));
|
||||
readonly #showAssign = computed(
|
||||
() =>
|
||||
(this._permissionsService.canAssignUser(this.file(), this.dossier()) ||
|
||||
this._permissionsService.canUnassignUser(this.file(), this.dossier())) &&
|
||||
this.isDossierOverview(),
|
||||
);
|
||||
readonly #showDelete = computed(() => this._permissionsService.canSoftDeleteFile(this.file(), this.dossier()));
|
||||
readonly #showOCR = computed(() => this._permissionsService.canOcrFile(this.file(), this.dossier()));
|
||||
readonly #canReanalyse = computed(() => this._permissionsService.canReanalyseFile(this.file(), this.dossier()));
|
||||
readonly #canEnableAutoAnalysis = computed(() => this._permissionsService.canEnableAutoAnalysis([this.file()], this.dossier()));
|
||||
readonly #showUnderReview = computed(
|
||||
() => this._permissionsService.canSetUnderReview(this.file(), this.dossier()) && !this.isDossierOverviewWorkflow(),
|
||||
);
|
||||
readonly #showUnderApproval = computed(
|
||||
() => this._permissionsService.canSetUnderApproval(this.file(), this.dossier()) && !this.isDossierOverviewWorkflow(),
|
||||
);
|
||||
readonly #showApprove = computed(
|
||||
() => this._permissionsService.isReadyForApproval(this.file(), this.dossier()) && !this.isDossierOverviewWorkflow(),
|
||||
);
|
||||
readonly #canToggleAnalysis = computed(() => this._permissionsService.canToggleAnalysis(this.file(), this.dossier()));
|
||||
readonly #toggleTooltip? = computed(() => {
|
||||
if (!this.#canToggleAnalysis()) {
|
||||
return _('file-preview.toggle-analysis.only-managers');
|
||||
}
|
||||
return this.file()?.excluded ? _('file-preview.toggle-analysis.enable') : _('file-preview.toggle-analysis.disable');
|
||||
});
|
||||
readonly #showToggleAnalysis = computed(
|
||||
() => !!this.file().lastProcessed && this._permissionsService.showToggleAnalysis(this.dossier()),
|
||||
);
|
||||
readonly #analysisForced = signal(false);
|
||||
readonly #showReanalyse = computed(
|
||||
() => (this.#canReanalyse() || this.file().excludedFromAutomaticAnalysis || this.#analysisForced()) && !this.file().dossierArchived,
|
||||
);
|
||||
readonly #isDossierMember = computed(() => this._permissionsService.isDossierMember(this.dossier()));
|
||||
readonly #showDownload = computed(
|
||||
() => this._permissionsService.canDownloadRedactedFile() && !!this.file().lastProcessed && this.#isDossierMember(),
|
||||
);
|
||||
readonly #showReanalyseFilePreview = computed(
|
||||
() => this.#showReanalyse() && this.isFilePreview() && !this.file().isApproved && this.#isDossierMember(),
|
||||
);
|
||||
readonly #showReanalyseDossierOverview = computed(
|
||||
() => this.#showReanalyse() && this.isDossierOverview() && !this.file().isApproved && this.#isDossierMember(),
|
||||
);
|
||||
readonly #ariaExpanded$ = toObservable(this._documentInfoService?.shown);
|
||||
readonly #areRulesLocked = computed(() => this._rulesService.currentTemplateRules().timeoutDetected);
|
||||
|
||||
readonly #isDocumine = getConfig().IS_DOCUMINE;
|
||||
readonly areRulesLocked = computed(() => this._rulesService.currentTemplateRules().timeoutDetected);
|
||||
readonly #canDisableAutoAnalysis = computed(
|
||||
() => !this.#isDocumine && this._permissionsService.canDisableAutoAnalysis([this.file()], this.dossier()),
|
||||
);
|
||||
|
||||
constructor(
|
||||
private readonly _injector: Injector,
|
||||
private readonly _filesService: FilesService,
|
||||
private readonly _changeRef: ChangeDetectorRef,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _iqserDialog: IqserDialog,
|
||||
@ -115,6 +143,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
private readonly _rulesService: RulesService,
|
||||
private readonly _toasterService: Toaster,
|
||||
readonly fileAttributesService: FileAttributesService,
|
||||
@Optional() private readonly _documentInfoService: DocumentInfoService,
|
||||
@Optional() private readonly _excludedPagesService: ExcludedPagesService,
|
||||
@ -125,24 +154,16 @@ export class FileActionsComponent implements OnChanges {
|
||||
return !!this._expandableActionsComponent?.expanded;
|
||||
}
|
||||
|
||||
private get _toggleTooltip(): string {
|
||||
if (!this.canToggleAnalysis) {
|
||||
return _('file-preview.toggle-analysis.only-managers');
|
||||
}
|
||||
|
||||
return this.file?.excluded ? _('file-preview.toggle-analysis.enable') : _('file-preview.toggle-analysis.disable');
|
||||
}
|
||||
|
||||
private get _buttons(): Action[] {
|
||||
get #buttons() {
|
||||
const actions: Action[] = [
|
||||
{
|
||||
id: 'btn-download_file',
|
||||
type: ActionTypes.downloadBtn,
|
||||
files: [this.file],
|
||||
dossier: this.dossier,
|
||||
files: [this.file()],
|
||||
dossier: this.dossier(),
|
||||
tooltipClass: 'small',
|
||||
show: this.showDownload,
|
||||
disabled: this.file.processingStatus === ProcessingFileStatuses.ERROR,
|
||||
show: this.#showDownload(),
|
||||
disabled: this.file().processingStatus === ProcessingFileStatuses.ERROR,
|
||||
helpModeKey: this.#isDocumine ? 'download_document' : 'download',
|
||||
},
|
||||
{
|
||||
@ -151,16 +172,16 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#openDeleteFileDialog(),
|
||||
tooltip: _('dossier-overview.delete.action'),
|
||||
icon: 'iqser:trash',
|
||||
show: this.showDelete,
|
||||
show: this.#showDelete(),
|
||||
helpModeKey: 'delete_file',
|
||||
},
|
||||
{
|
||||
id: 'btn-assign',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#assign(),
|
||||
tooltip: this.assignTooltip,
|
||||
tooltip: this.#assignTooltip(),
|
||||
icon: 'red:assign',
|
||||
show: this.showAssign,
|
||||
show: this.#showAssign(),
|
||||
helpModeKey: 'assign_user',
|
||||
},
|
||||
{
|
||||
@ -169,7 +190,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#assignToMe(),
|
||||
tooltip: _('dossier-overview.assign-me'),
|
||||
icon: 'red:assign-me',
|
||||
show: this.showAssignToSelf,
|
||||
show: this.#showAssignToSelf(),
|
||||
helpModeKey: 'assign_user',
|
||||
},
|
||||
{
|
||||
@ -178,7 +199,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#openImportRedactionsDialog(),
|
||||
tooltip: _('dossier-overview.import-redactions'),
|
||||
icon: 'red:import_redactions',
|
||||
show: this.showImportRedactions && !this._iqserPermissionsService.has(Roles.getRss),
|
||||
show: this.#showImportRedactions() && !this._iqserPermissionsService.has(Roles.getRss),
|
||||
helpModeKey: 'import_redactions',
|
||||
},
|
||||
{
|
||||
@ -186,7 +207,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#toggleDocumentInfo(),
|
||||
tooltip: _('file-preview.document-info'),
|
||||
ariaExpanded: toObservable(this._documentInfoService?.shown, { injector: this._injector }),
|
||||
ariaExpanded: this.#ariaExpanded$,
|
||||
icon: 'red:status-info',
|
||||
show: !!this._documentInfoService,
|
||||
helpModeKey: 'document_info',
|
||||
@ -196,10 +217,10 @@ export class FileActionsComponent implements OnChanges {
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#toggleExcludePages(),
|
||||
tooltip: _('file-preview.exclude-pages'),
|
||||
ariaExpanded: toObservable(this._excludedPagesService?.shown, { injector: this._injector }),
|
||||
showDot: !!this.file.excludedPages?.length,
|
||||
ariaExpanded: this.#ariaExpanded$,
|
||||
showDot: !!this.file().excludedPages?.length,
|
||||
icon: 'red:exclude-pages',
|
||||
show: !!this._excludedPagesService && this._permissionsService.canExcludePages(this.file, this.dossier),
|
||||
show: !!this._excludedPagesService && this._permissionsService.canExcludePages(this.file(), this.dossier()),
|
||||
helpModeKey: 'exclude_pages',
|
||||
},
|
||||
{
|
||||
@ -208,7 +229,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#setToNew(),
|
||||
tooltip: _('dossier-overview.back-to-new'),
|
||||
icon: 'red:undo',
|
||||
show: this.showSetToNew,
|
||||
show: this.#showSetToNew(),
|
||||
helpModeKey: 'change_status',
|
||||
},
|
||||
{
|
||||
@ -217,7 +238,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#setFileUnderApproval(),
|
||||
tooltip: _('dossier-overview.under-approval'),
|
||||
icon: 'red:ready-for-approval',
|
||||
show: this.showUnderApproval,
|
||||
show: this.#showUnderApproval(),
|
||||
helpModeKey: 'change_status',
|
||||
},
|
||||
{
|
||||
@ -226,17 +247,17 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#setFileUnderReview(),
|
||||
tooltip: _('dossier-overview.under-review'),
|
||||
icon: 'red:undo',
|
||||
show: this.showUnderReview,
|
||||
show: this.#showUnderReview(),
|
||||
helpModeKey: 'change_status',
|
||||
},
|
||||
{
|
||||
id: 'btn-set_file_approved',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.setFileApproved(),
|
||||
tooltip: this.file.canBeApproved ? _('dossier-overview.approve') : _('dossier-overview.approve-disabled'),
|
||||
tooltip: this.file().canBeApproved ? _('dossier-overview.approve') : _('dossier-overview.approve-disabled'),
|
||||
icon: 'red:approved',
|
||||
disabled: !this.file.canBeApproved,
|
||||
show: this.showApprove,
|
||||
disabled: !this.file().canBeApproved,
|
||||
show: this.#showApprove(),
|
||||
helpModeKey: 'change_status',
|
||||
},
|
||||
{
|
||||
@ -245,17 +266,17 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#toggleAutomaticAnalysis(),
|
||||
tooltip: _('dossier-overview.stop-auto-analysis'),
|
||||
icon: 'red:disable-analysis',
|
||||
show: this.canDisableAutoAnalysis,
|
||||
show: this.#canDisableAutoAnalysis(),
|
||||
helpModeKey: 'stop_analysis',
|
||||
},
|
||||
{
|
||||
id: 'btn-reanalyse_file_preview',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#reanalyseFile(),
|
||||
tooltip: this.areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('file-preview.reanalyse-notification'),
|
||||
tooltip: this.#areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('file-preview.reanalyse-notification'),
|
||||
icon: 'iqser:refresh',
|
||||
show: this.showReanalyseFilePreview,
|
||||
disabled: this.file.isProcessing || this.areRulesLocked(),
|
||||
show: this.#showReanalyseFilePreview(),
|
||||
disabled: this.file().isProcessing || this.#areRulesLocked(),
|
||||
helpModeKey: 'stop_analysis',
|
||||
},
|
||||
{
|
||||
@ -263,9 +284,9 @@ export class FileActionsComponent implements OnChanges {
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#toggleAutomaticAnalysis(),
|
||||
tooltip: _('dossier-overview.start-auto-analysis'),
|
||||
buttonType: this.isFilePreview ? CircleButtonTypes.warn : CircleButtonTypes.default,
|
||||
buttonType: this.isFilePreview() ? CircleButtonTypes.warn : CircleButtonTypes.default,
|
||||
icon: 'red:enable-analysis',
|
||||
show: this.canEnableAutoAnalysis,
|
||||
show: this.#canEnableAutoAnalysis(),
|
||||
helpModeKey: 'stop_analysis',
|
||||
},
|
||||
{
|
||||
@ -274,7 +295,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#setFileUnderApproval(),
|
||||
tooltip: _('dossier-overview.under-approval'),
|
||||
icon: 'red:undo',
|
||||
show: this.showUndoApproval,
|
||||
show: this.#showUndoApproval(),
|
||||
helpModeKey: 'change_status',
|
||||
},
|
||||
{
|
||||
@ -283,28 +304,28 @@ export class FileActionsComponent implements OnChanges {
|
||||
action: () => this.#ocrFile(),
|
||||
tooltip: _('dossier-overview.ocr-file'),
|
||||
icon: 'iqser:ocr',
|
||||
show: this.showOCR,
|
||||
show: this.#showOCR(),
|
||||
helpModeKey: 'automatic_text_recognition',
|
||||
},
|
||||
{
|
||||
id: 'btn-reanalyse_file',
|
||||
type: ActionTypes.circleBtn,
|
||||
action: () => this.#reanalyseFile(),
|
||||
tooltip: this.areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('dossier-overview.reanalyse.action'),
|
||||
tooltip: this.#areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('dossier-overview.reanalyse.action'),
|
||||
icon: 'iqser:refresh',
|
||||
show: this.showReanalyseDossierOverview,
|
||||
disabled: this.areRulesLocked(),
|
||||
show: this.#showReanalyseDossierOverview(),
|
||||
disabled: this.#areRulesLocked(),
|
||||
helpModeKey: 'stop_analysis',
|
||||
},
|
||||
{
|
||||
id: 'btn-toggle_analysis',
|
||||
type: ActionTypes.toggle,
|
||||
action: () => this.#toggleAnalysis(),
|
||||
disabled: !this.canToggleAnalysis,
|
||||
tooltip: this.toggleTooltip,
|
||||
class: { 'mr-24': this.isDossierOverviewList },
|
||||
checked: !this.file.excluded,
|
||||
show: this.showToggleAnalysis && this.isDossierMember,
|
||||
disabled: !this.#canToggleAnalysis,
|
||||
tooltip: this.#toggleTooltip(),
|
||||
class: { 'mr-24': this.isDossierOverviewList() },
|
||||
checked: !this.file().excluded,
|
||||
show: this.#showToggleAnalysis() && this.#isDossierMember(),
|
||||
helpModeKey: 'disable_extraction',
|
||||
},
|
||||
];
|
||||
@ -312,15 +333,11 @@ export class FileActionsComponent implements OnChanges {
|
||||
return actions.filter(btn => btn.show);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.#setup();
|
||||
}
|
||||
|
||||
async setFileApproved() {
|
||||
this._loadingService.start();
|
||||
const approvalResponse: ApproveResponse = (await this._filesService.getApproveWarnings([this.file]))[0];
|
||||
const approvalResponse: ApproveResponse = (await this._filesService.getApproveWarnings([this.file()]))[0];
|
||||
if (!approvalResponse.hasWarnings) {
|
||||
await this._filesService.reload(this.file.dossierId, this.file);
|
||||
await this._filesService.reload(this.file().dossierId, this.file());
|
||||
this._loadingService.stop();
|
||||
return;
|
||||
}
|
||||
@ -341,8 +358,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
forceReanalysisAction($event: LongPressEvent) {
|
||||
this.analysisForced = !$event.touchEnd && this._userPreferenceService.isIqserDevMode;
|
||||
this.#setup();
|
||||
this.#analysisForced.set(!$event.touchEnd && this._userPreferenceService.isIqserDevMode);
|
||||
}
|
||||
|
||||
#showOCRConfirmationDialog(): Observable<boolean> {
|
||||
@ -357,7 +373,7 @@ export class FileActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
#openImportRedactionsDialog() {
|
||||
this._dialogService.openDialog('importRedactions', { dossierId: this.file.dossierId, fileId: this.file.fileId });
|
||||
this._dialogService.openDialog('importRedactions', { dossierId: this.file().dossierId, fileId: this.file().fileId });
|
||||
}
|
||||
|
||||
#openDeleteFileDialog() {
|
||||
@ -370,8 +386,8 @@ export class FileActionsComponent implements OnChanges {
|
||||
async () => {
|
||||
this._loadingService.start();
|
||||
try {
|
||||
const dossier = this._activeDossiersService.find(this.file.dossierId);
|
||||
await firstValueFrom(this._fileManagementService.delete([this.file], this.file.dossierId));
|
||||
const dossier = this._activeDossiersService.find(this.file().dossierId);
|
||||
await firstValueFrom(this._fileManagementService.delete([this.file()], this.file().dossierId));
|
||||
await this._injector.get(Router).navigate([dossier.routerLink]);
|
||||
} catch (error) {
|
||||
this._injector.get(Toaster).error(_('error.http.generic'), { params: error });
|
||||
@ -382,8 +398,8 @@ export class FileActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
#assign() {
|
||||
const files = [this.file];
|
||||
const targetStatus = this.file.workflowStatus;
|
||||
const files = [this.file()];
|
||||
const targetStatus = this.file().workflowStatus;
|
||||
const withCurrentUserAsDefault = true;
|
||||
const withUnassignedOption = true;
|
||||
this._iqserDialog.openDefault(AssignReviewerApproverDialogComponent, {
|
||||
@ -397,29 +413,34 @@ export class FileActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
async #assignToMe() {
|
||||
await this._fileAssignService.assignToMe([this.file]);
|
||||
await this._fileAssignService.assignToMe([this.file()]);
|
||||
}
|
||||
|
||||
async #reanalyseFile() {
|
||||
const rules = await firstValueFrom(this._rulesService.getFor(this.dossier().dossierTemplateId));
|
||||
if (rules.timeoutDetected) {
|
||||
this._toasterService.error(_('dossier-listing.rules.timeoutError'));
|
||||
return;
|
||||
}
|
||||
const params: ReanalyzeQueryParams = {
|
||||
force: true,
|
||||
triggeredByUser: true,
|
||||
};
|
||||
await this._reanalysisService.reanalyzeFilesForDossier([this.file], this.file.dossierId, params);
|
||||
await this._reanalysisService.reanalyzeFilesForDossier([this.file()], this.file().dossierId, params);
|
||||
}
|
||||
|
||||
async #toggleAutomaticAnalysis() {
|
||||
this._loadingService.start();
|
||||
await firstValueFrom(this._reanalysisService.toggleAutomaticAnalysis(this.file.dossierId, [this.file]));
|
||||
await firstValueFrom(this._reanalysisService.toggleAutomaticAnalysis(this.file().dossierId, [this.file()]));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
async #setFileUnderApproval() {
|
||||
await this._fileAssignService.assignApprover(this.file, true);
|
||||
await this._fileAssignService.assignApprover(this.file(), true);
|
||||
}
|
||||
|
||||
async #ocrFile() {
|
||||
if (this.file.lastManualChangeDate) {
|
||||
if (this.file().lastManualChangeDate) {
|
||||
const confirm = await firstValueFrom(this.#showOCRConfirmationDialog());
|
||||
if (!confirm) {
|
||||
return;
|
||||
@ -432,93 +453,47 @@ export class FileActionsComponent implements OnChanges {
|
||||
viewerHeaderService.disableRotationButtons();
|
||||
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService.ocrFiles([this.file], this.file.dossierId);
|
||||
await this._reanalysisService.ocrFiles([this.file()], this.file().dossierId);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
async #setFileUnderReview() {
|
||||
await this._fileAssignService.assignReviewer(this.file, true);
|
||||
await this._fileAssignService.assignReviewer(this.file(), true);
|
||||
}
|
||||
|
||||
async #toggleAnalysis() {
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService.toggleAnalysis(this.file.dossierId, [this.file], !this.file.excluded);
|
||||
await this._reanalysisService.toggleAnalysis(this.file().dossierId, [this.file()], !this.file().excluded);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
#setup() {
|
||||
this.isDossierOverviewList = this.type === 'dossier-overview-list';
|
||||
this.isDossierOverviewWorkflow = this.type === 'dossier-overview-workflow';
|
||||
this.isDossierOverview = this.type.startsWith('dossier-overview');
|
||||
this.isFilePreview = this.type === 'file-preview';
|
||||
|
||||
this.assignTooltip = this.file.isUnderApproval ? _('dossier-overview.assign-approver') : _('dossier-overview.assign-reviewer');
|
||||
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;
|
||||
this.showUnderReview = this._permissionsService.canSetUnderReview(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
this.showUnderApproval = this._permissionsService.canSetUnderApproval(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
this.showApprove = this._permissionsService.isReadyForApproval(this.file, this.dossier) && !this.isDossierOverviewWorkflow;
|
||||
|
||||
this.canToggleAnalysis = this._permissionsService.canToggleAnalysis(this.file, this.dossier);
|
||||
this.showToggleAnalysis = !!this.file.lastProcessed && this._permissionsService.showToggleAnalysis(this.dossier);
|
||||
this.toggleTooltip = this._toggleTooltip;
|
||||
this.isDossierMember = this._permissionsService.isDossierMember(this.dossier);
|
||||
|
||||
this.showDelete = this._permissionsService.canSoftDeleteFile(this.file, this.dossier);
|
||||
this.showOCR = this._permissionsService.canOcrFile(this.file, this.dossier);
|
||||
this.canReanalyse = this._permissionsService.canReanalyseFile(this.file, this.dossier);
|
||||
this.canDisableAutoAnalysis = !this.#isDocumine && this._permissionsService.canDisableAutoAnalysis([this.file], this.dossier);
|
||||
this.canEnableAutoAnalysis = this._permissionsService.canEnableAutoAnalysis([this.file], this.dossier);
|
||||
|
||||
this.showStatusBar = !this.file.isError && !this.file.isUnprocessed && this.isDossierOverviewList;
|
||||
|
||||
const showReanalyse =
|
||||
(this.canReanalyse || this.file.excludedFromAutomaticAnalysis || this.analysisForced) && !this.file.dossierArchived;
|
||||
|
||||
this.showReanalyseFilePreview = showReanalyse && this.isFilePreview && !this.file.isApproved && this.isDossierMember;
|
||||
this.showReanalyseDossierOverview = showReanalyse && this.isDossierOverview && !this.file.isApproved && this.isDossierMember;
|
||||
|
||||
this.showDownload = this._permissionsService.canDownloadRedactedFile() && !!this.file.lastProcessed && this.isDossierMember;
|
||||
this.buttons = this._buttons;
|
||||
|
||||
this._changeRef.markForCheck();
|
||||
}
|
||||
|
||||
async #setFileApproved() {
|
||||
this._loadingService.start();
|
||||
await this._filesService.setApproved(this.file);
|
||||
await this._filesService.setApproved(this.file());
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
async #setToNew() {
|
||||
this._loadingService.start();
|
||||
await this._filesService.setToNew(this.file);
|
||||
await this._filesService.setToNew(this.file());
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
#toggleExcludePages() {
|
||||
this._excludedPagesService.toggle();
|
||||
const shown = this._excludedPagesService.shown();
|
||||
setLocalStorageDataByFileId(this.file.id, 'show-exclude-pages', shown);
|
||||
setLocalStorageDataByFileId(this.file().id, 'show-exclude-pages', shown);
|
||||
if (shown) {
|
||||
setLocalStorageDataByFileId(this.file.id, 'show-document-info', false);
|
||||
setLocalStorageDataByFileId(this.file().id, 'show-document-info', false);
|
||||
}
|
||||
}
|
||||
|
||||
#toggleDocumentInfo() {
|
||||
this._documentInfoService.toggle();
|
||||
const shown = this._documentInfoService.shown();
|
||||
setLocalStorageDataByFileId(this.file.id, 'show-document-info', shown);
|
||||
setLocalStorageDataByFileId(this.file().id, 'show-document-info', shown);
|
||||
if (shown) {
|
||||
setLocalStorageDataByFileId(this.file.id, 'show-exclude-pages', false);
|
||||
setLocalStorageDataByFileId(this.file().id, 'show-exclude-pages', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user