Bug 42296: Tidy all script tags - trivial occurrences

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 only adds 'data-tt-allowed="true"' when needed. The work to
move the JS variable to a separate script tag has been done already on
bug 41324.

Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-03-31 12:17:21 +02:00 committed by Pedro Amorim
parent 80abb65c62
commit 4a4843e481
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
25 changed files with 25 additions and 25 deletions

View File

@ -290,7 +290,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/show-password-toggle.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$(document).ready( function() {
if ( document.location.hash ) {
const input = $('<input name="auth_forwarded_hash" type="hidden">')

View File

@ -65,7 +65,7 @@
[% Asset.js("js/cancel_booking_modal.js") | $raw %]
[% Asset.js("js/combobox.js") | $raw %]
[% Asset.js("js/additional-filters.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var cancel_success = 0;
var update_success = 0;
var bookings_table;

View File

@ -60,7 +60,7 @@
</tbody>
</table>
[% END %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var clubs_borrowernumber = "[% borrowernumber | html %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -60,7 +60,7 @@
</fieldset>
</form>
</div>
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
if([% enrollent_id | html %]){
$("#heading").html(_("Modifying enrollment")+" <em>[% club.name | html %]</em>");
}

View File

@ -361,7 +361,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'coursereserves', 'reserves', 'course_reserves_table', 'json' ) | $raw %];
const course_reserves_size = [% course_reserves.size || 0 | html %];
const i18n = {

View File

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

View File

@ -27,7 +27,7 @@
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'js-date-format.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const agreement_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'agreements', 'agreements', 'json' ) | $raw %];
const license_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'licenses', 'licenses', 'json' ) | $raw %];
const eholdings_packages_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'packages', 'json' ) | $raw %];

View File

@ -126,7 +126,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
function showBarcodeText( path, dimensions ){

View File

@ -231,7 +231,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/labels-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const batch_id = "[% batch_id | html %]";
const has_entries = [% table_loop ? 1 : 0 | html %];
</script>

View File

@ -142,7 +142,7 @@
<!-- /.main.container-fluid -->
[% MACRO jsinclude BLOCK %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$(document).ready(function(){
$("#CheckAll").click(function(e){
e.preventDefault();

View File

@ -234,7 +234,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings('members', 'patron-lists', 'patron-list-table', 'json') | $raw %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -162,7 +162,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const interface = "[% interface | html %]";
const theme = "[% theme | html %]";
</script>

View File

@ -122,7 +122,7 @@
[% ELSIF !in_lists && CAN_user_tools_manage_patron_lists %]
<p>Patron is not on any list. <a href="/cgi-bin/koha/patron_lists/add-modify.pl">Create a new patron list</a>.</p>
[% END %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var patron_id = "[% borrowernumber | html %]";
var cardnumber = "[% cardnumber | html %]";
Koha.addPermissions({

View File

@ -175,7 +175,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/tools-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const batch_id = "[% batch_id | html %]";
Koha.addPrefs({
PatronsPerPage: "[% Koha.Preference('PatronsPerPage') | html %]",

View File

@ -188,7 +188,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
function DeleteConfirm() {
var element_ids = selected_layouts("delete");

View File

@ -243,7 +243,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'format_price.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var items_table_settings = [% TablesSettings.GetTableSettings('pos', 'pay', 'invoices', 'json') | $raw %];
var zero_formatted = "[% 0 | $Price %]";
const payment_id = "[% payment_id | html %]";

View File

@ -489,7 +489,7 @@
[% Asset.js("js/modals/cashup_modals.js") | $raw %]
[% Asset.js("js/modal_printer.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const register = {
id: "[% register.id | html %]",
description: "[% register.description | html %]",

View File

@ -400,7 +400,7 @@
[% Asset.js("js/modals/cashup_summary_modal.js") | $raw %]
[% Asset.js("js/modals/cashup_modals.js") | $raw %]
[% Asset.js("js/modal_printer.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$(document).ready(function () {
[%# js used here as we don't have access to these template variables where we need them #%]
$("#bankable").text('[% bankable | $Price %]');

View File

@ -24,7 +24,7 @@
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'js-date-format.inc' %]
[% INCLUDE 'js-biblio-format.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const authorised_value_categories = [% To.json(AuthorisedValues.GetCategories()) | $raw %].map(c => c.category);
const db_columns = [% To.json(db_columns) | $raw %];
const api_mappings = [% To.json(api_mappings) | $raw %];

View File

@ -383,7 +383,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
// FIXME This does not work, we need to pass table settings, not the columns
columns_settings = [% FILTER collapse %]
[

View File

@ -1823,7 +1823,7 @@
[% Asset.js( "js/mana.js" ) | $raw %]
[% Asset.js( "js/throttledButton.js" ) | $raw %]
[% INCLUDE 'select2.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let op = "";
[% IF create %]
op = "create";

View File

@ -193,7 +193,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'lostitems', 'lostitems-table', 'json' ) | $raw %];
[% IF csv_profiles.count %]
// Add the first (checkbox) column if it is displayed

View File

@ -168,7 +168,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'orders_by_fund', 'funds-table', 'json' ) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -18,7 +18,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const institutions_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'institutions', 'institutions', 'json' ) | $raw %];
const accounts_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'accounts', 'accounts', 'json' ) | $raw %];
const system_preference_overrides_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'system_preference_overrides', 'system_preference_overrides', 'json' ) | $raw %];

View File

@ -68,7 +68,7 @@
</tbody>
</table>
[% END %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const patron_id = "[% borrower.borrowernumber | html %]";
Koha.addPrefs({
OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],