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 <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2023-11-01 17:19:09 +00:00 committed by Katrin Fischer
parent 44f7f404fc
commit c52f51b421
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -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 );
}
}