From 65460128f13334ce73652682b740d8312f3bc833 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Jan 2024 09:36:43 +0100 Subject: [PATCH] Bug 35756: Correctly serialize patron's data in patron search popup/modal We are incorrectly using encodeURIComponent in patron-search.inc. When a new patron is selected, the info message is showing "Patron %s is already in the list" or "Patron %s added". If the patron has space in their name, they will be substituted with %20. We are using JSON for select, we can reuse it for add. Test plan: Have a patron with spaces in their name Add users to a fund Notice that the name is correctly displayed. Signed-off-by: Lucas Gass Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer (cherry picked from commit 6779e64d955f6e90e05eba19fd4d7d3606ae15ec) Signed-off-by: Fridolin Somers --- .../prog/en/includes/patron-search.inc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index f7b139fd68..11fc20a8e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -596,13 +596,9 @@ [% FOR action IN actions %] [% SWITCH action %] [% CASE 'select' %] - let patron_str = JSON.stringify(row); action_node += '' + _("Select") + ''; - let input_node = $(''); - $(input_node).val(patron_str); - action_node += $(input_node).prop('outerHTML'); [% CASE 'add' %] - action_node += '' + _("Add") + ''; + action_node += '' + _("Add") + ''; [% CASE 'edit' %] action_node += ' ' + _("Edit") + ''; [% CASE 'checkout' %] @@ -611,6 +607,12 @@ [% END %] [% END %] [% END %] + + let patron_str = JSON.stringify(row); + let input_node = $(''); + $(input_node).val(patron_str); + action_node += $(input_node).prop('outerHTML'); + return action_node; }, "searchable": false, @@ -647,16 +649,15 @@ $("body").on("click",".add_user",function(e){ e.preventDefault(); var borrowernumber = $(this).data("borrowernumber"); - var firstname = $(this).data("firstname"); - var surname = $(this).data("surname"); - add_user( borrowernumber, firstname + " " + surname ); + var borrower_data = JSON.parse($("#borrower_data"+borrowernumber).val()); + add_user( borrowernumber, borrower_data.firstname + " " + borrower_data.surname ); }); $("body").on("click",".select_user",function(e){ e.preventDefault(); var borrowernumber = $(this).data("borrowernumber"); - var borrower_data = $("#borrower_data"+borrowernumber).val(); - select_user( borrowernumber, JSON.parse(borrower_data) ); + var borrower_data = JSON.parse($("#borrower_data"+borrowernumber).val()); + select_user( borrowernumber, borrower_data ); }); $("body").on("click",".patron_preview", function( e ){ -- 2.39.5