Bugzilla – Attachment 132675 Details for
Bug 30055
Rewrite some of the patron searches to make them use the REST API routes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30055: Put extended attributes search back
Bug-30055-Put-extended-attributes-search-back.patch (text/plain), 5.53 KB, created by
Martin Renvoize (ashimema)
on 2022-03-31 08:39:52 UTC
(
hide
)
Description:
Bug 30055: Put extended attributes search back
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-03-31 08:39:52 UTC
Size:
5.53 KB
patch
obsolete
>From b557d354ab6e7a3ee0565f7ddba9ddadc52b1b36 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 10 Feb 2022 18:00:22 +0100 >Subject: [PATCH] Bug 30055: Put extended attributes search back >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Last patches remove the ability to search on extended attributes. >C4::Utils::DataTables::Members::search is searching on all the >attributes that are flagged as "searchable", we want to keep this >behaviour. > >I have tried several things and this is the simplest I have found. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Séverine Queune <severine.queune@bulac.fr> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/members/search.tt | 21 ++++++++++++++++++- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 13 ++++++++++-- > members/search.pl | 5 +++++ > 3 files changed, 36 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >index 112f96a9e5..ed1857207a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >@@ -139,6 +139,10 @@ > map[l.branchcode] = l; > return map; > }, {}); >+ >+ [% IF Koha.Preference('ExtendedPatronAttributes') %] >+ let extended_attribute_types = [% To.json(attribute_type_codes) | $raw %]; >+ [% END %] > </script> > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'js-date-format.inc' %] >@@ -160,7 +164,21 @@ > let start_with = $("#firstletter_filter").val() > if (!start_with) return ""; > return { "like": start_with + "%" } >- } >+ }, >+ [% IF Koha.Preference('ExtendedPatronAttributes') %] >+ "-or": function(){ >+ let filter = $("#searchmember_filter").val(); >+ if (!filter) return ""; >+ return [ >+ { >+ "extended_attributes.value": { "like": "%" + filter + "%" } >+ }, >+ { >+ "extended_attributes.code": extended_attribute_types >+ } >+ ]; >+ }, >+ [% END %] > }; > patrons_table = $("#memberresultst").kohaTable({ > "ajax": { >@@ -177,6 +195,7 @@ > "url": '/api/v1/patrons' > [% END %] > }, >+ embed: ['extended_attributes'], > "order": [[ 1, "asc" ]], > "iDeferLoading": 0, > "columns": [ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 453a333dcf..ffeea60161 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -604,13 +604,22 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > if ( default_filters ) { > let additional_filters = {}; > for ( f in default_filters ) { >+ let k; let v; > if ( typeof(default_filters[f]) === 'function' ) { > let val = default_filters[f](); > if ( val != undefined && val != "" ) { >- additional_filters[f] = val; >+ k = f; v = val; > } > } else { >- additional_filters[f] = default_filters[f]; >+ k = f; v = default_filters[f]; >+ } >+ >+ // Pass to -or if you want a separate OR clause >+ // It's not the usual DBIC notation! >+ if ( f == '-or' ) { >+ if (v) or_query_parameters.push(v) >+ } else if ( v ) { >+ additional_filters[k] = v; > } > } > if ( Object.keys(additional_filters).length ) { >diff --git a/members/search.pl b/members/search.pl >index 4689cf89b1..b53773ad00 100755 >--- a/members/search.pl >+++ b/members/search.pl >@@ -18,8 +18,10 @@ > use Modern::Perl; > > use CGI qw ( -utf8 ); >+use C4::Context; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); >+use Koha::Patron::Attribute::Types; > > my $input = CGI->new; > >@@ -45,5 +47,8 @@ $template->param( > filter => $filter, > selection_type => $selection_type, > alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), >+ attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >+ ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >+ : [] ), > ); > output_html_with_http_headers( $input, $cookie, $template->output ); >-- >2.20.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 30055
:
130364
|
130365
|
130366
|
130367
|
130368
|
130369
|
130370
|
130371
|
130372
|
130385
|
130386
|
130387
|
130388
|
130389
|
130390
|
130391
|
130392
|
130393
|
130394
|
130395
|
130457
|
130487
|
130488
|
130491
|
130507
|
130511
|
130629
|
130630
|
130671
|
130672
|
130701
|
130702
|
130704
|
130716
|
130717
|
131829
|
132168
|
132419
|
132420
|
132421
|
132422
|
132423
|
132424
|
132425
|
132426
|
132427
|
132428
|
132429
|
132430
|
132431
|
132432
|
132433
|
132434
|
132435
|
132436
|
132437
|
132438
|
132439
|
132440
|
132441
|
132450
|
132451
|
132452
|
132453
|
132454
|
132455
|
132456
|
132457
|
132458
|
132459
|
132460
|
132461
|
132462
|
132463
|
132464
|
132465
|
132466
|
132467
|
132468
|
132469
|
132470
|
132471
|
132472
|
132473
|
132539
|
132616
|
132617
|
132618
|
132619
|
132620
|
132621
|
132622
|
132623
|
132624
|
132625
|
132627
|
132628
|
132629
|
132630
|
132631
|
132632
|
132633
|
132634
|
132635
|
132636
|
132637
|
132638
|
132639
|
132640
|
132641
|
132664
|
132665
|
132666
|
132667
|
132668
|
132669
|
132670
|
132671
|
132672
|
132673
|
132674
| 132675 |
132676
|
132677
|
132678
|
132679
|
132680
|
132681
|
132682
|
132683
|
132684
|
132685
|
132686
|
132687
|
132688