bulk action improvement
This commit is contained in:
parent
59e59f3531
commit
eed15f1ca3
@ -8,6 +8,7 @@ import { FileStatusWrapper } from '../../file/model/file-status.wrapper';
|
||||
import { FileActionService } from '../../file/service/file-action.service';
|
||||
import { download } from '../../../utils/file-download-utils';
|
||||
import { computerize } from '../../../utils/functions';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-bulk-actions',
|
||||
@ -75,12 +76,8 @@ export class BulkActionsComponent {
|
||||
}
|
||||
|
||||
public async reanalyse() {
|
||||
this.loading = true;
|
||||
const fileIds = this.selectedFiles.filter((file) => this._permissionsService.fileRequiresReanalysis(file)).map((file) => file.fileId);
|
||||
|
||||
await this._reanalysisControllerService.reanalyzeFilesForProject(fileIds, this._appStateService.activeProject.projectId).toPromise();
|
||||
this.reload.emit();
|
||||
this.loading = false;
|
||||
this._performBulkAction(this._reanalysisControllerService.reanalyzeFilesForProject(fileIds, this._appStateService.activeProject.projectId));
|
||||
}
|
||||
|
||||
// Under review
|
||||
@ -89,14 +86,7 @@ export class BulkActionsComponent {
|
||||
}
|
||||
|
||||
public setToUnderReview() {
|
||||
this.loading = true;
|
||||
|
||||
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileUnderReview(file).toPromise());
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
this.reload.emit();
|
||||
this.loading = false;
|
||||
});
|
||||
this._performBulkAction(this._fileActionService.setFileUnderReview(this.selectedFiles));
|
||||
}
|
||||
|
||||
// Under approval
|
||||
@ -105,13 +95,7 @@ export class BulkActionsComponent {
|
||||
}
|
||||
|
||||
public setToUnderApproval() {
|
||||
this.loading = true;
|
||||
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileUnderApproval(file).toPromise());
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
this.reload.emit();
|
||||
this.loading = false;
|
||||
});
|
||||
this._performBulkAction(this._fileActionService.setFileUnderApproval(this.selectedFiles));
|
||||
}
|
||||
|
||||
// Approve
|
||||
@ -120,13 +104,7 @@ export class BulkActionsComponent {
|
||||
}
|
||||
|
||||
public approveDocuments() {
|
||||
this.loading = true;
|
||||
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileApproved(file).toPromise());
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
this.reload.emit();
|
||||
this.loading = false;
|
||||
});
|
||||
this._performBulkAction(this._fileActionService.setFileApproved(this.selectedFiles));
|
||||
}
|
||||
|
||||
// Undo approval
|
||||
@ -134,6 +112,10 @@ export class BulkActionsComponent {
|
||||
return this.selectedFiles.reduce((acc, file) => acc && this._permissionsService.canUndoApproval(file), true);
|
||||
}
|
||||
|
||||
get canDownloadRedactedFiles() {
|
||||
return this.selectedFiles.reduce((acc, file) => acc && this._permissionsService.canDownloadRedactedFile(file), true);
|
||||
}
|
||||
|
||||
// Bulk Download
|
||||
downloadRedactedFiles() {
|
||||
this.loading = true;
|
||||
@ -141,11 +123,17 @@ export class BulkActionsComponent {
|
||||
.downloadRedactedFiles({ fileIds: this.selectedFiles.map((file) => file.fileId) }, this._appStateService.activeProjectId, false, 'response')
|
||||
.subscribe((data) => {
|
||||
download(data, 'redacted_files_' + computerize(this._appStateService.activeProject.name) + '.zip');
|
||||
})
|
||||
.add(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
get canDownloadRedactedFiles() {
|
||||
return this.selectedFiles.reduce((acc, file) => acc && this._permissionsService.canDownloadRedactedFile(file), true);
|
||||
private _performBulkAction(obs: Observable<any>) {
|
||||
this.loading = true;
|
||||
obs.subscribe().add(() => {
|
||||
this.reload.emit();
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user