Skip to content

[Dropzone] Enable multiple file uploads #512

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

Closed

Conversation

daFish
Copy link
Contributor

@daFish daFish commented Oct 24, 2022

Q A
Bug fix? no
New feature? yes
Tickets Fix #7
License MIT

This change adds the posibility to upload multiple files using the Dropzone component. This is based on the work by @yassinehamouten.

  • Tests
  • Make it configurable using the FormType

@daFish daFish force-pushed the feat/dropzone-support-multiple-files branch from e8a8a1e to 7105e52 Compare October 24, 2022 13:31
@daFish daFish marked this pull request as ready for review October 24, 2022 13:36
@daFish daFish marked this pull request as draft October 24, 2022 20:03
@daFish daFish force-pushed the feat/dropzone-support-multiple-files branch from 7105e52 to 05ffafc Compare October 25, 2022 06:56
@daFish daFish marked this pull request as ready for review October 25, 2022 06:57
@daFish
Copy link
Contributor Author

daFish commented Oct 25, 2022

@tgalopin & @weaverryan Would you mind to review this PR? 😄

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I have some questions - either we're not (yet) quite supporting the "preview" for multiple files, or I'm missing it!

Cheers :)

@@ -2,6 +2,7 @@
{%- set dataController = (attr['data-controller']|default('') ~ ' symfony--ux-dropzone--dropzone')|trim -%}
{%- set attr = attr|merge({ 'data-controller': '', class: (attr.class|default('') ~ ' dropzone-input')|trim}) -%}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but we can revert this change

}

this._dispatchEvent('dropzone:change', file);
this._dispatchEvent('dropzone:change', event.target.files);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not this in the CHANGELOG - that's a minor BC break.

@@ -42,31 +42,34 @@ export default class extends Controller {
this.previewImageTarget.style.display = 'none';
this.previewImageTarget.style.backgroundImage = 'none';
this.previewFilenameTarget.textContent = '';
document.querySelectorAll('.dropzone-preview-image-container').forEach((e) => e.remove());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm missing it, where/what is creating this .dropzone-preview-image-container element?


// Show the filename in preview
this.previewFilenameTarget.textContent = file.name;
this.previewTarget.style.display = 'flex';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried the code yet, but how does this work with multiple files? It looks like if I attach multiple files, only the last one's filename would show up (it would override the earlier ones). Or very possibly I am missing a detail :)

@daFish
Copy link
Contributor Author

daFish commented Nov 2, 2022

After a small conversation with @weaverryan on Slack I plan to add the following options to this component:

  • ability to specify the number of files
  • enable adding additional files after files were already dropped

@daFish daFish marked this pull request as draft December 8, 2022 18:19
@daFish daFish changed the title feat(dropzone): enable multiple file uploads [Dropzone] Enable multiple file uploads Dec 8, 2022
@daFish daFish force-pushed the feat/dropzone-support-multiple-files branch from 806cc8a to 3e47174 Compare January 26, 2023 10:44
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

I played with this locally, but it doesn't look like multiple previews show up - just the one. Is that my mistake? Or do we still need a good deal more work - like to have potentially multiple "preview" areas instead of just one?

Thanks!

numberOfFiles: Number
}

readonly numberOfFilesValue: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already removed.

@@ -2,6 +2,7 @@
{%- set dataController = (attr['data-controller']|default('') ~ ' symfony--ux-dropzone--dropzone')|trim -%}
{%- set attr = attr|merge({ 'data-controller': '', class: (attr.class|default('') ~ ' dropzone-input')|trim}) -%}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -28,6 +28,7 @@ public function configureOptions(OptionsResolver $resolver)
'attr' => [
'placeholder' => 'Drag and drop or browse',
],
'multiple' => false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that needed? It's already the default of the parent type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has been removed.

@kristjan-kure
Copy link

Hi! We need multiple file upload. Who can help with this? I understand daFish has been developing it, but we need it live? Who on the Symfony development team can help us to work with this?

@daFish
Copy link
Contributor Author

daFish commented Apr 11, 2023

After some thoughts I'm not going to finish this. It is based upon the work of @yassinehamouten and I'd rather propose to go with uppy.io.

@daFish daFish closed this Apr 11, 2023
@daFish daFish deleted the feat/dropzone-support-multiple-files branch April 11, 2023 15:49
@simonsolutions
Copy link
Contributor

sorry to pick up on the old PR. But the above mentioned missing preview on more than one file seems still not to be working. I tried the current version of UX Dropzone, the multiple in the form element works. It accepts multiple files and posts them along with the form. But the preview of more than one file and the capability of adding more files seems also be missing.

Is there any trick i am missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dropzone: handle multiple files
4 participants