diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts index d024219ec..8ddf2f2e7 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { Action, ActionTypes, Dossier, File } from '@red/domain'; +import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses } from '@red/domain'; import { CircleButtonType, CircleButtonTypes, ListingModes } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { LongPressEvent } from '@shared/directives/long-press.directive'; @@ -94,7 +94,7 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { }, { type: ActionTypes.downloadBtn, - show: true, + show: !this.selectedFiles.some(file => file.processingStatus === ProcessingFileStatuses.ERROR), files: this.selectedFiles, dossier: this.dossier, }, diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts index 4ad455f3b..7debf669d 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/file-actions/file-actions.component.ts @@ -11,7 +11,7 @@ import { ViewChild, } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { Action, ActionTypes, Dossier, File, User } from '@red/domain'; +import { Action, ActionTypes, Dossier, File, ProcessingFileStatuses, User } from '@red/domain'; import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { CircleButtonType, @@ -165,6 +165,7 @@ export class FileActionsComponent implements OnChanges { dossier: this.dossier, tooltipClass: 'small', show: this._permissionsService.canDownloadRedactedFile(), + disabled: this.file.processingStatus === ProcessingFileStatuses.ERROR, }, { type: ActionTypes.circleBtn, diff --git a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.html b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.html index 87eb0a2a2..daa4928a1 100644 --- a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.html +++ b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.html @@ -1,9 +1,9 @@ diff --git a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts index c180328bd..7979ca52c 100644 --- a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { Dossier, File } from '@red/domain'; +import { Dossier, File, ProcessingFileStatuses } from '@red/domain'; import { FileDownloadService } from '@upload-download/services/file-download.service'; import { CircleButtonType, CircleButtonTypes, defaultDialogConfig, Toaster } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @@ -35,6 +35,10 @@ export class FileDownloadBtnComponent implements OnChanges { private readonly _toaster: Toaster, ) {} + get invalidDownload() { + return this.files.some(file => file.processingStatus === ProcessingFileStatuses.ERROR); + } + ngOnChanges(): void { this.canDownloadFiles = this._permissionsService.canDownloadFiles(this.files, this.dossier); this.tooltip = this.canDownloadFiles ? _('dossier-overview.download-file') : _('dossier-overview.download-file-disabled'); @@ -44,18 +48,20 @@ export class FileDownloadBtnComponent implements OnChanges { $event.stopPropagation(); const ref = this._dialog.open(DownloadDialogComponent, { ...defaultDialogConfig, - data: { dossier: this.dossier, hasUnapprovedDocuments: this.files.some(file => !file.isApproved) }, + data: { dossier: this.dossier, files: this.files }, }); const result = await firstValueFrom(ref.afterClosed()); if (!result) { return; } - await this._fileDownloadService.downloadFiles({ - dossierId: this.dossier.id, - fileIds: this.files.map(f => f.id), - ...result, - }); - this._toaster.info(_('download-status.queued')); + await this._fileDownloadService + .downloadFiles({ + dossierId: this.dossier.id, + fileIds: this.files.map(f => f.id), + ...result, + }) + .then(() => this._toaster.info(_('download-status.queued'))) + .catch(() => this._toaster.error(_('download-status.error'))); } } diff --git a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.html b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.html index f8f82a401..1ece80983 100644 --- a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.html +++ b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.html @@ -21,6 +21,7 @@ [tooltipClass]="btn.tooltipClass" [tooltipPosition]="tooltipPosition" [type]="buttonType" + [disabled]="btn.disabled" > diff --git a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts index 2bd72d1ed..40ed0f46f 100644 --- a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts @@ -84,7 +84,7 @@ export class ExpandableFileActionsComponent implements OnChanges { $event.stopPropagation(); const ref = this._dialog.open(DownloadDialogComponent, { ...defaultDialogConfig, - data: { dossier, hasUnapprovedDocuments: files.some(file => !file.isApproved) }, + data: { dossier, files }, }); const result = await firstValueFrom(ref.afterClosed()); if (!result) { diff --git a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.html b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.html index 539c93c98..06a0acbaa 100644 --- a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.html +++ b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.html @@ -2,7 +2,7 @@
-
+
diff --git a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts index 873288aab..cc719b47e 100644 --- a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts +++ b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts @@ -1,5 +1,5 @@ import { Component, Inject } from '@angular/core'; -import { Dossier, DownloadFileType, DownloadFileTypes, IReportTemplate } from '@red/domain'; +import { Dossier, DownloadFileType, DownloadFileTypes, IReportTemplate, File, WorkflowFileStatuses } from '@red/domain'; import { downloadTypesForDownloadTranslations } from '@translations/download-types-translations'; import { ReportTemplateService } from '@services/report-template.service'; import { AbstractControl, FormBuilder } from '@angular/forms'; @@ -9,7 +9,7 @@ import { IconButtonTypes, List } from '@iqser/common-ui'; export interface DownloadDialogData { readonly dossier: Dossier; - readonly hasUnapprovedDocuments: boolean; + readonly files: File[]; } export interface DownloadDialogResult { @@ -50,6 +50,18 @@ export class DownloadDialogComponent { return this.form.controls.downloadFileTypes?.value?.length || 0; } + get hasUnapprovedFiles() { + return this.data.files.some(file => !file.isApproved); + } + + get invalidDownload() { + return ( + !!this.form.controls.downloadFileTypes.value.length && + this.form.controls.downloadFileTypes.value.every(type => type === DownloadFileTypes.REDACTED) && + !this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED) + ); + } + private get _availableReportTypes() { const dossierTemplateId = this.data.dossier.dossierTemplateId; const result = this._reportTemplateController.getAvailableReportTemplates(dossierTemplateId); @@ -72,13 +84,6 @@ export class DownloadDialogComponent { this._dialogRef.close(); } - get invalidDownload() { - return ( - this.form.controls.downloadFileTypes.value.every(type => type === DownloadFileTypes.REDACTED) && - this.data.hasUnapprovedDocuments - ); - } - private _hasReportTemplateOrDownloadType(control: AbstractControl) { const atLeastAReportSelected = control.get('reportTemplateIds')?.value.length > 0; const atLeastATypeSelected = control.get('downloadFileTypes')?.value.length > 0; diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 3acc5a9bd..eeeff716b 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1053,7 +1053,8 @@ }, "download-includes": "Wählen Sie die Dokumente für Ihr Download-Paket aus", "download-status": { - "queued": "Ihr Download wurde zur Warteschlange hinzugefügt. Hier finden Sie alle angeforderten Downloads: My Downloads." + "queued": "Ihr Download wurde zur Warteschlange hinzugefügt. Hier finden Sie alle angeforderten Downloads: My Downloads.", + "error": "" }, "download-type": { "annotated": "PDF mit Anmerkungen", diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 327d32d4b..5346e40aa 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1053,7 +1053,8 @@ }, "download-includes": "Choose what is included at download:", "download-status": { - "queued": "Your download has been queued, you can see all your requested downloads here: My Downloads." + "queued": "Your download has been queued, you can see all your requested downloads here: My Downloads.", + "error": "The download preparation failed, please recheck the selected files and download option settings." }, "download-type": { "annotated": "Annotated PDF",