[ADF-3095] ability to intercept, pause and resume upload process (#3416)

* prevent and resume upload process

* upload fixes and confirmation dialog demo

* ability to toggle the upload confirmation demo

* fix tests

* unit tests

* docs update

* remove deprecation

* fix test name
This commit is contained in:
Denys Vuika
2018-05-31 10:21:32 +01:00
committed by Eugenio Romano
parent 64a8c66103
commit 54e80e7863
11 changed files with 273 additions and 36 deletions

View File

@@ -31,7 +31,7 @@ import {
PaginationComponent, FormValues, DisplayMode, UserPreferenceValues, InfinitePaginationComponent
} from '@alfresco/adf-core';
import { DocumentListComponent, PermissionStyleModel } from '@alfresco/adf-content-services';
import { DocumentListComponent, PermissionStyleModel, UploadFilesEvent, ConfirmDialogComponent } from '@alfresco/adf-content-services';
import { SelectAppsDialogComponent } from '@alfresco/adf-process-services';
@@ -177,6 +177,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
infiniteScrolling: boolean;
supportedPages: number[];
currentSiteid = '';
warnOnMultipleUploads = false;
private onCreateFolder: Subscription;
private onEditFolder: Subscription;
@@ -513,4 +514,27 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
}
return false;
}
onBeginUpload(event: UploadFilesEvent) {
if (this.warnOnMultipleUploads && event) {
const files = event.files || [];
if (files.length > 1) {
event.pauseUpload();
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
data: {
title: 'Upload',
message: `Are you sure you want to upload ${files.length} file(s)?`
},
minWidth: '250px'
});
dialogRef.afterClosed().subscribe(result => {
if (result === true) {
event.resumeUpload();
}
});
}
}
}
}