RED-10588: backported all the locked rules related changes.

This commit is contained in:
Nicoleta Panaghiu 2024-12-03 18:02:23 +02:00
parent 584a6b7bd0
commit c9bb6bc6a5
24 changed files with 488 additions and 319 deletions

View File

@ -258,6 +258,7 @@ export const appModuleFactory = (config: AppConfig) => {
provide: MAT_TOOLTIP_DEFAULT_OPTIONS,
useValue: {
disableTooltipInteractivity: true,
showDelay: 1,
},
},
BaseDatePipe,

View File

@ -11,7 +11,9 @@ import { DictionaryService } from '@services/entity-services/dictionary.service'
import { DefaultColorsService } from '@services/entity-services/default-colors.service';
import { WatermarkService } from '@services/entity-services/watermark.service';
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
import { getConfig } from '@iqser/common-ui';
import { getConfig, Toaster } from '@iqser/common-ui';
import { RulesService } from '../modules/admin/services/rules.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
export function templateExistsWhenEnteringAdmin(): CanActivateFn {
return async function (route: ActivatedRouteSnapshot): Promise<boolean> {
@ -21,12 +23,14 @@ export function templateExistsWhenEnteringAdmin(): CanActivateFn {
const defaultColorsService = inject(DefaultColorsService);
const watermarksService = inject(WatermarkService);
const router = inject(Router);
const rulesService = inject(RulesService);
const isDocumine = getConfig().IS_DOCUMINE;
const dossierTemplate = inject(DossierTemplateStatsService).get(dossierTemplateId);
await firstValueFrom(fileAttributesService.loadFileAttributesConfig(dossierTemplateId));
await firstValueFrom(dictionaryService.loadDictionaryDataForDossierTemplate(dossierTemplateId));
await firstValueFrom(defaultColorsService.loadForDossierTemplate(dossierTemplateId));
await firstValueFrom(rulesService.getFor(dossierTemplateId));
if (!isDocumine) {
await firstValueFrom(watermarksService.loadForDossierTemplate(dossierTemplateId));
}
@ -50,6 +54,8 @@ export function templateExistsWhenEnteringDossierList(): CanActivateFn {
const dictionaryService = inject(DictionaryService);
const defaultColorsService = inject(DefaultColorsService);
const watermarksService = inject(WatermarkService);
const rulesService = inject(RulesService);
const toaster = inject(Toaster);
const isDocumine = getConfig().IS_DOCUMINE;
await firstValueFrom(dashboardStatsService.loadForTemplate(dossierTemplateId));
@ -64,6 +70,10 @@ export function templateExistsWhenEnteringDossierList(): CanActivateFn {
await firstValueFrom(fileAttributesService.loadFileAttributesConfig(dossierTemplateId));
await firstValueFrom(dictionaryService.loadDictionaryDataForDossierTemplate(dossierTemplateId));
await firstValueFrom(defaultColorsService.loadForDossierTemplate(dossierTemplateId));
const rules = await firstValueFrom(rulesService.getFor(dossierTemplateId));
if (rules.timeoutDetected) {
toaster.error(_('dossier-listing.rules.timeoutError'));
}
if (!isDocumine) {
await firstValueFrom(watermarksService.loadForDossierTemplate(dossierTemplateId));
}

View File

@ -34,6 +34,21 @@
<span [innerHTML]="'dossier-template-info-screen.created-on' | translate: { date: createdOn }"></span>
</div>
<div *ngIf="areRulesLocked()">
<mat-icon
(click)="resetRules()"
[matTooltip]="
currentUser.isAdmin
? ('dossier-template-info-screen.rules-reset.tooltip' | translate)
: ('dossier-template-info-screen.rules-reset.disabled-action' | translate)
"
[class.cursor-pointer]="currentUser.isAdmin"
svgIcon="iqser:alert-circle"
class="action-icon"
></mat-icon>
<span class="error">{{ 'dossier-template-info-screen.rules-reset.label' | translate }}</span>
</div>
<div>
<mat-icon svgIcon="red:entries"></mat-icon>
{{ 'dossier-template-info-screen.entries' | translate: { count: ctx.stats.numberOfEntries } }}

View File

@ -18,3 +18,17 @@
padding-right: 24px;
margin-right: 24px;
}
.error {
color: var(--iqser-primary);
}
.action-icon {
::ng-deep svg g {
fill: var(--iqser-primary);
}
}
.cursor-pointer {
cursor: pointer;
}

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, computed, Input, OnInit } from '@angular/core';
import { ContextComponent } from '@iqser/common-ui/lib/utils';
import { type DossierTemplate, type DossierTemplateStats } from '@red/domain';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
@ -9,6 +9,12 @@ import { MatIcon } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
import { InitialsAvatarComponent } from '@common-ui/users';
import { DatePipe } from '@shared/pipes/date.pipe';
import { RulesService } from '../../../services/rules.service';
import { Toaster } from '@iqser/common-ui';
import { MatTooltip } from '@angular/material/tooltip';
import { firstValueFrom } from 'rxjs';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { getCurrentUser } from '@users/user.service';
interface Context {
readonly dossierTemplate: DossierTemplate;
@ -20,16 +26,22 @@ interface Context {
templateUrl: './dossier-template-details.component.html',
styleUrls: ['./dossier-template-details.component.scss'],
standalone: true,
imports: [NgIf, AsyncPipe, MatIcon, TranslateModule, DatePipe, InitialsAvatarComponent],
imports: [NgIf, AsyncPipe, MatIcon, TranslateModule, DatePipe, InitialsAvatarComponent, MatTooltip],
})
export class DossierTemplateDetailsComponent extends ContextComponent<Context> implements OnInit {
readonly translations = dossierTemplateStatusTranslations;
@Input({ required: true }) dossierTemplateId: string;
readonly areRulesLocked = computed(() => {
return this._rulesService.currentTemplateRules().timeoutDetected;
});
readonly currentUser = getCurrentUser();
constructor(
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _dossierTemplateStatsService: DossierTemplateStatsService,
private readonly _rulesService: RulesService,
private readonly _toaster: Toaster,
) {
super();
}
@ -40,4 +52,11 @@ export class DossierTemplateDetailsComponent extends ContextComponent<Context> i
stats: this._dossierTemplateStatsService.watch$(this.dossierTemplateId),
});
}
async resetRules() {
if (!this.currentUser.isAdmin) return;
await firstValueFrom(this._rulesService.reset(this.dossierTemplateId));
this._toaster.success(_('dossier-template-info-screen.rules-reset.success'));
await firstValueFrom(this._rulesService.getFor(this.dossierTemplateId));
}
}

