Bug 42278: Tidy all script tags - circ

In order to tidy all the script tags of the .tt files we isolate the
interpolation of Template::Toolkit variables in a separate script tag.

This patch focuses on the circulation module.

The 4 main changes are in the following files:
* circulation.tt
As expected this one is messy to test, we need to look at the diff and
make sure the different features linked with the variables moved at
still working correctly (yes, it's vague!)
* circulation_batch_checkouts.tt
On the batch checkout table the due date hidden input should have the
value of the return date high demand items.
* overdue.tt
On the overdue report view, the "Return claims" column must be hidden if
ClaimReturnedLostValue is not set.
* transfers_to_send.tt
The transfers to send view should show all libraries

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-03-30 09:51:06 +02:00 committed by Pedro Amorim
parent acfd02af12
commit 650a8d8a64
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
15 changed files with 82 additions and 66 deletions

View File

@ -523,7 +523,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let requested_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'article-requests', 'article-requests-requested-table', 'json' ) | $raw %]
let pending_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'article-requests', 'article-requests-pending-table', 'json' ) | $raw %]
let processing_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'article-requests', 'article-requests-processing-table', 'json' ) | $raw %]

View File

@ -301,7 +301,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'transfers', 'transferstable', 'json' ) | $raw %]
var found = [% found ? 1 : 0 | html %];
</script>

View File

