Replace file in queue when single select #767

Open
SmallhillCZ wants to merge 1 commits from unknown repository into development

View File

@@ -1,6 +1,7 @@
import { Directive, ElementRef, Input, HostListener } from '@angular/core';
import { FileUploader } from './file-uploader.class';
import { FileItem } from './file-item.class';
// todo: filters
@@ -8,6 +9,8 @@ import { FileUploader } from './file-uploader.class';
export class FileSelectDirective {
@Input() public uploader:FileUploader;
lastFile:FileItem;
protected element:ElementRef;
public constructor(element:ElementRef) {
@@ -22,7 +25,7 @@ export class FileSelectDirective {
return void 0;
}
public isEmptyAfterSelection():boolean {
public isMultiple():boolean {
return !!this.element.nativeElement.attributes.multiple;
}
@@ -34,9 +37,16 @@ export class FileSelectDirective {
let filters = this.getFilters();
// if(!this.uploader.isHTML5) this.destroy();
// if not multiple, remove previously added file so we can replace it with the new one
if(!this.isMultiple() && this.lastFile & !this.lastFile.uploaded) this.uploader.removeFromQueue(this.lastFile);
this.uploader.addToQueue(files, options, filters);
if (this.isEmptyAfterSelection()) {
// save file so we can remove it later
this.lastFile = this.uploader.queue[this.uploader.queue.length - 1];
if (this.isMultiple()) {
// todo
this.element.nativeElement.value = '';
/*this.element.nativeElement