diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts index e46967dab..94197c8f0 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -114,7 +114,7 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { action: () => this._bulkActionsService.reanalyse(this.selectedFiles), tooltip: _('dossier-overview.bulk.reanalyse'), icon: 'iqser:refresh', - show: this.canReanalyse && this.analysisForced, + show: this.canReanalyse && (this.analysisForced || this.canEnableAutoAnalysis), }, { type: ActionTypes.circleBtn, @@ -165,9 +165,9 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { this.canReanalyse = this._permissionsService.canReanalyseFile(this.selectedFiles); - this.canDisableAutoAnalysis = this._permissionsService.canDisableAutoAnalysis(this.selectedFiles); + this.canDisableAutoAnalysis = this._permissionsService.canEnableDisableAutoAnalysis(this.selectedFiles, 'disable'); - this.canEnableAutoAnalysis = this._permissionsService.canEnableAutoAnalysis(this.selectedFiles); + this.canEnableAutoAnalysis = this._permissionsService.canEnableDisableAutoAnalysis(this.selectedFiles, 'enable'); this.canOcr = this.selectedFiles.reduce((acc, file) => acc && file.canBeOCRed, true); diff --git a/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts index 03a3494b1..7f4dc6cc7 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts @@ -372,8 +372,8 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, this.showDelete = this._permissionsService.canDeleteFile(this.file); this.showOCR = this.file.canBeOCRed; this.canReanalyse = this._permissionsService.canReanalyseFile(this.file); - this.canDisableAutoAnalysis = this._permissionsService.canDisableAutoAnalysis(this.file); - this.canEnableAutoAnalysis = this._permissionsService.canEnableAutoAnalysis(this.file); + this.canDisableAutoAnalysis = this._permissionsService.canEnableDisableAutoAnalysis(this.file, 'disable'); + this.canEnableAutoAnalysis = this._permissionsService.canEnableDisableAutoAnalysis(this.file, 'enable'); this.showStatusBar = !this.file.isError && !this.file.isPending && this.isDossierOverviewList; @@ -382,8 +382,9 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, (this._permissionsService.canAssignUser(this.file) || this._permissionsService.canUnassignUser(this.file)) && this.isDossierOverview; - this.showReanalyseFilePreview = this.canReanalyse && this.isFilePreview && this.analysisForced; - this.showReanalyseDossierOverview = this.canReanalyse && this.isDossierOverview && this.analysisForced; + this.showReanalyseFilePreview = this.canReanalyse && this.isFilePreview && (this.analysisForced || this.canEnableAutoAnalysis); + this.showReanalyseDossierOverview = + this.canReanalyse && this.isDossierOverview && (this.analysisForced || this.canEnableAutoAnalysis); this.buttons = this._buttons; diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index 0d82eb7c0..6d8baf3ee 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -32,14 +32,9 @@ export class PermissionsService { return files.reduce((acc, _file) => this._canReanalyseFile(_file) && acc, true); } - canDisableAutoAnalysis(file: File | File[]): boolean { + canEnableDisableAutoAnalysis(file: File | File[], value: 'enable' | 'disable'): boolean { const files = file instanceof File ? [file] : file; - return files.reduce((acc, _file) => this._canDisableAutoAnalysis(_file) && acc, true); - } - - canEnableAutoAnalysis(file: File | File[]): boolean { - const files = file instanceof File ? [file] : file; - return files.reduce((acc, _file) => this._canEnableAutoAnalysis(_file) && acc, true); + return files.reduce((acc, _file) => this._canEnableDisableAutoAnalysis(_file, value) && acc, true); } isFileAssignee(file: File): boolean { @@ -168,12 +163,9 @@ export class PermissionsService { return this.isReviewerOrApprover(file) || file.isNew || (file.isError && file.isNew); } - private _canDisableAutoAnalysis(file: File): boolean { - return !file.excludedFromAutomaticAnalysis && file.assignee === this._userService.currentUser.id; - } - - private _canEnableAutoAnalysis(file: File): boolean { - return file.excludedFromAutomaticAnalysis && file.assignee === this._userService.currentUser.id; + private _canEnableDisableAutoAnalysis(file: File, value: 'enable' | 'disable'): boolean { + const enableOrDisable = value === 'enable' ? file.excludedFromAutomaticAnalysis : !file.excludedFromAutomaticAnalysis; + return enableOrDisable && file.assignee === this._userService.currentUser.id; } private _canAssignToSelf(file: File, dossier: Dossier): boolean { diff --git a/libs/common-ui b/libs/common-ui index 31b60ff11..b808e4661 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 31b60ff117a8d8ecb9617be3b0c9e1822d437034 +Subproject commit b808e4661e56aa93baca96c57f910443437112d4 diff --git a/libs/red-domain/src/lib/files/file.model.ts b/libs/red-domain/src/lib/files/file.model.ts index d0518b8f6..d1168ffa2 100644 --- a/libs/red-domain/src/lib/files/file.model.ts +++ b/libs/red-domain/src/lib/files/file.model.ts @@ -69,7 +69,7 @@ export class File extends Entity implements IFile { this.dossierDictionaryVersion = file.dossierDictionaryVersion; this.dossierId = file.dossierId; this.excluded = !!file.excluded; - this.excludedFromAutomaticAnalysis = Math.random() < 0.5; //!!file.excludedFromAutomaticAnalysis; + this.excludedFromAutomaticAnalysis = !!file.excludedFromAutomaticAnalysis; this.fileAttributes = file.fileAttributes; this.fileId = file.fileId; this.filename = file.filename;