Skip to content

Commit

Permalink
Fix non working remove event and add missing removeAll (bleenco#313)
Browse files Browse the repository at this point in the history
* Remove should be on this.files and not this.uploads

* Add the missing input event removeAll
  • Loading branch information
humancopy authored and jkuri committed Jul 24, 2017
1 parent 8580044 commit bcd9092
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ngx-uploader/classes/ngx-uploader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
});
}
Expand Down

0 comments on commit bcd9092

Please sign in to comment.