From c52f51b421cb3b77591bb804589b221b424fcefc Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 1 Nov 2023 17:19:09 +0000 Subject: [PATCH] Bug 34608: (follow-up) Display authorized values if used This patch shamelessly steals from Bug 33568 in order to allow the correct authorized value description to be shown in the JS-generated table of results for values of borrowers sort1 and sort2. To test, apply the patch and go to Administration -> Authorized values. - Add some values, if necessary, to both the 'Bsort1' and 'Bsort2' categories. - Locate some patron records to edit, and set the patron's "Sort 1" and "Sort 2" fields. - Perform a patron search which will return those patron records. - Confirm that the correct authorized value description is shown instead of the authorized value code. - Delete all values from the 'Bsort1' and 'Bsort2' authorized value categories. - Return to your patron search and confirm that "Sort 1" and "Sort 2" values are still being shown, though now it's the "raw" code. Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/en/includes/patron-search.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 8f26d5169a..493b3f8cc6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -6,7 +6,7 @@ [% USE raw %] [% USE Asset %] [% USE To %] - +[% USE AuthorisedValues %] [% SET search_results_block_id = 'searchresults' %] [%# Display a simple form %] @@ -308,6 +308,10 @@ [% CASE %] let patron_search_url = '/api/v1/patrons'; [% END %] + + const av_bsort1= new Map([% To.json(AuthorisedValues.Get('Bsort1')) | $raw %].map( av => [av.authorised_value, av.lib])); + const av_bsort2= new Map([% To.json(AuthorisedValues.Get('Bsort2')) | $raw %].map( av => [av.authorised_value, av.lib])); + $(document).ready(function(){ let parent_block = $("#[% search_results_block_id | html %]"); @@ -623,7 +627,8 @@ "searchable": true, "orderable": true, "render": function( data, type, row, meta ) { - return escape_str(data); + let bsort2_lib = av_bsort2.get( data.toString() ) || data; + return escape_str( bsort2_lib ); } } @@ -633,7 +638,8 @@ "searchable": true, "orderable": true, "render": function( data, type, row, meta ) { - return escape_str(data); + let bsort1_lib = av_bsort1.get( data.toString() ) || data; + return escape_str( bsort1_lib ); } } -- 2.39.5