From 567cfeba28b1e39a8b878ac051eecbf1d827a04a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 17 Oct 2024 11:35:22 -0300 Subject: [PATCH] Bug 35717: JS fixes Bug 37018 added validation to queries and `{"in":...}` is no longer valid. `{"-in":...}` is so this patch tweaks that. The previous patch fixes actual linking orders to suggestions. But not having orders linked highlighted the code explode because an empty array evaluates to `true` in Javascript. This patch fixes that too. The links generated by this patchset also get their components correctly escaped. --- .../prog/en/modules/acqui/orderreceive.tt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 903430c5704..f972fa24dd6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -555,7 +555,7 @@ $(document).ready(function(){ // keep a copy for re-rendering var $funds_tree = $('#bookfund').html(); - var base_query = { "me.order_id": {"in": [[% multiple_orders | html %]]}}; + var base_query = { "me.order_id": {"-in": [[% multiple_orders | html %]]}}; var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; var options = { "ajax": { @@ -697,7 +697,7 @@ params['ordernumber'] = row.order_id; params['booksellerid'] = row.basket.vendor_id; - if(row.suggestions && row.suggestions[0].reason) { + if(row.suggestions?.length && row.suggestions[0].reason) { params["suggestionid"] = row.suggestions[0].suggestion_id; const options = Array.from(document.querySelectorAll('#reason option')); @@ -1042,7 +1042,7 @@ "data": function(row, type, val, meta) { if(row.invoice) { if(CAN_user_acquisition) { - return ''+row.invoice.invoice_number+""; + return ''+escape_str(row.invoice.invoice_number)+""; } return row.invoice.invoice_number; } @@ -1138,17 +1138,17 @@ o.parent().hide(); } }); - if(row.suggestions) { + if(row.suggestions?.length) { $("#suggestion_fieldset").show(); if(row.suggestions[0].suggester) { $("#biblio_suggestion_suggester").parent().show(); $("#biblio_suggestion_suggester") .html( - [row.suggestions[0].suggester.surname, row.suggestions[0].suggester.firstname] + [escape_str(row.suggestions[0].suggester.surname), escape_str(row.suggestions[0].suggester.firstname)] .filter(function(name){ return name }) - .join(', ')+' ('+SUGGESTION.format(row.suggestions[0].suggestion_id)+')' + .join(', ')+' ('+SUGGESTION.format(row.suggestions[0].suggestion_id)+')' ); } else { $("#biblio_suggestion_suggester").parent().hide(); -- 2.47.0