From ce1c4f78b41bd4e359779cad0bc78b2a43c3b35a 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 51a8cfb49d..30119add0b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -5,6 +5,7 @@ [% USE Asset %] [% USE To %] +[% USE AuthorisedValues %] [%# Display a simple form %] [% BLOCK patron_search_filters_simple %]
@@ -282,6 +283,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(); @@ -619,7 +624,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 ); } } @@ -629,7 +635,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