From 7798f0346cb505bcaf50ae4413f8330e57b056bc Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 23 Feb 2024 13:15:39 +0000 Subject: [PATCH] Bug 34478: SQUASH Follow-up to previous batch operations patches - Get the CSRF token from the pop-up instead of from the parent window, since that seems to work - Remove some click handlers which were made obsolete Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/js/cart.js | 16 +++------------- tools/batch_record_modification.pl | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cart.js b/koha-tmpl/intranet-tmpl/prog/js/cart.js index 9b95c0f06e..0514331af7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cart.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cart.js @@ -28,7 +28,8 @@ function resultsBatchProcess( op ){ alert( __("No item was selected") ); return false; } else { - /* form markup for batch edit or delete operations */ + /* Dynamically create a form in the parent window so that */ + /* the form submission will redirect in the expected way */ let params = []; const body = window.opener.document.getElementsByTagName("body"); let f = document.createElement("form"); @@ -41,9 +42,7 @@ function resultsBatchProcess( op ){ f.setAttribute("action", "/cgi-bin/koha/tools/batch_delete_records.pl"); } f.innerHTML = ''; - /* Get token from parent window */ - csrf = window.opener.document.querySelectorAll('[name="csrf_token"]'); - f.append( csrf[0] ); + f.innerHTML += ''; let textarea = document.createElement("textarea"); textarea.setAttribute("name", "bib_list"); textarea.setAttribute("style", "display:none"); @@ -104,15 +103,6 @@ $(document).ready(function(){ } }); - $("#batch_modify").on("click",function(e){ - e.preventDefault(); - batchModify(); - }); - $("#batch_delete").on("click",function(e){ - e.preventDefault(); - batchDelete(); - }); - $("#remove_from_cart").on("click",function(e){ e.preventDefault(); delSelRecords(); diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl index ec3b339e40..b89f67294e 100755 --- a/tools/batch_record_modification.pl +++ b/tools/batch_record_modification.pl @@ -89,7 +89,7 @@ if ( $op eq 'form' ) { ] ) ); -} elsif ( $op eq 'list' ) { +} elsif ( $op eq 'cud-list' ) { # List all records to process my ( @records, @record_ids ); if ( my $bib_list = $input->param('bib_list') ) { -- 2.39.5