django-material-admin icon indicating copy to clipboard operation
django-material-admin copied to clipboard

Input select-accross is not in action form

Open dco5 opened this issue 4 years ago • 3 comments

This input is not inside the changelist-form so when you click on select all items in the list and then select an action, the action is only applying to the 10 items displayed on the page. <input type="hidden" name="select_across" value="1" class="select-across">

dco5 avatar Aug 18 '21 20:08 dco5

Hi, any workaround for this?

julhernandezv avatar Jan 25 '22 03:01 julhernandezv

I did something kind of hacky to fix it. I overrode admin/base_site.html and in the footer section I added my own javascript to fix it.

$(document).on('click', '.question', function () {
    $("#changelist-form").append('<input type="hidden" name="select_across" value="1" class="select-across">');
    let clearButton = document.querySelectorAll('.card-content span.clear')[0];
    clearButton.style = "display: inline;"
})


$(document).on('click', '.card-content span.clear a', function () {
    let clearButton = document.querySelectorAll('.card-content span.clear')[0];
    clearButton.style = "display: none;"
})

dco5 avatar Jan 25 '22 04:01 dco5

You can also just edit/override the template actions.html and add "display: none;" to the proper span tags. No JS required. Page should initially load with display set to none anyway but seems it was forgotten.

Also for input select_across. you can also just add the form attribute and give it the value "changelist-form" This will pass select_across into your request.POST

herrrta avatar Jan 25 '22 19:01 herrrta