Bug 42293: Tidy all script tags - serials

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 serials module.

The 3 main changes are in the following files:
* routing.tt
* serials-search.tt
* subscription-detail.tt

Changes are trivial.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
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-31 12:05:04 +02:00 committed by Pedro Amorim
parent 8d9d749c53
commit 2ecbac6060
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
8 changed files with 25 additions and 19 deletions

View File

@ -217,7 +217,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( "serials", "claims", "claimst", "json" ) | $raw %];
const vendor_id = "[% supplierid | html %]";
</script>

View File

@ -135,6 +135,9 @@
[% END %]
[% MACRO jsinclude BLOCK %]
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = [% subscriptionid || 0 | html %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
$(".itemrank").on("change", function () {
@ -184,7 +187,7 @@
}
$.ajax({
data: {
subscriptionid: [% subscriptionid | html %],
subscriptionid,
borrowernumbers,
op: 'cud-add_new_recipients',
csrf_token: $('meta[name="csrf-token"]').attr('content'),
@ -192,7 +195,7 @@
type: 'POST',
url: '/cgi-bin/koha/serials/routing.pl',
success: function (data) {
document.location.href = '/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]';
document.location.href = `/cgi-bin/koha/serials/routing.pl?subscriptionid=${subscriptionid}`;
return false;
},
error: function (data) {

View File

@ -341,8 +341,9 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = "[% subscriptionid | html %]";
var subscriptionidlist = "[% subscriptionidlist | html %]";
</script>
[% Asset.js("js/serials-toolbar.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
@ -420,7 +421,7 @@
$(document).ready(function() {
$(".delete-issues").on("click", function(e){
e.preventDefault();
deleteIssues("[% subscriptionidlist | html %]");
deleteIssues(subscriptionidlist);
});
});
</script>

View File

@ -18,7 +18,6 @@
[% Asset.js("js/cataloging.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
//<![CDATA[
$(document).ready(function () {
$("#multi_receiving").on("show", function () {
$(this).find(".modal-body").html($(".serials_multi_receiving")[0].outerHTML);
@ -88,7 +87,6 @@
}
});
});
//]]>
</script>
<style nonce="[% Koha.CSPNonce | $raw %]">
#serials_edit fieldset.rows label,

View File

@ -45,7 +45,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% Asset.js("js/serials-toolbar.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = "[% subscriptionid | html %]";
</script>
[% END %]

View File

@ -1,4 +1,5 @@
[% USE raw %]
[% USE To %]
[% USE Asset %]
[% USE AuthorisedValues %]
[% USE Branches %]
@ -281,9 +282,13 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = "[% subscriptionid | html %]";
const edit_action_link = "[% edit_action_link | html %]";
[% IF mana %]
const additional_fields_for_subscription = [% To.json(additional_fields_for_subscription) | $raw %];
[% END %]
</script>
[% Asset.js("js/serials-toolbar.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
@ -367,9 +372,9 @@
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function() {
$(".local").hide();
[% FOR field IN additional_fields_for_subscription %]
$("label[for=additional_field_[% field.id | $raw %]], input#additional_field_[% field.id | $raw %]").hide();
[% END %]
additional_fields_for_subscription.forEach(f => {
$(`label[for=additional_field_${f.id}], input#additional_field_${f.id}`).hide();
});
});
</script>
[% END %]

View File

@ -596,7 +596,7 @@
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/mana.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = "[% subscriptionid | html %]";
var irregularity = "[% irregularity | html %]";
var more_than_one_serial = "[% more_than_one_serial | html %]";

View File

@ -447,18 +447,17 @@
[% END %]
[% MACRO jsinclude BLOCK %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var subscriptionid = "[% subscriptionid | html %]";
var table_settings = [% TablesSettings.GetTableSettings( 'serials', 'subscription-detail', 'orders', 'json' ) | $raw %];
const has_orders = [% orders_grouped.size ? 1 : 0 | html %];
const print_routing_list_issue = "[% print_routing_list_issue | uri %]";
</script>
[% Asset.js("js/serials-toolbar.js") | $raw %]
[% Asset.js("js/mana.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
var table_settings = [% TablesSettings.GetTableSettings( 'serials', 'subscription-detail', 'orders', 'json' ) | $raw %];
const has_orders = [% orders_grouped.size ? 1 : 0 | html %];
const print_routing_list_issue = "[% print_routing_list_issue | uri %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
// the english words used in display purposes
var text = new Array(