@ -1128,7 +1128,7 @@
[% PROCESS 'modal-claims.inc' %]
[% PROCESS 'modal-claims-js' %]
[% INCLUDE 'js-date-format.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
/* Set some variable needed in circulation.js */
const LoadCheckoutsTableDelay = [% Koha.Preference('LoadCheckoutsTableDelay') || 0 | html %];
const AlwaysLoadCheckoutsTable = [% Koha.Preference('AlwaysLoadCheckoutsTable') | html %];
@ -1153,6 +1153,29 @@
[% END %]
var SuspendHoldsIntranet = [% ( Koha.Preference('SuspendHoldsIntranet') ) ? 1 : 0 | html %];
var DisplayAddHoldGroups = [% ( Koha.Preference('DisplayAddHoldGroups') ) ? 1 : 0 | html %];
Koha.addPrefs({
OnSiteCheckoutAutoCheck: [% Koha.Preference("OnSiteCheckoutAutoCheck") ? 1 : 0 | html %],
});
const table_settings_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'issues-table', 'json' ) | $raw %];
const table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %];
const table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %];
const table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %];
const CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %];
const patron_borrowernumber = [% patron.borrowernumber | $raw %];
const has_patron = [% borrowernumber && patron ? 1 : 0 | html %];
const CircAutoPrintQuickSlip = "[% CircAutoPrintQuickSlip | html %]";
const amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
const fines = "[% fines | $Price %]";
const today_due_date_and_time = "[% today_due_date_and_time | $KohaDates dateformat => 'iso', with_hours => 1 %]";
const duedatespec = "[% duedatespec | html %]";
const override_high_holds = [% override_high_holds ? 1 : 0 | html %];
const HIGHHOLDS = [% HIGHHOLDS ? To.json(HIGHHOLDS) : 'null' | $raw %];
const waiting_holds_barcodes = new Array();
[% FOREACH wh IN waiting_holds %]
waiting_holds_barcodes.push("[% wh.item.barcode | html %]");
[% END %]
const onsite_checkout = "[% onsite_checkout | html %]";
</script>
[% Asset.js("js/pages/circulation.js") | $raw %]
[% IF Koha.Preference('ClaimReturnedLostValue') || Koha.Preference('BundleLostValue') %]
@ -1165,25 +1188,18 @@
[% INCLUDE 'js-biblio-format.inc' %]
[% Asset.js("js/hold-group.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
table_settings_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'issues-table', 'json' ) | $raw %]
table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %]
table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %]
table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %]
CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %]
patron_borrowernumber = [% patron.borrowernumber | $raw %]
[% IF borrowernumber and patron %]
if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){
if( has_patron ){
if( Cookies.get("holdfor") != patron_borrowernumber ){
Cookies.remove("holdfor", { path: '/', SameSite: 'Lax' });
}
[% ELSE %]
} else {
Cookies.remove("holdfor", { path: '/', SameSite: 'Lax' });
[% END %]
}
[% UNLESS ( patron.borrowernumber ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %]
if (borrowernumber ) {
window.onload=function(){ $('#findborrower').focus(); };
}
var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
var fines = "[% fines | $Price %]";
var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
@ -1193,7 +1209,7 @@
if( duedatespec ){
const duedatespec_fp = duedatespec._flatpickr;
if ( $("#onsite_checkout").prop('checked') ) {
duedatespec_fp.setDate("[% today_due_date_and_time | $KohaDates dateformat => 'iso', with_hours => 1 %]");
duedatespec_fp.setDate(today_due_date_and_time);
} else {
duedatespec_fp.setDate("");
}
@ -1216,15 +1232,11 @@
barcodeSubmitInFlight = false;
}
});
[% IF waiting_holds.count && waiting_holds.count > 0 %]
if (waiting_holds_barcodes.length > 0) {
$('#circ-warnwaitingholds-modal .btn-primary').on('click',function() {
$('#mainform').submit();
});
var waiting_holds_barcodes = new Array();
[% FOREACH wh IN waiting_holds %]
waiting_holds_barcodes.push("[% wh.item.barcode | html %]");
[% END %]
$("#mainform").on('submit', function(){
if( $("#checkout_confirmed").length > 0 ){
return true;
@ -1239,7 +1251,7 @@
$("#circ-warnwaitingholds-modal").on('hidden.bs.modal',function(){
$("#mainform").append('<input type="hidden" id="checkout_confirmed" value=1>').submit();
});
[% END %]
}
$('#mainform').on('submit',function() {
if ($("#barcode").length && $("#barcode").val()) {
@ -1250,40 +1262,40 @@
// listen submit to trigger qslip on empty checkout
$('#mainform').bind('submit',function() {
if ($('#barcode').val() == '') {
[% IF ( CircAutoPrintQuickSlip == 'clear' ) %]
if (CircAutoPrintQuickSlip == 'clear') {
window.location='/cgi-bin/koha/circ/circulation.pl';
return false;
[% ELSIF ( CircAutoPrintQuickSlip == 'ignore' ) %]
} else if (CircAutoPrintQuickSlip == 'ignore') {
return false;
[% ELSE %]
window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=issue[% CircAutoPrintQuickSlip | html %]", "printwindow");
} else {
window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=issue" + CircAutoPrintQuickSlip, "printwindow");
return false;
[% END %]
}
}
});
[% IF Koha.Preference('OnSiteCheckoutAutoCheck') && onsite_checkout == "on" %]
if (Koha.prefs.OnSiteCheckoutAutoCheck && onsite_checkout == "on") {
toggle_onsite_checkout();
[% END %]
}
$("#onsite_checkout").click(function(){
toggle_onsite_checkout();
});
[% IF HIGHHOLDS %]
[% IF !override_high_holds %]
$("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate | html %]');
if ('[% duedatespec | html %]' === '') {
if (HIGHHOLDS) {
if (!override_high_holds) {
$("input[name=duedatespec]:hidden").val(HIGHHOLDS.returndate);
if (duedatespec === '') {
$("input[name=restoreduedatespec]:hidden").val('highholds_empty');
} else {
$("input[name=restoreduedatespec]:hidden").val('[% duedatespec | html %]');
$("input[name=restoreduedatespec]:hidden").val(duedatespec);
}
[% END %]
}
$("#override_high_holds_tmp").on( 'change', function() {
if ( this.checked ) {
$("input[name=duedatespec]:hidden").val('');
}
});
[% END %]
}
// Handle checkout for fast cataloging
// Check the referrer to prevent csrf, fill and submit form

View File

@ -242,15 +242,6 @@
[% IF checkout_info.HIGHHOLDS %]
<li><i class="fa fa-li fa-warning"></i>High demand item. Loan period shortened to [% checkout_info.HIGHHOLDS.duration | html %] days (due [% checkout_info.HIGHHOLDS.returndate | html %]).</li>
[% END %]
[% IF checkout_info.HIGHHOLDS %]
<!-- FIXME -->
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function() {
$("input[name=duedatespec]:hidden").val('[% checkout_info.HIGHHOLDS.returndate | html %]');
});
</script>
[% END %]
[% IF NOT checkout_info.IMPOSSIBLE && ( CAN_user_circulate_force_checkout || checkout_info.HIGHHOLDS ) && ( checkout_info.RESERVED || checkout_info.RESERVE_WAITING || checkout_info.TRANSFERRED || checkout_info.PROCESSING ) %]
<!-- arbitrary choice, revert the hold is not possible-->
<li><i class="fa fa-li fa-warning"></i>This item is on hold for another patron. The hold will be overridden, but not cancelled.</li>
@ -352,10 +343,19 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
// FIXME Why are we using a Perl variable here?
const today_due_date_and_time = "[% today_due_date_and_time | $KohaDates dateformat => 'iso', with_hours => 1 %]";
[% FOR checkout_info IN checkout_infos %]
[% IF checkout_info.HIGHHOLDS %]
$(document).ready(function() {
$("input[name=duedatespec]:hidden").val('[% checkout_info.HIGHHOLDS.returndate | html %]');
});
[% END %]
[% END %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
if ($("#barcodelist").length) {

View File

@ -469,7 +469,7 @@
</script>
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let pickups = [% To.json(curbside_pickups.unblessed) | $raw %];
let policy = [% To.json(policy.unblessed) | $raw %];
let opening_slots = [% To.json(policy.opening_slots.unblessed) | $raw %];

View File

@ -346,11 +346,14 @@
[% INCLUDE 'select2.inc' %]
[% INCLUDE 'js-date-format.inc' %]
[% PROCESS 'modal-claims-js' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const ClaimReturnedLostValue = [% Koha.Preference('ClaimReturnedLostValue') ? 1 : 0 | html %];
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'overdues', 'circ-overdues', 'json' ) | $raw %];
[% IF !Koha.Preference('ClaimReturnedLostValue') %]
table_settings['columns'].splice(13, 1);
[% END %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
if (!ClaimReturnedLostValue) {
table_settings["columns"].splice(13, 1);
}
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
function clone_input(node, original_id) {

View File

@ -115,7 +115,7 @@
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'js-biblio-format.inc' %]
[% INCLUDE 'js-date-format.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
let all_libraries = [% To.json(Branches.all) | $raw %].map(e => {

View File

@ -298,7 +298,7 @@
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/hold-group.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -337,7 +337,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$('#current-article-requests').ready(function() {
$(".hide").hide();
});

View File

@ -214,7 +214,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holdsratios', 'holds-ratios', 'json' ) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -1525,7 +1525,7 @@
[% INCLUDE 'calendar.inc' %]
[% Asset.js("js/pages/circulation.js") | $raw %]
[% Asset.js("js/modal_printer.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
/* Set a variable needed by resolve_claim_modal.js or add_catalog_concern.js */
var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";

View File

@ -96,11 +96,12 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
let library_ids = [];
[% FOR library IN libraries %]
library_ids.push("[% library.branchcode | html %]");
[% END %]
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const library_ids = [
[% FOREACH library IN libraries %]
"[% library.branchcode | html %]"[% UNLESS loop.last %],[% END %]
[% END %]
];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {

View File

@ -117,7 +117,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let library_ids = [];
[% FOR library IN branchesloop %]
library_ids.push("[% library.branchcode | html %]");

View File

@ -383,7 +383,7 @@
[% INCLUDE 'select2.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/hold-group.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings('circ', 'view_holdsqueue', 'holds-table', 'json') | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -204,7 +204,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var holdst_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdst', 'json' ) | $raw %];
var holdso_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso', 'json' ) | $raw %];
var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];