Bug 42290: Tidy all script tags - suggestion

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

Trivial changes, the main changes have been done already, we only move
them to a separate script tag.

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 14:33:38 +02:00 committed by Pedro Amorim
parent 36e00f5aff
commit e4293f93d2
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 16 additions and 12 deletions

View File

@ -1207,6 +1207,19 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'select_manager.inc' manager => suggestion.manager %]
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
[% IF op == 'else' %]
const has_suggestions = [% suggestions.size ? 1 : 0 | html %];
let suggestionData = [% To.json(suggestions || []) | $raw %];
var suggestions_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
Koha.addPermissions({
CAN_user_suggestions_suggestions_manage: [% CAN_user_suggestions_suggestions_manage ? 1 : 0 | html %],
CAN_user_suggestions_suggestions_delete: [% CAN_user_suggestions_suggestions_delete ? 1 : 0 | html %],
});
[% ELSIF op == 'save' %]
const has_other_reason = [% other_reason ? 1 : 0 | html %];
[% END %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
function select_suggester(borrowernumber, borrower) {
$.ajax({
@ -1253,15 +1266,6 @@
</script>
[% END %]
[% IF op == 'else' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
const has_suggestions = [% suggestions.size ? 1 : 0 | html %];
let suggestionData = [% To.json(suggestions || []) | $raw %];
var suggestions_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
Koha.addPermissions({
CAN_user_suggestions_suggestions_manage: [% CAN_user_suggestions_suggestions_manage ? 1 : 0 | html %],
CAN_user_suggestions_suggestions_delete: [% CAN_user_suggestions_suggestions_delete ? 1 : 0 | html %],
});
</script>
[% INCLUDE 'datatables.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
@ -1595,13 +1599,13 @@
calcNewsuggTotal();
});
[% IF other_reason %]
if (has_other_reason){
$(".select-reason").hide();
$(".select-reason").find("option[value='other']").attr("selected","selected");
$("#other_reason").show();
[% ELSE %]
} else {
$("#other_reason").hide();
[% END %]
}
$(".select-reason").change(function(){
if($(this).val() == "other"){
$(this).hide();