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
Use FormData for docs/images add-multiple's edit handling #8315
Use FormData for docs/images add-multiple's edit handling #8315
Conversation
Manage this branch in SquashTest this branch here: https://th3hamm0rfeatureuse-multipart-sub0n.squash.io |
In the hope for a faster review, maybe this helps: wagtail/client/src/entrypoints/images/image-chooser-modal.js Lines 6 to 45 in e4d563e
|
In principle this look good, why the change to I will try to do some testing locally and get this approved. Thanks for the explanation. |
No, there is no obvious reason. First I wanted to keep it in sync with the very similar code for the modals, and second, from my experience with jquery and the task to reduce its usage where possible, only using
Nice, thanks! |
As I understand it, (Haven't tested to confirm that - I just happened to be refactoring the chooser modal JS yesterday and was wondering why it used the long-winded |
Thanks, that makes sense. |
The ajax-request now uses multipart/form-data, similar to image-chooser-modal.js/document-chooser-modal.js, which allows to add and use FileFields in the bulk-upload-views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, put it through a bunch of scenarios and cannot see any issues.
Thanks for the explanation @th3hamm0r
Tested
- after upload of images/docs - trigger a server side error
- after upload of images/docs - delete the item & ensure it is not saved
- after upload of images/docs - trigger a success save (should hide and changes be made)
- test bad upload on drop - not part of this change but ensure it does not try to grab content that is not there (no form)
b2895ef
to
da19967
Compare
pushed up a rebase, with prettier formatting (added after this PR was created) + changelog. |
The ajax-request now uses multipart/form-data, similar to
image-chooser-modal.js
/document-chooser-modal.js
, which allows to add and useFileFields
in the bulk-upload-views.This PR is a bit related to #8314, because we needed an additional
FileField
for our images, where the user can attach a license proof in some cases (depends on other custom fields and validation).This works in the image chooser, but did not work in the bulk-upload-tool (
add-multiple.js
), because those file-inputs have not been transferred to the backend with jquery's.serialize()
.So as a quickfix, we had to customize/patch
get_image_multi_form()
, to exclude the license proof for now, but to allow customizations in a clean way, I've created #8314.Please check the following:
make lint
from the Wagtail root.Google Chrome 100.0.4896.75, Firefox 99.0 (both on Linux Mint/Ubuntu)
Please describe additional details for testing this change.
Footnotes
Development Testing ↩
Browser and device support ↩
Accessibility Target ↩