Workflow bulk actions

This commit is contained in:
Adina Țeudan 2021-12-02 03:38:36 +02:00
parent 5886b34d9b
commit 37bd733fbf
6 changed files with 35 additions and 8 deletions

View File

@ -1,4 +1,4 @@
<ng-container (longPress)="forceReanalysisAction($event)" *ngIf="selectedFiles.length" redactionLongPress>
<redaction-expandable-file-actions [actions]="buttons" [buttonType]="buttonType" [tooltipPosition]="'above'">
<redaction-expandable-file-actions [actions]="buttons" [buttonType]="buttonType" [maxWidth]="maxWidth" [tooltipPosition]="'above'">
</redaction-expandable-file-actions>
</ng-container>

View File

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

View File

@ -54,10 +54,11 @@
</div>
</section>
<ng-template #bulkActions>
<ng-template #bulkActions let-maxWidth="maxWidth">
<redaction-dossier-overview-bulk-actions
[buttonType]="(configService.listingMode$ | async) === listingModes.table ? circleButtonTypes.dark : circleButtonTypes.primary"
[dossier]="dossier"
[maxWidth]="maxWidth"
[selectedFiles]="listingService.selectedEntities$ | async"
></redaction-dossier-overview-bulk-actions>
</ng-template>

View File

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

View File

@ -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'));
}
}

@ -1 +1 @@
Subproject commit ea2d5fc69b114ee9a8d117f55865a34e2efc0303
Subproject commit 67ae381607fa946231e44c2946a66bef1b13498f