[ADF-711] Drag and drop doesn't have the acceptedFilesType property (#3104)

* Added acceptedFilesType property for upload-drag-area component.
* Only those files will be uploaded which are included in acceptedFilesType.
This commit is contained in:
camorra-skk
2018-03-22 15:05:40 +05:30
committed by Eugenio Romano
parent 36625c1af6
commit 7358563b09
6 changed files with 166 additions and 98 deletions

View File

@@ -41,6 +41,7 @@ import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { PermissionModel } from '../../document-list/models/permissions.model';
import 'rxjs/add/observable/throw';
import { UploadBase } from './base-upload/upload-base';
@Component({
selector: 'adf-upload-button',
@@ -51,7 +52,7 @@ import 'rxjs/add/observable/throw';
],
encapsulation: ViewEncapsulation.None
})
export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionSubject {
export class UploadButtonComponent extends UploadBase implements OnInit, OnChanges, NodePermissionSubject {
/** Toggles component disabled state (if there is no node permission checking). */
@Input()
@@ -69,10 +70,6 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
@Input()
versioning: boolean = false;
/** List of allowed file extensions, for example: ".jpg,.gif,.png,.svg". */
@Input()
acceptedFilesType: string = '*';
/** Sets a limit on the maximum size (in bytes) of a file to be uploaded.
* Has no effect if undefined.
*/
@@ -118,6 +115,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
protected translateService: TranslationService,
protected logService: LogService
) {
super();
}
ngOnInit() {
@@ -190,27 +188,6 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
});
}
/**
* Checks if the given file is allowed by the extension filters
*
* @param file FileModel
*/
protected isFileAcceptable(file: FileModel): boolean {
if (this.acceptedFilesType === '*') {
return true;
}
const allowedExtensions = this.acceptedFilesType
.split(',')
.map(ext => ext.replace(/^\./, ''));
if (allowedExtensions.indexOf(file.extension) !== -1) {
return true;
}
return false;
}
/**
* Checks if the given file is an acceptable size
*