From c09e13cf82e05c937a7817b3dba55a280dec7416 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 23 Jan 2025 16:20:12 +0000
Subject: [PATCH] Bug 38958: Search history deletion broken in the staff
 interface
Content-Type: text/plain; charset=utf-8

There is some JS on the staff interface search history page which uses a
jQuery selector that doesn't seem to work after the DataTables upgrade.
This patch fixes it.

To test, apply the patch and enable EnableSearchHistory if necessary.

- In the staff interface, perform a few catalog searches if necessary.
- Choose "Search history" from the user menu in the upper right.
- In the table of searches, check the checkbox next to one or more
  search history entries.
- The delete button at the top of the table should become enabled.
- Clicking the delete button should work correctly to delete your
  selected searches.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 .../prog/en/modules/catalogue/search-history.tt           | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt
index 3c7e3449b5..2bb748d05c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt
@@ -248,7 +248,7 @@
                 .attr('action', form.attr('action'))
                 .attr('method', form.attr('method'));
             form.find('input[type="hidden"]')
-                .add(table.$('input:checkbox:checked'))
+                .add( $('input:checkbox:checked', table) )
                 .each(function() {
                     var input = $('<input type="hidden">')
                         .attr('name', $(this).attr('name'))
@@ -281,7 +281,7 @@
             e.preventDefault();
             var form = $(this).parents("form").first();
             var table = form.find('table').dataTable();
-            var ids = table.$("input:checkbox:checked");
+            var ids = $("input:checkbox:checked", table);
             if ( $(ids).length < 1 ) {
                 return false;
             }
@@ -306,8 +306,8 @@
 
     function enableCheckboxActions(form){
         // Enable/disable controls if checkboxes are checked
-        var table = form.find('table').dataTable();
-        var checked_count = table.$("input:checkbox:checked").length;
+        var table = form.find('table');
+        var checked_count = $("input:checkbox:checked", table).length;
         if (checked_count) {
           if (checked_count == 1) {
             form.find(".selections").html(_("With selected search: "));
-- 
2.39.5