marinosoftware / active_storage_drag_and_drop

Provides a form helper to make it easy to make drag-and-drop file upload fields that work with Rails' Active Storage.
MIT License
92 stars 14 forks source link

Customizing The Drag and Drop Pending Upload Form Documentation Update #5

Open iarobinson opened 5 years ago

iarobinson commented 5 years ago
Screen Shot 2019-06-13 at 12 26 30 PM

If you can provide insight for me on this, I'd be happy to create a PR with updated documentation.

IanGrantMarino commented 5 years ago

Hi Ian,

A PR for a better example here would be much appreciated! That's not a great example as it's just the default implementation. To override it you have to redefine window.ActiveStorageDragAndDrop.paintUploadIcon so here's a very quick and dirty example that you should be able to put in your JavaScript bundle:

window.ActiveStorageDragAndDrop.paintUploadIcon = function (iconContainer, id, file, complete) {'
  iconContainer.insertAdjacentHTML('afterbegin', `
    <div data-direct-upload-id="${id}">
    </div>
  `)
}

It should replace the upload icon with an empty div. If it isn't working for you or you need a more complete example let me know.

philsmy commented 4 years ago

Sorry to 'me too' this, but I also would like some sort of working example on how to override the upload view. I couldn't get what you pasted in here to work...perhaps there are some punctuation issues? but I get an error on the page.

new:253 Uncaught TypeError: Cannot set property 'paintUploadIcon' of undefined

I am putting that on a page after

import ActiveStorageDragAndDrop from 'active_storage_drag_and_drop'

ActiveStorageDragAndDrop.start()

would have been called.