From d93d566e949c3984224941b221e2b385a2c12d99 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Wed, 5 Aug 2020 18:53:46 +0000
Subject: [PATCH] Bug 26154: Remove the use of jquery.checkboxes plugin from
 batch item deletion and modification

This patch removes the use of the jquery.checkboxes plugin from the
batch item modification and batch item deletion pages.

To test, apply the patch and go to Tools -> Batch item
modification.

 - Submit a batch of barcodes.
 - On the results page, test the "Select all" and "Clear all" controls
   at the top of the page. These should work correctly on the checkboxes
   in the table of results.
 - Test that the "Clear on loan" control still works to uncheck
   checkboxes corresponding to items which are checked out.
 - Test the "Show all columns" and "Hide all columns" checkboxes in the
   "Show/hide columns" section. These should work correctly on the
   checkboxes for showing and hiding columns in the table.
 - Go to Tools -> Batch item deletion.
 - Submit a batch of barcodes.
 - Repeat the same testing steps above (except the "Clear on loan"
   step).
---
 .../prog/en/modules/tools/batchMod-del.tt          |  1 -
 .../prog/en/modules/tools/batchMod-edit.tt         |  1 -
 koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js  | 24 ++++++++++++++--------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
index 8f99122e19..c765db5adf 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
@@ -298,7 +298,6 @@
     [% Asset.js("js/tools-menu.js") | $raw %]
     [% INCLUDE 'datatables.inc' %]
     [% Asset.js("js/pages/batchMod.js") | $raw %]
-    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
     [% Asset.js("js/browser.js") | $raw %]
     <script type="text/javascript">
         // Prepare array of all column headers, incrementing each index by
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
index a0c8c83168..5228d77f31 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
@@ -8,7 +8,6 @@
 [% Asset.js("js/background-job-progressbar.js") | $raw %]
 [% Asset.js("js/cataloging.js") | $raw %]
 [% INCLUDE 'datatables.inc' %]
-[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
 [% Asset.js("js/pages/batchMod.js") | $raw %]
 <script type="text/javascript">
 //<![CDATA[
diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js
index c20a415eb1..4d15973fd1 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js
@@ -80,14 +80,18 @@ function showColumn(num){
   }
 }
 function showAllColumns(){
-    $("#selections").checkCheckboxes();
+    $("#selections input:checkbox").each(function(){
+        $(this).prop("checked", true);
+    });
     $("#selections span").addClass("selected");
     $("#itemst td:nth-child(3),#itemst tr th:nth-child(3)").nextAll().show();
     $.removeCookie("showColumns", { path: '/' });
     $("#hideall").prop("checked", false).parent().removeClass("selected");
 }
 function hideAllColumns(){
-    $("#selections").unCheckCheckboxes();
+    $("#selections input:checkbox").each(function(){
+        $(this).prop("checked", false);
+    });
     $("#selections span").removeClass("selected");
     $("#itemst td:nth-child(3),#itemst th:nth-child(3)").nextAll().hide();
     $("#hideall").prop("checked", true).parent().addClass("selected");
@@ -105,13 +109,17 @@ function hideAllColumns(){
         ],
         "bPaginate": false,
     }));
-    $("#selectallbutton").click(function(){
-      $("#itemst").checkCheckboxes();
-      return false;
+    $("#selectallbutton").click(function(e){
+        e.preventDefault();
+        $("#itemst input:checkbox").each(function(){
+            $(this).prop("checked", true);
+        });
     });
-    $("#clearallbutton").click(function(){
-      $("#itemst").unCheckCheckboxes();
-      return false;
+    $("#clearallbutton").click(function(e){
+        e.preventDefault();
+        $("#itemst input:checkbox").each(function(){
+            $(this).prop("checked", false);
+        });
     });
     $("#clearonloanbutton").click(function(){
       $("#itemst input[name='itemnumber'][data-is-onloan='1']").each(function(){
-- 
2.11.0