Skip to content

Conversation

@adlius
Copy link
Collaborator

@adlius adlius commented Jan 19, 2018

Purpose

Currently for quickfiles, uploading multiple files by drag'n'drop is not allowed and would show "Cannot upload multiple files". However, this is not the case when user clicks the "upload" button and select multiple files to upload. This PR fix this problem by not allowing users to select multiple files for upload.

Summary of Changes

Dropzone.js handles drag'n'drop upload differently than clicking the "upload" button for upload. Therefore, there is not an event handler that we can override to prevent multiple uploads through clicking the "upload" button. However, we could remove the "multiple" attribute from the hidden <input> element Dropzone uses, thus preventing users from selecting multiple files. And that is what is done in this PR.

Side Effects / Testing Notes

None.

Ticket

https://openscience.atlassian.net/browse/EMB-60

Reviewer Checklist

  • meets requirements
  • easy to understand
  • DRY
  • testable and includes test(s)
  • changes described in CHANGELOG.md

Copy link
Member

@jamescdavis jamescdavis left a comment

Choose a reason for hiding this comment

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

See comments, and also, please update CHANGELOG

// Therefore, we remove the "multiple" attribute for the hidden file input element, so that users cannot select
// multiple files for upload in the first place.
let clickableElement = this.get('clickable');
if (this.options && this.options.preventMultipleFiles && clickableElement){
Copy link
Member

Choose a reason for hiding this comment

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

Should use this.get() e.g. this.get('options.preventMultipleFiles')

Copy link
Member

Choose a reason for hiding this comment

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

if (this.get('options.preventMultipleFiles') && this.get('clickableElement')) {

// Dropzone.js does not have an option for disabling selecting multiple files when clicking the "upload" button.
// Therefore, we remove the "multiple" attribute for the hidden file input element, so that users cannot select
// multiple files for upload in the first place.
let clickableElement = this.get('clickable');
Copy link
Member

Choose a reason for hiding this comment

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

This variable is only used once and is probably not necessary.

@jamescdavis
Copy link
Member

@jamescdavis jamescdavis merged commit aece5ff into CenterForOpenScience:develop Jan 26, 2018
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.

2 participants