diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.html index b1147ec9b..2514ba77b 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.html @@ -1,4 +1,4 @@ - + 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 21aedf4b5..060e4c237 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 @@ -22,6 +22,7 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { @Input() @Required() dossier: Dossier; @Input() @Required() selectedFiles: File[]; @Input() buttonType: CircleButtonType = CircleButtonTypes.dark; + @Input() maxWidth: number; analysisForced: boolean; canAssignToSelf: boolean; @@ -91,7 +92,6 @@ export class DossierOverviewBulkActionsComponent implements OnChanges { type: ActionTypes.downloadBtn, show: true, files: this.selectedFiles, - disabled: !this._permissionsService.canDownloadFiles(this.selectedFiles), }, { type: ActionTypes.circleBtn, diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html index 9be2ad255..f59df8959 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html @@ -54,10 +54,11 @@ - + 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 c389b5f2b..09031d88c 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 @@ -148,7 +148,6 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, show: true, files: [this.file], tooltipClass: 'small', - disabled: !this._permissionsService.canDownloadFiles([this.file]), }, { type: ActionTypes.circleBtn, 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 318ecab8d..454fd9242 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 @@ -1,6 +1,10 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { Action } from './types'; -import { CircleButtonType, IqserTooltipPosition } from '@iqser/common-ui'; +import { Action, ActionTypes } from './types'; +import { CircleButtonType, IqserTooltipPosition, Toaster } from '@iqser/common-ui'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { File } from '@red/domain'; +import { FileDownloadService } from '@upload-download/services/file-download.service'; +import { PermissionsService } from '@services/permissions.service'; @Component({ selector: 'redaction-expandable-file-actions', @@ -18,10 +22,16 @@ export class ExpandableFileActionsComponent implements OnChanges { hiddenButtons: Action[]; expanded = false; + constructor( + private readonly _fileDownloadService: FileDownloadService, + private readonly _toaster: Toaster, + private readonly _permissionsService: PermissionsService, + ) {} + ngOnChanges(changes: SimpleChanges) { if (changes.actions || changes.maxWidth) { if (this.maxWidth) { - const count = Math.floor(this.maxWidth / 36); + const count = Math.floor(this.maxWidth / 36) || 1; if (count >= this.actions.length) { this.displayedButtons = [...this.actions]; this.hiddenButtons = []; @@ -34,5 +44,22 @@ export class ExpandableFileActionsComponent implements OnChanges { this.hiddenButtons = []; } } + + if (changes.actions) { + // Patch download button + const downloadBtn = this.actions.find(btn => btn.type === ActionTypes.downloadBtn); + if (downloadBtn) { + downloadBtn.action = $event => this._downloadFiles($event, downloadBtn.files); + downloadBtn.disabled = !this._permissionsService.canDownloadFiles(downloadBtn.files); + } + } + } + + private async _downloadFiles($event: MouseEvent, files: File[]) { + $event.stopPropagation(); + const dossierId = files[0].dossierId; + const filesIds = files.map(f => f.fileId); + await this._fileDownloadService.downloadFiles(filesIds, dossierId).toPromise(); + this._toaster.info(_('download-status.queued')); } } diff --git a/libs/common-ui b/libs/common-ui index ea2d5fc69..67ae38160 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit ea2d5fc69b114ee9a8d117f55865a34e2efc0303 +Subproject commit 67ae381607fa946231e44c2946a66bef1b13498f