Bug 42283: Tidy all script tags - cataloguing

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

The 3 main changes are in the following files:
* addbooks.tt
* additem.tt
* concerns.tt

There are non-trivial changes in concerns.tt. You need to create several
authorised values for TICKET_STATUS, turn on CatalogConcerns and OpacCatalogConcerns, create several concerns and go to /cgi-bin/koha/cataloguing/concerns.pl
Confirm that the filters are working correctly

Note that cataloguing/addbiblio.tt is on a separate bug (bug 42284)

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 13:14:54 +02:00 committed by Pedro Amorim
parent 5988883898
commit 0aeb26417e
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
7 changed files with 37 additions and 31 deletions

View File

@ -1,4 +1,5 @@
[% USE raw %]
[% USE To %]
[% USE Koha %]
[% USE KohaDates %]
[% USE TablesSettings %]
@ -326,12 +327,13 @@
[% 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( 'cataloguing', 'addbooks', 'reservoir-table', 'json' ) | $raw %]
const interface = "[% interface | html %]";
const theme = "[% theme | html %]";
const biblionumber = "[% biblionumber | html %]";
var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
var z3950_search_params = [% To.json(z3950_search_params || []) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
@ -414,9 +416,9 @@
/* provide Z3950 search points */
function GetZ3950Terms(fw){
var strQuery="&frameworkcode=" + fw;
[% FOREACH z3950_search_param IN z3950_search_params %]
strQuery += "&" + "[% z3950_search_param.name | uri %]" + "=" + "[% z3950_search_param.value | uri %]";
[% END %]
z3950_search_params.forEach(function(z3950_search_param) {
strQuery += "&" + z3950_search_param.name + "=" + z3950_search_param.value;
});
return strQuery;
}
</script>

View File

@ -24,12 +24,9 @@
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.css("css/addbiblio.css") | $raw %]
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
[% IF Koha.Preference('CreateAVFromCataloguing') && CAN_user_parameters_manage_auth_values %]
var auth_values_creation = 1;
[% ELSE %]
var auth_values_creation = 0;
[% END %]
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var auth_values_creation = [% IF Koha.Preference('CreateAVFromCataloguing') && CAN_user_parameters_manage_auth_values %]1[% ELSE %]0[% END %];
var has_item_groups = "[% item_groups.size | html %]";
</script>
[% INCLUDE 'select2.inc' %]
[% Asset.js("js/cataloging.js") | $raw %]
@ -37,9 +34,6 @@
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'str/cataloging_additem.inc' %]
[% Asset.js("js/cataloging_additem.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
var has_item_groups = "[% item_groups.size | html %]";
</script>
<style nonce="[% Koha.CSPNonce | $raw %]">
.flatpickr_wrapper input {
width: 100%;

View File

@ -231,7 +231,7 @@
[% END %]
[% MACRO jsinclude BLOCK %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
$(document).ready(function() {
$("#newRecord").click(function(){

View File

@ -63,10 +63,18 @@
[% 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">
logged_in_user_borrowernumber = [% logged_in_user.borrowernumber | html %];
var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %];
var statuses = [];
[% FOR st IN status %]
statuses.push({
authorised_value: "[% st.authorised_value | html %]",
lib: "[% st.lib | html %]",
});
[% END %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
@ -253,15 +261,13 @@
tickets.DataTable().draw();
});
adjust_filter_label();
});
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function() {
[% FOR st IN status %]
$('#[% st.authorised_value | html %]_filter').on("click", function() {
if ($("#hide_[% st.authorised_value | html %]").is(":checked")){
statuses.forEach(function(st){
const av = st.authorised_value;
$(`#${av}_filter`).on("click", function() {
if ($(`#${av}`).is(":checked")){
additional_filters.status.find((o, i) => {
if (o["!="] === '[% st.authorised_value | html %]') {
if (o["!="] === av) {
additional_filters.status.splice(i, 1);
return true; // stop searching
}
@ -269,18 +275,18 @@
if ( additional_filters.status.length === 1 ){
delete additional_filters.status;
}
$(this).html('<i class="fa fa-filter"></i> '+_("Filter ")+"[% st.lib | html %]");
$(this).html('<i class="fa fa-filter"></i> '+_("Filter ")+st.lib);
} else {
if (!additional_filters.hasOwnProperty("status")) {
additional_filters.status = [ '-and' ];
}
additional_filters.status.push({ '!=': "[% st.authorised_value | html %]" });
$(this).html('<i class="fa fa-bars"></i> '+_("Include ")+"[% st.lib | html %]");
additional_filters.status.push({ '!=': av});
$(this).html('<i class="fa fa-bars"></i> '+_("Include ")+st.lib);
}
$("#hide_[% st.authorised_value | html %]").prop("checked", !$("#hide_[% st.authorised_value | html %]").is(":checked"));
$(`#hide_${av}`).prop("checked", !$(`#hide${av}`).is(":checked"));
tickets.DataTable().draw();
});
[% END %]
});
});
</script>
[% INCLUDE 'select2.inc' %]

View File

@ -225,7 +225,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/merge-record.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
[% UNLESS (result) %]
[% IF (choosereference) %]
function changeFramework(fw) {

View File

@ -30,6 +30,10 @@
</div>
</nav>
</form>
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var index = "[% index | html %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
$('#return').focus();
@ -38,7 +42,7 @@
// The following function just puts back the value of the input #return
// into the caller's field, referenced by index. And closes the popup.
function submitMyForm() {
$(window.opener.document).find('#[% index | html %]').val($('#return').val() );
$(window.opener.document).find(`#${index}`).val($('#return').val() );
window.close();
}
</script>

View File

@ -280,7 +280,7 @@
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'z3950_search.inc' %]
[% Asset.js("js/z3950_search.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
var table_settings = [% TablesSettings.GetTableSettings( 'cataloguing', 'z3950_search', 'resultst', 'json' ) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">