Skip to content

Commit

Permalink
added upload started and finished events (#5)
Browse files Browse the repository at this point in the history
* added upload started and finished events to make it easy to deal with upload progress from outside the component.

* added $wireModelAttribute as an extra value sent with the event.

* added filepond-upload-reverted and filepond-upload-file-removed event.

* fixed a typo in dispatch of filepond-upload-finished event.
  • Loading branch information
abdelhamiderrahmouni authored Sep 20, 2024
1 parent 7a5c33b commit 1efc147
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions resources/views/upload.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,22 @@ class="{{ $attributes->get('class') }}"
pond.setOptions({
allowMultiple: isMultiple,
server: {
process: (fieldName, file, metadata, load, error, progress) => {
@this.upload('{{ $wireModelAttribute }}', file, load, error, progress);
process: async (fieldName, file, metadata, load, error, progress) => {
$dispatch('filepond-upload-started', '{{ $wireModelAttribute }}');
await @this.upload('{{ $wireModelAttribute }}', file, (response) => {
load(response);
$dispatch('filepond-upload-finished', {'{{ $wireModelAttribute }}': response });
}, error, progress);
},
revert: (filename, load) => {
@this.revert('{{ $wireModelAttribute }}', filename, load);
revert: async (filename, load) => {
await @this.revert('{{ $wireModelAttribute }}', filename, load);
$dispatch('filepond-upload-reverted', '{{ $wireModelAttribute }}');
},
remove: (file, load) => {
console.log(file);
@this.remove('{{ $wireModelAttribute }}', file.name);
remove: async (file, load) => {
console.log(file);
await @this.remove('{{ $wireModelAttribute }}', file.name);
load();
$dispatch('filepond-upload-file-removed', '{{ $wireModelAttribute }}');
},
},
required: @js($required),
Expand Down

0 comments on commit 1efc147

Please sign in to comment.