From 8326b7a5023ccd36a1d4f956bfe72da5620e3de3 Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
Date: Wed, 24 Aug 2016 01:08:11 +0000
Subject: [PATCH] [SIGNED-OFF] Bug 15711: Fixing the 'Delete selected' button
 on patroncard images
Content-Type: text/plain; charset="utf-8"

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 <mtompset@hotmail.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
---
 .../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 17387bd..f3e8430 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
@@ -5,17 +5,19 @@
         //<![CDATA[
             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;
@@ -25,16 +27,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.1.4