Bug 42280: Tidy all script tags - admin

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

The 2 main changes are in the following files:
* aqplan.tt
"0" should be correctly formatted
* categories.tt
trivial change about table settings

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-04-03 11:24:41 +02:00 committed by Pedro Amorim
parent 0de23cde12
commit 70bb50988b
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
29 changed files with 32 additions and 30 deletions

View File

@ -615,7 +615,7 @@
[% Asset.js("js/acq.js") | $raw %]
[% IF close_form %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const budget_period_description = "[% budget_period_description | html %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -729,7 +729,7 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
[% IF budgets %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const budget_period_id = [% budget_period_id || 'null' | html %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -320,10 +320,12 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/acq.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const zero_formatted = "[% 0 | $Price on_editing => 1 %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
jQuery.validator.addClassRules({ plan_entry: { pnumber: true } }); // require that input be a number in fields with the class 'plan_entry'
jQuery.validator.addMethod("pnumber", $.validator.methods.number, _("Please enter a valid number.") );
var zero_formatted = "[% 0 | $Price on_editing => 1 %]";
$(document).ready(function() {
$("#selections input").on("change",function(e){
var num = $(this).attr("id");

View File

@ -472,7 +472,7 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %]
[% Asset.js("js/admin-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const tagsubfield = [% IF tagsubfield %]"[% tagsubfield | html %]"[% ELSE %]null[% END %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -144,7 +144,7 @@
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'js-date-format.inc' %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const job_statuses = [
{'_id': 'new', '_str': _("New")},
{'_id': 'cancelled', '_str': _("Cancelled")},

View File

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

View File

@ -137,7 +137,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const codes_loop = [% To.json(codes_loop) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -817,7 +817,7 @@
width: 50em;
}
</style>
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]';
</script>

View File

@ -918,9 +918,10 @@
[% END %]
[% MACRO jsinclude BLOCK %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var TalkingTechItivaPhoneNotification = [% Koha.Preference('TalkingTechItivaPhoneNotification') || 0 | html %];
var PhoneNotification = [% Koha.Preference('PhoneNotification') || 0 | html %];
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'categories', 'patron_categories', 'json' ) | $raw %];
</script>
[% Asset.js("js/admin-menu.js") | $raw %]
[% Asset.js("js/messaging-preference-form.js") | $raw %]
@ -929,7 +930,6 @@
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'categories', 'patron_categories', 'json' ) | $raw %];
$(document).ready(function () {
function getTextareaFromParent(el) {
return $(el).children("textarea").eq(0);

View File

@ -204,7 +204,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-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( 'admin', 'cities', 'table_cities', 'json' ) | $raw %];
var cities_table_url = '/api/v1/cities?';

View File

@ -403,7 +403,7 @@
[% Asset.js("js/admin-menu.js") | $raw %]
[%- IF ( panel.defined ) -%]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$(document).ready( function() {
$("#[% panel | uri %]_panel").collapse("show");
[%- IF page.defined -%]

View File

@ -173,7 +173,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let opening_slots = {};
let slots;
[% FOR l IN libraries %]

View File

@ -307,7 +307,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
let table_settings = [% TablesSettings.GetTableSettings( 'admin', 'currency', 'currencies-table', 'json' ) | $raw %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -453,7 +453,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-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( 'admin', 'edi_accounts', 'edi_accounts_table', 'json' ) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">

View File

@ -459,7 +459,7 @@
[% Asset.js("js/admin-menu.js") | $raw %]
[% Asset.js("js/transport_status.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const i18n = {
on: "[% tp("Active", "On") | html %]",
passive: "[% tp('FTP connection mode', '(passive)') | html %]",

View File

@ -348,7 +348,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var identity_provider_domains_url = '/api/v1/auth/identity_providers/[%- identity_provider_id | html -%]/domains';
[% SET categories = Categories.all() %]
var categories = {

View File

@ -173,7 +173,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var $branch = "[% branch | html %]";
$(function(){

View File

@ -548,7 +548,7 @@
[% Asset.js("js/admin-menu.js") | $raw %]
[% 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( 'admin', 'itemtypes', 'table_item_type', 'json' ) | $raw %];
[% IF ( Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') ) %]
table_settings['columns'].shift(); // Remove item type image column from configuration

View File

@ -327,7 +327,7 @@
});
});
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var languages_select = $('<select name="lang" id="lang"></select>');
[% FOR language IN languages %]
[% FOR sublanguage IN language.sublanguages_loop %]

View File

@ -318,7 +318,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var categories = [% To.json( categories ) | $raw %];
var module_filter_options = {
source: {

View File

@ -438,7 +438,7 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %]
[% Asset.js("js/admin-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const tagsubfield = [% IF tagsubfield %]"[% tagsubfield | html %]"[% ELSE %]null[% END %];
</script>
[% Asset.js("js/marc_subfields_structure.js") | $raw %]

View File

@ -731,7 +731,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var maxMatchPoint = [% max_matchpoint | html %];
var maxMatchCheck = [% max_matchcheck | html %];

View File

@ -185,7 +185,7 @@
[% INCLUDE 'datatables.inc' %]
[% END %]
[% IF server %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const server = {
dataformat: "[% server.dataformat | html %]",
recordtype: "[% server.recordtype | html %]",

View File

@ -301,7 +301,7 @@
[% Asset.js( "lib/codemirror/css-lint.min.js" ) | $raw %]
[% Asset.js( "lib/codemirror/yaml-lint.min.js" ) | $raw %]
[% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var themelang = "[% themelang | html %]";
$(document).ready(function(){
$("select[multiple='multiple']").multipleSelect( {

View File

@ -236,7 +236,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var MSG_DUPLICATE_CODE = _("Restriction type code is already in use");
var MSG_DUPLICATE_DISPLAY_TEXT = _("Restriction type label is already in use");
var existing = {

View File

@ -323,7 +323,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const i18n = {
on: "[% tp("Active", "On") | html %]"
};

View File

@ -146,7 +146,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const branchTransferLimitsType = "[% BranchTransferLimitsType | html %]";
const val_type = branchTransferLimitsType == "itemtype" ? "item_type" : "collection_code";
const branches = [% To.json(branches) | $raw %];

View File

@ -264,7 +264,7 @@
[% INCLUDE 'calendar.inc' %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% Asset.js("/lib/leaflet/leaflet.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
function positionMap() {
var tbh = $("#mapid");
var mapContainer = tbh.parent();

View File

@ -304,7 +304,7 @@
[% END %]
[% IF server %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const server = {
syntax: "[% server.syntax | html %]",
encoding: "[% server.encoding | html %]",