From c86b2596f3216067747c78a4c94829509453a748 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 27 Aug 2021 16:06:02 +0000
Subject: [PATCH] Bug 18747: Select All in Add Patron Option in Patron Lists
 only selects the first 20 entries
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch corrects the JavaScript functions for the "select all" and
"clear all" action when viewing patrons in a list. Before this
correction, checkboxes which were previously in hidden table rows would
not be checked.

To test, apply the patch and go to Patrons -> Patron Lists

- View a patron list
- If necessary, add multiple patrons to the list so that the number
  exceeds 20.
- Change the number of entries shown by the DataTable: Show [ 50 ]
  entries.
- Click "Select all." All visible checkboxes should be checked.
- Click "Clear all." All checkboxes should be unchecked.

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
---
 .../intranet-tmpl/prog/en/modules/patron_lists/list.tt | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
index 5c8eb678ba..a9f74cf211 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
@@ -219,17 +219,15 @@
                 patron_input_name: 'patrons_to_add'
             });
 
-            var checkBoxes = $("input[type='checkbox']","#patron-list-table");
-
-            $("#CheckAll").click(function(e){
+            $("body").on("click", "#CheckAll", function(e){
                 e.preventDefault();
-                checkBoxes.each(function(){
+                $("input[type='checkbox']","#patron-list-table").each(function(){
                     $(this).prop("checked",1);
                 });
             });
-            $("#CheckNone").click(function(e){
+            $("body").on("click", "#CheckNone", function(e){
                 e.preventDefault();
-                checkBoxes.each(function(){
+                $("input[type='checkbox']","#patron-list-table").each(function(){
                     $(this).prop("checked",0);
                 });
             });
-- 
2.20.1