View File

@ -1,9 +1,25 @@
import { Injectable } from '@angular/core';
import { GenericService } from '@iqser/common-ui';
import { IRules } from '@red/domain';
import { EntitiesService, QueryParam } from '@iqser/common-ui';
import { IRules, Rules } from '@red/domain';
import { map, Observable, tap } from 'rxjs';
import { List } from '@common-ui/utils';
import { toSignal } from '@angular/core/rxjs-interop';
import { distinctUntilChanged, filter } from 'rxjs/operators';
@Injectable()
export class RulesService extends GenericService<IRules> {
@Injectable({ providedIn: 'root' })
export class RulesService extends EntitiesService<IRules, Rules> {
readonly currentTemplateRules = toSignal(
this.all$.pipe(
filter(all => !!all.length),
map(rules => rules[0]),
distinctUntilChanged(
(prev, curr) =>
prev.rules === curr.rules &&
prev.timeoutDetected === curr.timeoutDetected &&
prev.dossierTemplateId === curr.dossierTemplateId,
),
),
);
protected readonly _defaultModelPath = 'rules';
download(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
@ -13,4 +29,12 @@ export class RulesService extends GenericService<IRules> {
uploadRules(body: IRules) {
return this._post<unknown>({ ...body, ruleFileType: body.ruleFileType ?? 'ENTITY' });
}
getFor<R = IRules>(entityId: string, queryParams?: List<QueryParam>): Observable<R> {
return super.getFor<R>(entityId, queryParams).pipe(tap(rules => this.setEntities([rules as Rules])));
}
reset(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
return this._put(null, `${this._defaultModelPath}/${dossierTemplateId}/${ruleFileType}/reset`);
}
}

View File

@ -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>

View File

@ -1,6 +1,6 @@
import { Component, 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';
@ -9,6 +9,8 @@ import { BulkActionsService } from '../../services/bulk-actions.service';
import { ExpandableFileActionsComponent } from '@shared/components/expandable-file-actions/expandable-file-actions.component';
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]',
@ -17,218 +19,211 @@ import { NgIf } from '@angular/common';
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 #areFilesInErrorState = computed(() => this.selectedFiles().some(file => file.isError));
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()) && !this.#areFilesInErrorState(),
);
readonly #canEnableAutoAnalysis = computed(
() => this._permissionsService.canEnableAutoAnalysis(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canToggleAnalysis = computed(() => this._permissionsService.canToggleAnalysis(this.selectedFiles(), this.dossier()));
readonly #canOcr = computed(
() => this._permissionsService.canOcrFile(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canSetToNew = computed(
() => this._permissionsService.canSetToNew(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canSetToUnderReview = computed(
() => this._permissionsService.canSetUnderReview(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canSetToUnderApproval = computed(
() => this._permissionsService.canSetUnderApproval(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #isReadyForApproval = computed(
() => this._permissionsService.isReadyForApproval(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canApprove = computed(
() => this._permissionsService.canBeApproved(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
readonly #canUndoApproval = computed(
() => this._permissionsService.canUndoApproval(this.selectedFiles(), this.dossier()) && !this.#areFilesInErrorState(),
);
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),
disabled: !this.#canApprove,
tooltip: this.#canApprove ? _('dossier-overview.approve') : _('dossier-overview.approve-disabled'),
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: _('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(),
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);
}
}

View File

@ -60,7 +60,6 @@ interface DossierDetailsContext {
NgIf,
AsyncPipe,
CircleButtonComponent,
IqserAllowDirective,
TranslateModule,
DonutChartComponent,
IqserLoadingModule,
@ -70,6 +69,7 @@ interface DossierDetailsContext {
AssignUserDropdownComponent,
InitialsAvatarComponent,
TeamMembersComponent,
IqserAllowDirective,
],
})
export class DossierDetailsComponent extends ContextComponent<DossierDetailsContext> {
@ -111,7 +111,6 @@ export class DossierDetailsComponent extends ContextComponent<DossierDetailsCont
combineLatestWith(files$),
map(([stats, files]) => this.#calculateStatusConfig(stats, files)),
);
super._initContext({
needsWorkFilters: filterService.getFilterModels$('needsWorkFilters'),
dossier: dossier$,

View File

@ -30,11 +30,14 @@
<iqser-circle-button
(action)="reanalyseDossier()"
*ngIf="permissionsService.displayReanalyseBtn(dossier())"
[disabled]="listingService.areSomeSelected$ | async"
[disabled]="(listingService.areSomeSelected$ | async) || areRulesLocked()"
[icon]="'iqser:refresh'"
[iqserDisableStopPropagation]="shouldDisableStopPropagation()"
[tooltipClass]="'small warn'"
[tooltip]="'dossier-overview.new-rule.toast.actions.reanalyse-all' | translate"
[tooltip]="
(areRulesLocked() ? 'dossier-listing.rules.timeoutError' : 'dossier-overview.new-rule.toast.actions.reanalyse-all')
| translate
"
[type]="circleButtonTypes.warn"
></iqser-circle-button>

View File

@ -1,10 +1,11 @@
import { Component, computed, EventEmitter, input, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, EventEmitter, input, OnInit, Output } from '@angular/core';
import {
CircleButtonComponent,
CircleButtonTypes,
DisableStopPropagationDirective,
EntitiesService,
getConfig,
IqserAllowDirective,
IqserListingModule,
ListingService,
LoadingService,
@ -29,6 +30,7 @@ import { FileDownloadBtnComponent } from '@shared/components/buttons/file-downlo
import { ViewModeSelectionComponent } from '../view-mode-selection/view-mode-selection.component';
import { toSignal } from '@angular/core/rxjs-interop';
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
import { RulesService } from '../../../admin/services/rules.service';
@Component({
selector: 'redaction-dossier-overview-screen-header [dossier] [upload]',
@ -43,7 +45,9 @@ import { FileAttributesService } from '@services/entity-services/file-attributes
NgIf,
ViewModeSelectionComponent,
DisableStopPropagationDirective,
IqserAllowDirective,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DossierOverviewScreenHeaderComponent {
readonly dossier = input<Dossier>();
@ -53,6 +57,9 @@ export class DossierOverviewScreenHeaderComponent {
readonly downloadFilesDisabled$: Observable<boolean>;
readonly downloadComponentLogsDisabled$: Observable<boolean>;
readonly isDocumine = getConfig().IS_DOCUMINE;
readonly areRulesLocked = computed(() => {
return this._rulesService.currentTemplateRules().timeoutDetected;
});
readonly areSomeSelected = toSignal(this.listingService.areSomeSelected$);
readonly actionConfigs = computed(() => this.configService.actionConfig(this.dossier().id, this.areSomeSelected()));
readonly shouldDisableStopPropagation = computed(() => this._fileAttributesService.isEditingFileAttribute());
@ -69,6 +76,7 @@ export class DossierOverviewScreenHeaderComponent {
private readonly _reanalysisService: ReanalysisService,
private readonly _loadingService: LoadingService,
private readonly _primaryFileAttributeService: PrimaryFileAttributeService,
private readonly _rulesService: RulesService,
private readonly _fileAttributesService: FileAttributesService,
) {
const someNotProcessed$ = this.entitiesService.all$.pipe(some(file => !file.lastProcessed));
@ -82,6 +90,12 @@ export class DossierOverviewScreenHeaderComponent {
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'));
this._loadingService.stop();
return;
}
try {
await this._reanalysisService.reanalyzeDossier(this.dossier(), true);
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));

View File

@ -23,11 +23,13 @@
<div class="cell" *ngIf="!isDocumine">
<redaction-file-workload *ngIf="!file.excluded" [file]="file"></redaction-file-workload>
</div>
</ng-container>
<div class="user-column cell">
<iqser-initials-avatar [user]="file.assignee" [withName]="true"></iqser-initials-avatar>
</div>
<div class="user-column cell">
<iqser-initials-avatar [user]="file.assignee" [withName]="true"></iqser-initials-avatar>
</div>
<ng-container *ngIf="!file.isError">
<div class="cell">
<div class="small-label stats-subtitle">
<div>

View File

@ -5,7 +5,7 @@
}
.extend-cols {
grid-column-end: span 3;
grid-column-end: span 2;
align-items: flex-end;
}

View File

@ -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>

View File

@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, HostBinding, Injector, Input, OnChanges, Optional, 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';
@ -36,6 +36,7 @@ import { FileAssignService } from '../../services/file-assign.service';
import { ProcessingIndicatorComponent } from '@shared/components/processing-indicator/processing-indicator.component';
import { StatusBarComponent } from '@common-ui/shared';
import { NgIf, NgTemplateOutlet } from '@angular/common';
import { RulesService } from '../../../admin/services/rules.service';
@Component({
selector: 'redaction-file-actions',
@ -44,52 +45,113 @@ import { NgIf, NgTemplateOutlet } from '@angular/common';
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() && !this.file().isError,
);
readonly #showUndoApproval = computed(
() =>
this._permissionsService.canUndoApproval(this.file(), this.dossier()) &&
!this.isDossierOverviewWorkflow() &&
!this.file().isError,
);
readonly #showAssignToSelf = computed(
() => this._permissionsService.canAssignToSelf(this.file(), this.dossier()) && this.isDossierOverview(),
);
readonly #showImportRedactions = computed(
() => this._permissionsService.canImportRedactions(this.file(), this.dossier()) && !this.file().isError,
);
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()) && !this.file().isError);
readonly #canReanalyse = computed(() => this._permissionsService.canReanalyseFile(this.file(), this.dossier()));
readonly #canEnableAutoAnalysis = computed(
() => this._permissionsService.canEnableAutoAnalysis([this.file()], this.dossier()) && !this.file().isError,
);
readonly #showUnderReview = computed(
() =>
this._permissionsService.canSetUnderReview(this.file(), this.dossier()) &&
!this.isDossierOverviewWorkflow() &&
!this.file().isError,
);
readonly #showUnderApproval = computed(
() =>
this._permissionsService.canSetUnderApproval(this.file(), this.dossier()) &&
!this.isDossierOverviewWorkflow() &&
!this.file().isError,
);
readonly #showApprove = computed(
() =>
this._permissionsService.isReadyForApproval(this.file(), this.dossier()) &&
!this.isDossierOverviewWorkflow() &&
!this.file().isError,
);
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.file().isError &&
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 #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,
@ -100,6 +162,8 @@ export class FileActionsComponent implements OnChanges {
private readonly _activeDossiersService: ActiveDossiersService,
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,
@ -110,24 +174,15 @@ 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(),
helpModeKey: this.#isDocumine ? 'download_document' : 'download',
},
{
@ -136,16 +191,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',
},
{
@ -154,7 +209,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',
},
{
@ -163,7 +218,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',
},
{
@ -171,7 +226,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',
@ -181,10 +236,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',
},
{
@ -193,7 +248,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',
},
{
@ -202,7 +257,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',
},
{
@ -211,17 +266,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',
},
{
@ -230,18 +285,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: _('file-preview.reanalyse-notification'),
tooltipClass: 'small',
tooltip: this.#areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('file-preview.reanalyse-notification'),
icon: 'iqser:refresh',
show: this.showReanalyseFilePreview,
disabled: this.file.isProcessing,
show: this.#showReanalyseFilePreview(),
disabled: this.file().isProcessing || this.#areRulesLocked(),
helpModeKey: 'stop_analysis',
},
{
@ -249,9 +303,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',
},
{
@ -260,7 +314,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',
},
{
@ -269,27 +323,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: _('dossier-overview.reanalyse.action'),
tooltip: this.#areRulesLocked() ? _('dossier-listing.rules.timeoutError') : _('dossier-overview.reanalyse.action'),
icon: 'iqser:refresh',
show: this.showReanalyseDossierOverview,
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',
},
];
@ -297,33 +352,28 @@ export class FileActionsComponent implements OnChanges {
return actions.filter(btn => btn.show);
}
ngOnChanges() {
this.#setup();
}
async setFileApproved() {
if (!this.file.analysisRequired && !this.file.hasUpdates) {
if (!this.file().analysisRequired && !this.file().hasUpdates) {
await this.#setFileApproved();
return;
}
const data: IConfirmationDialogData = {
title: this.file.analysisRequired
title: this.file().analysisRequired
? _('confirmation-dialog.approve-file-without-analysis.title')
: _('confirmation-dialog.approve-file.title'),
question: this.file.analysisRequired
question: this.file().analysisRequired
? _('confirmation-dialog.approve-file-without-analysis.question')
: _('confirmation-dialog.approve-file.question'),
confirmationText: this.file.analysisRequired ? _('confirmation-dialog.approve-file-without-analysis.confirmationText') : null,
denyText: this.file.analysisRequired ? _('confirmation-dialog.approve-file-without-analysis.denyText') : null,
confirmationText: this.file().analysisRequired ? _('confirmation-dialog.approve-file-without-analysis.confirmationText') : null,
denyText: this.file().analysisRequired ? _('confirmation-dialog.approve-file-without-analysis.denyText') : null,
};
this._dialogService.openDialog('confirm', data, () => this.#setFileApproved());
}
forceReanalysisAction($event: LongPressEvent) {
this.analysisForced = !$event.touchEnd && this._userPreferenceService.isIqserDevMode;
this.#setup();
this.#analysisForced.set(!$event.touchEnd && this._userPreferenceService.isIqserDevMode);
}
#showOCRConfirmationDialog(): Observable<boolean> {
@ -338,7 +388,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() {
@ -351,8 +401,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 });
@ -363,8 +413,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, {
@ -378,29 +428,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;
@ -413,93 +468,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);
}
}
}

View File

@ -473,7 +473,7 @@ export class PermissionsService {
}
#canAssignToSelf(file: File, dossier: Dossier): boolean {
const precondition = this.#fileIsOk(file, dossier) && !this.isFileAssignee(file);
const precondition = (this.#fileIsOk(file, dossier) || file.isError) && !this.isFileAssignee(file);
return precondition && (this.isApprover(dossier) || (this.isDossierMember(dossier) && (file.isNew || file.isUnderReview)));
}

View File

@ -933,6 +933,9 @@
"reanalyse": {
"action": "Ganzes Dossier analysieren"
},
"rules": {
"timeoutError": "Regeln für Dossier-Vorlagen gesperrt!"
},
"stats": {
"analyzed-pages": "{count, plural, one{Seite} other{Seiten}}",
"total-people": "Benutzer"
@ -1089,6 +1092,12 @@
"entities": "{count} {count, plural, one{Entität} other{Entitäten}}",
"entries": "{count} {count, plural, one{Eintrag} other{Einträge}}",
"modified-on": "Geändert am: {date}",
"rules-reset": {
"disabled-action": "Bitte wenden Sie sich an Ihren Administrator, um die Regeln freizuschalten.",
"label": "Regeln gesperrt",
"success": "Die Regeln der Dossier-Vorlage wurden erfolgreich zurückgesetzt.",
"tooltip": "Klicken Sie hier, um die Regeln zurückzusetzen"
},
"title": "Dossier-Vorlage bearbeiten",
"valid-from": "Gültig ab: {date}",
"valid-to": "Gültig bis: {Datum}"

View File

@ -933,6 +933,9 @@
"reanalyse": {
"action": "Analyze entire dossier"
},
"rules": {
"timeoutError": "Dossier template rules locked!"
},
"stats": {
"analyzed-pages": "{count, plural, one{Page} other{Pages}}",
"total-people": "Total users"
@ -1089,6 +1092,12 @@
"entities": "{count} {count, plural, one{entity} other{entities}}",
"entries": "{count} {count, plural, one{entry} other{entries}}",
"modified-on": "Modified on: {date}",
"rules-reset": {
"disabled-action": "Please contact your administrator to unlock the rules.",
"label": "Rules locked",
"success": "Dossier template rules successfully reset.",
"tooltip": "Click to reset rules"
},
"title": "Edit dossier template",
"valid-from": "Valid from: {date}",
"valid-to": "Valid to: {date}"

View File

@ -933,6 +933,9 @@
"reanalyse": {
"action": "Gesamtes Dossier analysieren"
},
"rules": {
"timeoutError": "Regeln für Dossier-Vorlagen gesperrt!"
},
"stats": {
"analyzed-pages": "{count, plural, one{Page} other{Pages}}",
"total-people": "Anzahl der Benutzer"
@ -1089,6 +1092,12 @@
"entities": "{count} {count, plural, one{entity} other{entities}}",
"entries": "{count} {count, plural, one{entry} other{entries}}",
"modified-on": "Modified on: {date}",
"rules-reset": {
"disabled-action": "Bitte wenden Sie sich an Ihren Administrator, um die Regeln freizuschalten.",
"label": "Regeln gesperrt",
"success": "Die Regeln der Dossier-Vorlage wurden erfolgreich zurückgesetzt.",
"tooltip": "Klicken Sie hier, um die Regeln zurückzusetzen"
},
"title": "Edit dossier template",
"valid-from": "Valid from: {date}",
"valid-to": "Valid to: {date}"

View File

@ -933,6 +933,9 @@
"reanalyse": {
"action": "Analyze entire dossier"
},
"rules": {
"timeoutError": "Dossier template rules locked!"
},
"stats": {
"analyzed-pages": "{count, plural, one{Page} other{Pages}}",
"total-people": "Total users"
@ -1089,6 +1092,12 @@
"entities": "{count} {count, plural, one{entity} other{entities}}",
"entries": "{count} {count, plural, one{entry} other{entries}}",
"modified-on": "Modified on: {date}",
"rules-reset": {
"disabled-action": "Please contact your administrator to unlock the rules.",
"label": "Rules locked",
"success": "Dossier template rules successfully reset.",
"tooltip": "Click to reset rules"
},
"title": "Edit dossier template",
"valid-from": "Valid from: {date}",
"valid-to": "Valid to: {date}"

View File

@ -1,5 +1,4 @@
import { Entity } from '@iqser/common-ui';
import { PendingType, PendingTypes, ProcessingType, ProcessingTypes } from '../dossier-stats';
import { ARCHIVE_ROUTE, DOSSIERS_ROUTE } from '../dossiers';
import { FileAttributes } from '../file-attributes';
import { StatusSorter } from '../shared';
@ -17,6 +16,7 @@ import {
WorkflowFileStatus,
WorkflowFileStatuses,
} from './types';
import { PendingType, PendingTypes, ProcessingType, ProcessingTypes } from '../dossier-stats';
export class File extends Entity<IFile> implements IFile {
readonly added?: string;
@ -182,6 +182,13 @@ export class File extends Entity<IFile> implements IFile {
return this.canBeOpened ? `/main/${this.dossierTemplateId}/${routerPath}/${this.dossierId}/file/${this.fileId}` : undefined;
}
get #pendingType(): PendingType | undefined {
if (this.errorCode === FileErrorCodes.RULES_EXECUTION_TIMEOUT) {
return PendingTypes.timeout;
}
return undefined;
}
get #processingType(): ProcessingType {
if (PENDING_STATES.includes(this.processingStatus)) {
return ProcessingTypes.pending;
@ -195,13 +202,6 @@ export class File extends Entity<IFile> implements IFile {
return ProcessingTypes.processed;
}
get #pendingType(): PendingType | undefined {
if (this.errorCode === FileErrorCodes.RULES_EXECUTION_TIMEOUT) {
return PendingTypes.timeout;
}
return undefined;
}
isPageExcluded(page: number): boolean {
return this.excludedPages.includes(page);
}

View File

@ -13,3 +13,4 @@ export * from './app-config';
export * from './system-preferences';
export * from './component-rules';
export * from './editor.types';
export * from './rules.model';

View File

@ -0,0 +1,23 @@
import { IRules } from '@red/domain';
import { Entity } from '@iqser/common-ui';
export class Rules extends Entity<IRules> implements IRules {
readonly id: string;
readonly routerLink: string;
readonly searchKey: string;
readonly dossierTemplateId: string;
readonly ruleFileType?: 'ENTITY' | 'COMPONENT';
readonly rules?: string;
readonly dryRun?: boolean;
readonly timeoutDetected?: boolean;
constructor(rules: IRules) {
super(rules);
this.id = rules.dossierTemplateId;
this.dossierTemplateId = rules.dossierTemplateId;
this.ruleFileType = rules.ruleFileType;
this.rules = rules.rules;
this.dryRun = rules.dryRun;
this.timeoutDetected = rules.timeoutDetected;
}
}

View File

@ -5,7 +5,7 @@ export interface IRules {
/**
* The DossierTemplate ID for these rules
*/
dossierTemplateId?: string;
dossierTemplateId: string;
/**
* The file type to be retrieved/saved under, defaults to ENTITY
*/
@ -18,4 +18,8 @@ export interface IRules {
* Request param for rules validation, without updating them
*/
dryRun?: boolean;
/**
* Flag which indicates whether the dossier template rules have been locked due to a timeout
*/
timeoutDetected?: boolean;
}