From bcd90920fae5c1262eab189a51efcc6b57c3bf23 Mon Sep 17 00:00:00 2001 From: humancopy Date: Mon, 24 Jul 2017 04:21:43 +0300 Subject: [PATCH] Fix non working remove event and add missing removeAll (#313) * Remove should be on this.files and not this.uploads * Add the missing input event removeAll --- src/ngx-uploader/classes/ngx-uploader.class.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index 627b770a..6a35e219 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -35,7 +35,7 @@ export interface UploadFile { } export interface UploadOutput { - type: 'addedToQueue' | 'allAddedToQueue' | 'uploading' | 'done' | 'removed' | 'start' | 'cancelled' | 'dragOver' | 'dragOut' | 'drop' | 'removed'; + type: 'addedToQueue' | 'allAddedToQueue' | 'uploading' | 'done' | 'start' | 'cancelled' | 'dragOver' | 'dragOut' | 'drop' | 'removed' | 'removedAll'; file?: UploadFile; nativeFile?: File; } @@ -157,13 +157,19 @@ export class NgUploaderService { return; } - const i = this.uploads.findIndex(upload => upload.file.id === event.id); + const i = this.files.findIndex(file => file.id === event.id); if (i !== -1) { - const file = this.uploads[i].file; - this.uploads.splice(i, 1); + const file = this.files[i]; + this.files.splice(i, 1); this.serviceEvents.emit({ type: 'removed', file: file }); } break; + case 'removeAll': + if (this.files.length) { + this.files = []; + this.serviceEvents.emit({ type: 'removedAll' }); + } + break; } }); }