Bug 14632: Fix alert message for single item batch
authorIndranil Das Gupta <indradg@gmail.com>
Mon, 3 Aug 2015 04:27:53 +0000 (09:27 +0530)
committerLiz Rea <wizzyrea@gmail.com>
Thu, 10 Dec 2015 01:32:03 +0000 (14:32 +1300)
Fixes the incorrect msg "Please select at least label to delete."
for attempts to delete from single patron batches. Notifies the
user that doing so will delete the batch. It disallows direct
deletion, instead suggests the users to use the 'Delete batch'
option assuming the users know what they are doing.

Test plan
=========

1/ Load a single patron batch in edit mode and attempt to delete
   the single record. The JS alert message will inform that "Please
   select at least label to delete."
2/ Apply patch and refresh page and try to delete the single record
   again.
3/ This time the alert will inform the user that doing so will delete
   the batch and should that be desired action to choose the 'Delete
   batch' option from the toolbar.

Signed-off-by: Frederic Demians <f.demians@tamil.fr>
  It works as before but with an understantable warning message.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 85ae12e5864d8fd35f42a53c66440f00f7f4a35d)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
(cherry picked from commit a698cd39dba4595b9094c097db8d4108d11f1a4f)
Signed-off-by: Liz Rea <wizzyrea@gmail.com>

koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt

index ad4348a..a208633 100644 (file)
@@ -19,6 +19,7 @@
             function Remove() {
                 items = new Array;
                 item_num = new Array;
+
                 if(document.items.action.length > 0) {
                     for (var i=0; i < document.items.action.length; i++) {
                         if (document.items.action[i].checked) {
                             item_num.push(i+1);
                         }
                     }
-                    if (items.length < 1) {
-                        alert(_("Please select at least one item to delete."));
-                        return;     // no item selected
-                    }
                     getstr = items.join("&");
                     item_msg = item_num.join(", ");
                     var msg = _("Are you sure you want to remove card number(s): %s from this batch?").format(item_msg);
+                } else if (document.items.action.checked) {
+                    alert(_("Deletion of item from a batch with only one item will delete the batch.\n\nIf this is what you want, select 'Delete batch' option from toolbar"));
+                    return; // no deletion for single item batch
                 }
                 else {
-                    alert(_("Please select at least label to delete."));
+                    alert(_("Please select at least one patron to delete."));
                     return;     // no item selected
                 }
                 var answer = confirm(msg);