Bug 40061: (follow-up) Delete last image using checkbox

This followup corrects a problem in image deletion which isn't really
the same issue (it's not CSRF related) but is another problem with
deletion. The JS for grabbing all the checkboxes by name wasn't working
when there is only one checkbox.

To test, apply the patch and delete all but one image from the patron
card creator image manager.

- Check the checkbox for the last image and click the "Delete selected"
  button.
- The image should be deleted successfully.

Sponsored-by: Athens County Public Libraries
Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 727b9d2dde)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
(cherry picked from commit d99a9e28b6)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
This commit is contained in:
Owen Leonard 2025-06-04 18:16:44 +00:00 committed by Baptiste Wojtkowski
parent 2a76813844
commit ffe35288ce
No known key found for this signature in database
GPG Key ID: 47A8A13E10BC0D40
1 changed files with 6 additions and 5 deletions

View File

@ -194,11 +194,12 @@
}
function selected_images() {
var image_ids = new Array;
if (document.delete_images.image_id.length) {
for (i=0;i<document.delete_images.image_id.length;i++){
if (document.delete_images.image_id[i].checked){
image_ids.push(document.delete_images.image_id[i].value);
var image_ids = new Array();
let checkboxes = document.getElementsByName("image_id");
if (checkboxes.length) {
for (i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
image_ids.push(checkboxes[i].value);
}
}
}