Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1013 Add remove event to FileUpload #1047

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/fileupload/FileUpload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare class FileUpload {
$emit(eventName: 'error', e: { originalEvent: Event, files: any }): this;
$emit(eventName: 'before-send', e: { xhr: XMLHttpRequest, formData: any }): this;
$emit(eventName: 'clear'): this;
$emit(eventName: 'remove', e: { originalEvent: Event, file: any }): this;
}

export default FileUpload;
3 changes: 2 additions & 1 deletion src/components/fileupload/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {DomHandler} from 'primevue/utils';
import Ripple from 'primevue/ripple';

export default {
emits: ['select', 'uploader', 'before-upload', 'progress', 'upload', 'error', 'before-send', 'clear'],
emits: ['select', 'uploader', 'before-upload', 'progress', 'upload', 'error', 'before-send', 'clear', 'remove'],
props: {
name: {
type: String,
Expand Down Expand Up @@ -322,6 +322,7 @@ export default {
},
remove(index) {
this.clearInputElement();
this.$emit('remove', {originalEvent: event, file: this.files[index]});
this.files.splice(index, 1);
this.files = [...this.files];
},
Expand Down
8 changes: 7 additions & 1 deletion src/views/fileupload/FileUploadDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,17 @@ myUploader(event) {
event.progress: Calculated progress value.</td>
<td>Callback to invoke when files are selected.</td>
</tr>
<tr>
<tr>
<td>uploader</td>
<td>event.files: List of selected files.</td>
<td>Callback to invoke to implement a custom upload.</td>
</tr>
<tr>
<td>remove</td>
<td>event.originalEvent: Original browser event. <br />
event.file: Selected file.</td>
<td>Callback to invoke when a file is removed without uploading using clear button of a file.</td>
</tr>
</tbody>
</table>
</div>
Expand Down