Streamline bulk actions use of dynamic links to use HTML instead of JavaScript #11770
Labels
Accessibility
component:Bulk Actions
javascript
Pull requests that update Javascript code
status:Needs Design Decision
type:Enhancement
Is your proposal related to a problem?
We currently have a large amount of JavaScript in the bulk actions code that does the following;
Some of the code that does this.
wagtail/client/src/includes/bulk-actions.js
Lines 177 to 194 in dae51e1
This JavaScript could very likely be completely removed by using a HTML only approach.
Describe the solution you'd like
form
element and setting the checkboxinput
name & value attributes correctly negates the need for tracking the id withdata-object-id
.a
element, we could usebutton
and then target the form with theform="..."
attribute. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#formbutton
elements can direct the action to a custom base URL by setting theformaction
attribute. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#formactionnext
URL value can be declared with a hidden input that associates to the same form.button
can be changed to aninput
with alabel
and have the name 'all' and the value would be determined on clicking.childOf
value could be a simple hidden input that gets created when theparent
exists, the bulk actions response can conditionally handle this whenall
is selected. By the looks of things, this is current behaviour so no change needed to thewagtail/admin/views/bulk_action/base_bulk_action.py
code.While this seems like a lot it will mean that we can pull out a lot of JavaScript code and replace it with simpler semantic HTML that has the following benefits;
button
elements, nota
elements.a
link behaviour.input
in the template, no complex code overrides needed (likely it's not even possible to do this today).Potential approach
wagtail/admin/templates/wagtailadmin/bulk_actions/footer.html
.bulk_action_choices
template tag and own that same responsibility of preparing the actions. It would need to accept a param for theform
id to attach the inputs to.wagtail/admin/templates/wagtailadmin/shared/button.html
to render an actualbutton
element (conditionally) or maybe we make two; one for links and one for buttons. Thebutton
variation would need to render the url as theformaction
attribute and then pull in aform_id
value to render. OR we can just leverage theattrs
for this approach.input
for thenext
value and we can pull out the appending of the URL?next=...
in the template tag.Describe alternatives you've considered
Additional context
Working on this
form
andinput
/button
interaction works, additionally some solid understanding of Django template tags would be required.The text was updated successfully, but these errors were encountered: