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

Multiple files vs single files #3

Open
Neobii opened this issue Jul 20, 2016 · 9 comments
Open

Multiple files vs single files #3

Neobii opened this issue Jul 20, 2016 · 9 comments

Comments

@Neobii
Copy link

Neobii commented Jul 20, 2016

No description provided.

@dr-dimitru dr-dimitru added this to the v1.0.0 milestone Jul 24, 2016
@dr-dimitru dr-dimitru removed this from the v1.1.0 milestone Mar 2, 2018
@jankapunkt
Copy link
Collaborator

There is a new development branch called multifile on which the multiple files upload has been implemented.

!!! Note, that the feature under construction and should not be used in production until review is finished and merged to master.

In order to allow multiple uploads you have to (switch to the branch, of course and) define the scheme in the following way:

new SimpleSchema({
  pictures: {
    type: Array,
    optional: true,
  },
  'pictures.$': {
    type: String,
    optional: true,
    label: false,
    autoform: {
      afFieldInput: {
        type: 'fileUpload',
        collection: 'Images',
        multiple: "multiple",
        // uploadTemplate: 'uploadField', // <- not working with custom templates yet!
        // previewTemplate: 'uploadPreview' // <- Optional
      }
    }
  }
}, {tracker: Tracker})

And create a quickForm like so:

{{> quickForm schema=multipleSchema id="uploadImages" type="normal" }}

Where multipleSchema is a helper which returns the above declared schema.

It uses a queue of files as Reactive variable outside of the template instances, so it is accessible on each file input field.

If the user selects multiple files the queue will be filled and the field templates will each fetch a file to upload.

If a single file is selected, the old behavior is executed (immediately upload the file).

A good extension would be to make the queue-ing accessible to custom templates or document for custom templates how to realize multiple uploads.

@mishantidev
Copy link

I added this two specified schema fields to my existent schema, and here is my form tag:
quickForm collection=productsCollection doc=product id="updateProductForm" type="update"

However, delete button doesn't delete fields from array, preview doesn't works right as well, showing same image for different objects!

Also, if afFieldType is 'fileUpload', why there is mention of non-existent template 'fileUploads' in autoform.js? Is it just an unfinished and not working properly prototype?

@jankapunkt
Copy link
Collaborator

Thanks a lot for the investigation. I will look into it and update the branch accordingly.

@jankapunkt
Copy link
Collaborator

I added this two specified schema fields to my existent schema, and here is my form tag:
quickForm collection=productsCollection doc=product id="updateProductForm" type="update"

However, delete button doesn't delete fields from array, preview doesn't works right as well, showing same image for different objects!

I have created an experimental repo, which we can use as foundation for discussion: https://github.com/jankapunkt/meteor-autoform-multiles-example

Can you confirm, that the unwanted behavior also appears there?

(P.s. you need to clone this repo into a packages folder, since I wanted to avoid the submodules-mess)

Also, if afFieldType is 'fileUpload', why there is mention of non-existent template 'fileUploads' in autoform.js? Is it just an unfinished and not working properly prototype?

This dead reference is to be removed just now, thank you.

@jankapunkt
Copy link
Collaborator

@anjunatic did you check into the repo?

@jankapunkt
Copy link
Collaborator

@dr-dimitru did you have time to check into the repo? If you like it, I would make it a bit more robust and create a PR for review.

@jankapunkt
Copy link
Collaborator

Please keep open, new PR coming in within the next days.

@dr-dimitru
Copy link
Member

@jankapunkt 10.4

@jankapunkt jankapunkt mentioned this issue Feb 28, 2020
8 tasks
@jankapunkt
Copy link
Collaborator

There is a new updated PR in this feature: #58

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

Successfully merging a pull request may close this issue.

4 participants