From becf8e946600d2d40c974fb5d36fdd7bc92e3e0a Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 24 Aug 2016 01:08:11 +0000 Subject: [PATCH] Bug 15711: Fixing the 'Delete selected' button on patroncard images To test: 1) Go to Tools -> Patron Card Creator -> Manage images 2) Upload an image if you haven't already 3) Click Delete selected without selecting any images 4) Notice broken behaviour as described in Description 5) Apply patch, refresh page 6) Click Delete selected without selecting any images 7) Notice alert. Click OK 8) Select one image or more, click Delete selected 9) Notice confirm delete message. Sponsored-by: Catalyst IT Signed-off-by: Mark Tompsett Signed-off-by: Owen Leonard Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit bd3879e037727cdc2cc851aa910c68bd257ee6f4) Signed-off-by: Katrin Fischer (cherry picked from commit 70c55a6d69d68e04b50e8fbcf0eb7e62457350d7) Signed-off-by: Julian Maurice --- .../prog/en/modules/patroncards/image-manage.tt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt index 0dd477fe50..d54ef107e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt @@ -6,17 +6,19 @@ var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this image?"); function DeleteConfirm() { var results = selected_images("delete"); - if (results.images != -1) { + if (results.images) { var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids); var answer = confirm(msg); if (answer) { window.location = "/cgi-bin/koha/patroncards/image-manage.pl?op=delete&" + results.images; - } - else { + } else { return; // abort delete } + } else { + alert(_("Please select image(s) to delete.")); } - }; + } + function selected_images(op) { var selected = new Array; var image_ids = new Array; @@ -26,16 +28,15 @@ selected.push("image_id=" + document.delete_images.action[i].value); image_ids.push(document.delete_images.action[i].value); } - }; + } images = selected.join("&"); return {images:images, image_ids:image_ids}; } else if (document.delete_images.action.checked){ return {images:"batch_id="+document.delete_images.action.value, image_ids:document.delete_images.action.value}; - }; - alert(_("Please select image(s) to %s.").format(op)); + } return (-1); - }; + } $(document).ready(function() { $("#delete").click(function(){ return DeleteConfirm(); -- 2.39.5