Bugzilla – Attachment 165360 Details for
Bug 34608
Add sort1 and sort2 to patron search results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34608: Display dropdown list if linked with AV cat
Bug-34608-Display-dropdown-list-if-linked-with-AV-.patch (text/plain), 4.80 KB, created by
Jonathan Druart
on 2024-04-23 09:20:08 UTC
(
hide
)
Description:
Bug 34608: Display dropdown list if linked with AV cat
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-23 09:20:08 UTC
Size:
4.80 KB
patch
obsolete
>From 858906233c661a91dd32629df0088d887844ce22 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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. >--- > .../prog/en/includes/patron-search.inc | 47 +++++++++++++++---- > 1 file changed, 38 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 ec788f87e5a..f3f9520a4f0 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 %] >@@ -188,8 +190,18 @@ > [% CASE 'phone' %]<th>Phone</th> > [% CASE 'checkouts' %]<th>Checkouts</th> > [% CASE 'account_balance' %]<th>Fines</th> >- [% CASE 'sort1' %]<th>Sort 1</th> >- [% CASE 'sort2' %]<th>Sort 2</th> >+ [% CASE 'sort1' %] >+ [% IF av_bsort1.size %] >+ <th data-filter="av_bsort1">Sort 1</th> >+ [% ELSE %] >+ <th>Sort 1</th> >+ [% END %] >+ [% CASE 'sort2' %] >+ [% IF av_bsort2.size %] >+ <th data-filter="av_bsort2">Sort 2</th> >+ [% ELSE %] >+ <th>Sort 2</th> >+ [% END %] > [% CASE 'action' %]<th class="noExport"> </th> > [% END %] > [% END %] >@@ -257,6 +269,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 %]; >@@ -319,9 +351,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 %]"); >@@ -637,8 +666,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 bsort1 = av_bsort1_map[data.toString()]; >+ return escape_str(bsort1 ? bsort1.lib : data); > } > } > >@@ -648,8 +677,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 bsort2 = av_bsort2_map[data.toString()]; >+ return escape_str(bsort2 ? bsort2.lib : data); > } > } > >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34608
:
154729
|
155343
|
158194
|
159544
|
159545
|
159561
|
162592
|
162593
|
165260
|
165360
|
165375
|
167789
|
170624
|
170625
|
170626
|
170809
|
170810
|
170811
|
170812
|
170936
|
170937