Bug 26159: Remove the use of jquery.checkboxes plugin from batch record delete page
authorOwen Leonard <oleonard@myacpl.org>
Thu, 6 Aug 2020 11:42:33 +0000 (11:42 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 18 Aug 2020 13:45:49 +0000 (15:45 +0200)
This patch removes the use of the jquery.checkboxes plugin from the
batch delete records page.

To test, apply the patch and go to Tools ->  Batch record deletion.

 - Submit a batch of biblionumbers which includes one or more
   checked-out items, one or more on-hold items, and one or more records
   with no items.
 - On the confirmation page, test the selection links at the top of the
   results table. Each one should work correctly.
 - Submit a batch of authority record ids which includes some records
   which are in use and some which aren't.
 - On the confirmation page, test the selection links at the top of the
   results table. Each one should work correctly.

Signed-off-by: Amit Gupta <amit.gupta@informaticsglobal.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt

index 4e1bead..8889b15 100644 (file)
 [% MACRO jsinclude BLOCK %]
     [% Asset.js("js/tools-menu.js") | $raw %]
     [% INCLUDE 'datatables.inc' %]
-    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
     <script>
         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
         $(document).ready(function() {
               $("#show_list_option").show();
             }
           });
-          $("#selectall").click(function(e){
-            e.preventDefault();
-            $(".records").checkCheckboxes(":input[type='checkbox']:not(:disabled)");
-          });
-          $("#clearall").click(function(e){
-            e.preventDefault();
-            $(".records").unCheckCheckboxes(":input[type='checkbox']:not(:disabled)");
-          });
-          $("#selectwithoutitems").click(function(e){
-            e.preventDefault();
-            $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
-          });
-          $("#selectnotreserved").click(function(e){
-            e.preventDefault();
-            $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
+            $("#selectall").click(function(e){
+                e.preventDefault();
+                $(".records input[type='checkbox']:not(:disabled)").each(function(){
+                    $(this).prop("checked", true);
+                });
+            });
+
+            $("#clearall").click(function(e){
+                e.preventDefault();
+                $(".records input[type='checkbox']:not(:disabled)").each(function(){
+                    $(this).prop("checked", false);
+                });
+            });
+
+            $("#selectwithoutitems").click(function(e){
+                e.preventDefault();
+                $(".records input[type='checkbox']:not(:disabled)").each(function(){
+                    if( $(this).data("items") == 0 ){
+                        $(this).prop("checked", true );
+                    } else {
+                        $(this).prop("checked", false );
+                    }
+                });
+            });
+
+            $("#selectnotreserved").click(function(e){
+                e.preventDefault();
+                $(".records input[type='checkbox']:not(:disabled)").each(function(){
+                    if( $(this).data("reserves") == 0 ){
+                        $(this).prop("checked", true );
+                    } else {
+                        $(this).prop("checked", false );
+                    }
+                });
+            });
+
+            $("#clearlinkedtobiblio").click(function(e){
+                e.preventDefault();
+                $(".records input[type='checkbox']:not(:disabled)").each(function(){
+                    if( $(this).data("usage") == 0 ){
+                        $(this).prop("checked", true );
+                    } else {
+                        $(this).prop("checked", false );
+                    }
+                });
+            });
 
-          });
-          $("#clearlinkedtobiblio").click(function(e){
-            e.preventDefault();
-            $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
-          });
           $("#selectall").click();
 
           [% IF recordtype == 'biblio' %]