mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
36625c1af6
commit
7358563b09
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user