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 <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2024-02-23 13:15:39 +00:00 committed by Jonathan Druart
parent a482208f09
commit 7798f0346c
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0
2 changed files with 4 additions and 14 deletions

View file

@ -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 = '<input type="hidden" name="recordtype" value="biblio" /><input type="hidden" name="op" value="cud-list" />';
/* Get token from parent window */
csrf = window.opener.document.querySelectorAll('[name="csrf_token"]');
f.append( csrf[0] );
f.innerHTML += '<input type="hidden" name="csrf_token" value="' + $('meta[name="csrf-token"]').attr('content').trim() + '" />';
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();

View file

@ -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') ) {