From 1dc88130d108b28db128a48d993ad1dcfd4ad889 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 23 Apr 2024 11:19:22 +0200 Subject: [PATCH] Bug 34608: Display dropdown list if linked with AV cat If at least one AV exists for bsort1 we will show a dropdown list in the column filter for bsort1. Same for bsort2. Signed-off-by: Owen Leonard Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- .../prog/en/includes/patron-search.inc | 47 +++++++++++++++---- .../prog/en/modules/circ/circulation.tt | 1 + 2 files changed, 39 insertions(+), 9 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 493b3f8cc6..a1f2d8ff45 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -8,6 +8,8 @@ [% USE To %] [% USE AuthorisedValues %] [% SET search_results_block_id = 'searchresults' %] +[% SET av_bsort1 = AuthorisedValues.Get('Bsort1') %] +[% SET av_bsort2 = AuthorisedValues.Get('Bsort2') %] [%# Display a simple form %] [% BLOCK patron_search_filters_simple %] @@ -178,8 +180,18 @@ [% CASE 'phone' %]Phone [% CASE 'checkouts' %]Checkouts [% CASE 'account_balance' %]Fines - [% CASE 'sort1' %]Sort 1 - [% CASE 'sort2' %]Sort 2 + [% CASE 'sort1' %] + [% IF av_bsort1.size %] + Sort 1 + [% ELSE %] + Sort 1 + [% END %] + [% CASE 'sort2' %] + [% IF av_bsort2.size %] + Sort 2 + [% ELSE %] + Sort 2 + [% END %] [% CASE 'action' %]  [% END %] [% END %] @@ -247,6 +259,26 @@ return map; }, {}); + + const av_bsort1= [% To.json(av_bsort1) | $raw %].map( e => { + e['_id'] = e.authorised_value; + e['_str'] = e.lib; + return e; + }); + var av_bsort1_map = av_bsort1.reduce((map, e) => { + map[e._id] = e; + return map; + }, {}); + const av_bsort2= [% To.json(av_bsort2) | $raw %].map( e => { + e['_id'] = e.authorised_value; + e['_str'] = e.lib; + return e; + }); + var av_bsort2_map = av_bsort2.reduce((map, e) => { + map[e._id] = e; + return map; + }, {}); + [% IF Koha.Preference('ExtendedPatronAttributes') %] [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %] var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; @@ -309,9 +341,6 @@ 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 %]"); @@ -627,8 +656,8 @@ "searchable": true, "orderable": true, "render": function( data, type, row, meta ) { - let bsort2_lib = av_bsort2.get( data.toString() ) || data; - return escape_str( bsort2_lib ); + let bsort1 = av_bsort1_map[data.toString()]; + return escape_str(bsort1 ? bsort1.lib : data); } } @@ -638,8 +667,8 @@ "searchable": true, "orderable": true, "render": function( data, type, row, meta ) { - let bsort1_lib = av_bsort1.get( data.toString() ) || data; - return escape_str( bsort1_lib ); + let bsort2 = av_bsort2_map[data.toString()]; + return escape_str(bsort2 ? bsort2.lib : data); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index c31e66bd86..cf0abcc992 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1071,6 +1071,7 @@ [% FOREACH wh IN waiting_holds %] waiting_holds_barcodes.push("[% wh.item.barcode | html %]"); [% END %] + console.log(waiting_holds_barcodes); $("#mainform").on('submit', function(){ if( $("#checkout_confirmed").length > 0 ){ return true; -- 2.39.5