Bug 42279: Tidy all script tags - acqui
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 acquisition module. The 2 main changes are in the following files: * basket.tt It's mostly about table settings and the visibility of columns depending on syspref: - "supplier report" / EDIFACT - "modify" / if basket is not closed - "cancel" / CancelOrdersInClosedBaskets * neworderempty.tt trivial changes, no error or warning in the console should appear. Confirm than createing a new order works as expected. 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:
parent
707878312b
commit
3113ca088e
|
|
@ -359,7 +359,6 @@ if ( $basketobj->effective_create_items eq 'ordering' ) {
|
|||
}
|
||||
$template->param(
|
||||
AcqCreateItemOrdering => 1,
|
||||
UniqueItemFields => C4::Context->preference('UniqueItemFields'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -502,7 +501,6 @@ $template->param(
|
|||
publishercode => $data->{'publishercode'},
|
||||
barcode_subfield => $barcode_subfield,
|
||||
import_batch_id => $import_batch_id,
|
||||
acqcreate => $basketobj->effective_create_items eq "ordering" ? 1 : "",
|
||||
users_ids => join( ':', @order_user_ids ),
|
||||
users => \@order_users,
|
||||
( uc( C4::Context->preference("marcflavour") ) ) => 1,
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@
|
|||
[% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
|
||||
[% Asset.js("js/acquisitions-menu.js") | $raw %]
|
||||
[% IF loop_budget %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
[% Asset.css("css/addbiblio.css") | $raw %]
|
||||
[%# As long as cataloging plugins rely on 'script' tags added inline, JS must be in the header %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const template_path = "[% interface | html %]/[% theme | html %]";
|
||||
</script>
|
||||
[% Asset.js("js/acquisitions-menu.js") | $raw %]
|
||||
|
|
|
|||
|
|
@ -1318,26 +1318,48 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% Asset.js("js/acq.js") | $raw %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
var orders_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'basket', 'orders', 'json' ) | $raw %];
|
||||
let supplier_report_column = orders_table_settings.columns.find(c => c.columnname == 'supplier_report');
|
||||
const edifact_available = [% Koha.Preference('EDIFACT') && ediaccount ? 'true' : 'false' | html %];
|
||||
supplier_report_column.visibility_condition = edifact_available;
|
||||
|
||||
let modify_column = orders_table_settings.columns.find(c => c.columnname == 'modify');
|
||||
const modify_column_available = [% active && !closedate ? 'true' : 'false' | html %];
|
||||
modify_column.visibility_condition = modify_column_available;
|
||||
|
||||
let cancel_column = orders_table_settings.columns.find(c => c.columnname == 'cancel');
|
||||
const cancel_column_available = [% !closedate || Koha.Preference('CancelOrdersInClosedBaskets') ? 'true' : 'false' | html %];
|
||||
cancel_column.visibility_condition = cancel_column_available;
|
||||
|
||||
let skip_confirm_reopen = [% skip_confirm_reopen ? 1 : 0 | html %];
|
||||
|
||||
const listincgst = [% listincgst ? 1 : 0 | html %];
|
||||
const has_closedate = [% closedate ? 1 : 0 | html %];
|
||||
const basketno = "[% basketno | html %]";
|
||||
const booksellerid = "[% booksellerid | html %]";
|
||||
</script>
|
||||
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
function updateColumnsVisibility(visible) {
|
||||
if ( visible ) {
|
||||
$("table .tax_excluded, .tax_included").show();
|
||||
} else {
|
||||
[% IF ( listincgst ) %]
|
||||
if ( listincgst ) {
|
||||
$("table .tax_excluded").hide();
|
||||
[% ELSE %]
|
||||
} else {
|
||||
$("table .tax_included").hide();
|
||||
[% END %]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
[% UNLESS ( closedate ) %]
|
||||
if ( !has_closedate ) {
|
||||
$('#addtoBasket').on('show', function () {
|
||||
$(this).find(".modal-body").html($(".acqui_basket_add")[0].outerHTML);
|
||||
});
|
||||
[% END %]
|
||||
}
|
||||
|
||||
$("body").on("click", ".del_user", function(e){
|
||||
e.preventDefault();
|
||||
|
|
@ -1416,7 +1438,7 @@
|
|||
function confirm_ediorder() {
|
||||
var is_confirmed = confirm(_("Are you sure you want to close this basket and generate an EDIFACT order?"));
|
||||
if (is_confirmed) {
|
||||
window.location = "/cgi-bin/koha/acqui/basket.pl?op=edi_confirm&basketno=[% basketno | html %]";
|
||||
window.location = `/cgi-bin/koha/acqui/basket.pl?op=edi_confirm&basketno=${basketno}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1439,7 +1461,7 @@
|
|||
$(document).ready(function(){
|
||||
$("#basketgroupid").change(function(){
|
||||
if($(this).val() == "new"){
|
||||
location.href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid | html %]";
|
||||
location.href=`/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=${booksellerid}`;
|
||||
} else {
|
||||
$(this).parent().submit();
|
||||
}
|
||||
|
|
@ -1447,22 +1469,6 @@
|
|||
});
|
||||
</script>
|
||||
[% END # /UNLESS (closedate) %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
var orders_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'basket', 'orders', 'json' ) | $raw %];
|
||||
let supplier_report_column = orders_table_settings.columns.find(c => c.columnname == 'supplier_report');
|
||||
const edifact_available = [% Koha.Preference('EDIFACT') && ediaccount ? 'true' : 'false' | html %];
|
||||
supplier_report_column.visibility_condition = edifact_available;
|
||||
|
||||
let modify_column = orders_table_settings.columns.find(c => c.columnname == 'modify');
|
||||
const modify_column_available = [% active && !closedate ? 'true' : 'false' | html %];
|
||||
modify_column.visibility_condition = modify_column_available;
|
||||
|
||||
let cancel_column = orders_table_settings.columns.find(c => c.columnname == 'cancel');
|
||||
const cancel_column_available = [% !closedate || Koha.Preference('CancelOrdersInClosedBaskets') ? 'true' : 'false' | html %];
|
||||
cancel_column.visibility_condition = cancel_column_available;
|
||||
|
||||
let skip_confirm_reopen = [% skip_confirm_reopen ? 1 : 0 | html %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
$(document).ready(function () {
|
||||
$("#orders").kohaTable(
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@
|
|||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
let listclosed = [% listclosed ? 1 : 0 | html %];
|
||||
let grouping = [% grouping ? 1 : 0 | html %];
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% Asset.js("js/acq.js") | $raw %]
|
||||
[% Asset.js("js/funds_sorts.js") | $raw %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const op = "[% op | html %]";
|
||||
const has_results = [% result_order_loop ? 1 : 0 | html %];
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% Asset.js("js/modals/edifact_interchange.js") | $raw %]
|
||||
[% Asset.js("js/modals/edifact_errors.js") | $raw %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
var interface = "[% interface | html %]";
|
||||
var theme = "[% theme | html %]";
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@
|
|||
[% Asset.js("js/acquisitions-menu.js") | $raw %]
|
||||
[% 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( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% Asset.css("css/edifact_interchange.css") | $raw %]
|
||||
[% Asset.js("js/modals/edifact_interchange.js") | $raw %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
EdifactDisplay.init({
|
||||
modalId: "#EDI_modal",
|
||||
expandByDefault: true,
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@
|
|||
[% Asset.js("js/acquisitions-menu.js") | $raw %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
|
|
|
|||
|
|
@ -54,11 +54,22 @@
|
|||
[% Asset.js("js/additional-fields-entry.js") | $raw %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
[% INCLUDE 'select2.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const AcqCreateItemOrdering = [% AcqCreateItemOrdering ? 1 : 0 | html %];
|
||||
const is_standing = [% basket.is_standing ? 1 : 0 | html %];
|
||||
const ordernumber = "[% ordernumber | html %]";
|
||||
const from_suggestion = [% suggestion ? 1 : 0 | html %];
|
||||
const quantityrec = "[% quantityrec | html %]";
|
||||
const subscriptionid = "[% subscriptionid | html %]";
|
||||
Koha.addPrefs({
|
||||
UniqueItemFields: "[% Koha.Preference("UniqueItemFields") | html %]",
|
||||
});
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
actTotal = "";
|
||||
|
||||
function Check(ff) {
|
||||
[% IF (AcqCreateItemOrdering) %]
|
||||
if (AcqCreateItemOrdering) {
|
||||
// Remove last itemblock if it is not in items_list
|
||||
var lastitemblock = $("#outeritemblock > div:last");
|
||||
var tobedeleted = true;
|
||||
|
|
@ -71,7 +82,7 @@
|
|||
if(tobedeleted){
|
||||
$(lastitemblock).remove();
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
|
||||
var ok=0;
|
||||
var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
|
||||
|
|
@ -115,45 +126,47 @@
|
|||
|
||||
if (ok) {
|
||||
alert(_alertString);
|
||||
[% IF (AcqCreateItemOrdering) %]
|
||||
if (AcqCreateItemOrdering) {
|
||||
if(tobedeleted) {
|
||||
$(lastitemblock).appendTo('#outeritemblock');
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[% IF (AcqCreateItemOrdering) %]
|
||||
if(check_additem('[% UniqueItemFields | html %]') == false) {
|
||||
if (AcqCreateItemOrdering) {
|
||||
if(check_additem(Koha.prefs.UniqueItemFields) == false) {
|
||||
alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
|
||||
if(tobedeleted) {
|
||||
$(lastitemblock).appendTo('#outeritemblock');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
[% UNLESS ordernumber %]
|
||||
if (!ordernumber ){
|
||||
$("#items_list").hide();
|
||||
[% END %]
|
||||
}
|
||||
|
||||
[% IF AcqCreateItemOrdering and not basket.is_standing %]
|
||||
cloneItemBlock(0, '[% UniqueItemFields | html %]');
|
||||
[% END %]
|
||||
if (AcqCreateItemOrdering && !is_standing ){
|
||||
cloneItemBlock(0, Koha.prefs.UniqueItemFields);
|
||||
}
|
||||
|
||||
[% IF ( suggestion ) %]updateCosts();[% END %]
|
||||
if (from_suggestion) {
|
||||
updateCosts();
|
||||
}
|
||||
$("#quantity").change(function() {
|
||||
updateCosts();
|
||||
});
|
||||
|
||||
//We apply the function only for modify option
|
||||
[% IF ( quantityrec and not subscriptionid ) %]
|
||||
[% IF ( acqcreate ) %]
|
||||
if ( quantityrec && !subscriptionid ) {
|
||||
if ( AcqCreateItemOrdering ){
|
||||
$('#quantity').blur(function(){
|
||||
// if user decreases the quantity
|
||||
if($(this).val() < [% quantityrec | html %]){
|
||||
if($(this).val() < quantityrec ){
|
||||
alert(_("You have deleted item(s) in the order, don't forget to delete it(them) in the catalog"));
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -165,8 +178,8 @@
|
|||
return false;
|
||||
}
|
||||
});
|
||||
[% END %]
|
||||
[% END %]
|
||||
}
|
||||
}
|
||||
|
||||
//keep a copy of all budgets before removing the inactives
|
||||
disabledBudgetsCopy = $('#budget_id').html();
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
[% IF suggestions.size %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'js-date-format.inc' %]
|
||||
[% INCLUDE 'format_price.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
var edit_mode = "[% edit | html %]";
|
||||
var invoiceincgst = "[% invoiceincgst | html %]";
|
||||
var active_currency = "[% active_currency.currency | html %]";
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
Koha.addPrefs({
|
||||
marcflavour: "[% Koha.Preference('marcflavour') | html %]",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@
|
|||
[% Asset.js("js/acquisitions-menu.js") | $raw %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const vendor_id = [% vendor.id | html %];
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'js-date-format.inc' %]
|
||||
[% INCLUDE 'format_price.inc' %]
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
|
||||
const vendorTableSettings = [% TablesSettings.GetTableSettings( 'acqui', 'vendors', 'vendors', 'json' ) | $raw %];
|
||||
</script>
|
||||
[% Asset.js("js/vue/dist/acquisitions.js") | $raw %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue