From 4147f089dbf8493e36c024e2035af56a2d784005 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. --- .../intranet-tmpl/prog/en/includes/patron-search.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 68df44b596..50b3012184 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -6,6 +6,7 @@ [% USE Asset %] [% USE To %] +[% USE AuthorisedValues %] [%# Display a simple form %] [% BLOCK patron_search_filters_simple %]
@@ -284,6 +285,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(){ $("#info").hide(); @@ -621,7 +626,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 ); } } @@ -631,7 +637,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 ); } } -- 2.30.2