Bugzilla – Attachment 153447 Details for
Bug 29822
Use table column selection modal for DefaultPatronSearchFields preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29822: Escape backslash on split
Bug-29822-Escape-backslash-on-split.patch (text/plain), 6.47 KB, created by
Martin Renvoize (ashimema)
on 2023-07-14 08:55:25 UTC
(
hide
)
Description:
Bug 29822: Escape backslash on split
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-07-14 08:55:25 UTC
Size:
6.47 KB
patch
obsolete
>From 01d2b73e9d3fd417d083f1f29b3895ecd8a570a5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 11 May 2023 11:31:09 +0200 >Subject: [PATCH] Bug 29822: Escape backslash on split > >+ effectively replace 'standard', don't display it. >+ avoid mixing | and , > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 1 + > koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc | 2 +- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 4 ++-- > t/db_dependent/selenium/patrons_search.t | 8 ++++---- > 4 files changed, 8 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index e3316361d6..cf0b77c8fe 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -70,6 +70,7 @@ > > <script> > var defaultPatronSearchFields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' | html %]"; >+ defaultPatronSearchFields = defaultPatronSearchFields.replaceAll('\|', ','); > var defaultPatronSearchMethod = "[% Koha.Preference('DefaultPatronSearchMethod') || 'contains' | html %]"; > var extendedPatronAttributes = "[% Koha.Preference('ExtendedPatronAttributes') | html %]"; > var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]'; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >index b4c5047863..9ec62c2d10 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >@@ -87,7 +87,7 @@ > <select name="searchfieldstype" id="searchfieldstype_filter"> > [% END %] > [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %] >- [% standard.replace('|', ',') %] >+ [% standard = standard.replace('\|', ',') %] > [% SET full_address = 'streetnumber,streettype,address,address2,city,state,zipcode,country' %] > [% SET all_emails = 'email,emailpro,B_email' %] > [% SET all_phones = 'phone,phonepro,B_phone,altcontactphone,mobile' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 65e0ee874d..0e16baf053 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -554,7 +554,7 @@ function buildPatronSearchQuery(term, options) { > let pattern_subquery_and = []; > patterns.forEach(function (pattern, i) { > let pattern_subquery_or = []; >- search_fields.split('|').forEach(function (field, i) { >+ search_fields.split(',').forEach(function (field, i) { > pattern_subquery_or.push( > { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } } > ); >@@ -573,7 +573,7 @@ function buildPatronSearchQuery(term, options) { > > // Add full search term for each search field > let term_subquery_or = []; >- search_fields.split('|').forEach(function (field, i) { >+ search_fields.split(',').forEach(function (field, i) { > term_subquery_or.push( > { ["me." + field]: { 'like': leading_wildcard + term + '%' } } > ); >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index 790ab045eb..7de738bf76 100755 >--- a/t/db_dependent/selenium/patrons_search.t >+++ b/t/db_dependent/selenium/patrons_search.t >@@ -163,18 +163,18 @@ subtest 'Search patrons' => sub { > $driver->get( $base_url . "/members/members-home.pl" ); > my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); > is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); >- is( $adv_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set'); >+ is( $adv_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set'); > my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); > is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); >- is( $filter_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set'); >+ is( $filter_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set'); > C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); > $driver->get( $base_url . "/members/members-home.pl" ); > @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); > is( scalar @adv_options, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields'); >- is( $adv_options[0]->get_value(), 'firstname|initials', 'Standard search uses DefaultPatronSearchFields when populated'); >+ is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated'); > @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); > is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); >- is( $filter_options[0]->get_value(), 'firstname|initials', 'Standard filter uses DefaultPatronSearchFields when populated'); >+ is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated'); > C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses"); > $driver->get( $base_url . "/members/members-home.pl" ); > @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >-- >2.41.0
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 29822
:
144814
|
144831
|
146430
|
146445
|
146488
|
146489
|
146490
|
146491
|
146492
|
147433
|
147434
|
147435
|
147436
|
147437
|
149890
|
149891
|
149892
|
149893
|
149894
|
151058
|
151059
|
151060
|
151061
|
151062
|
151064
|
151233
|
151234
|
151235
|
151236
|
151237
|
151238
|
153373
|
153374
|
153375
|
153376
|
153377
|
153378
|
153379
|
153380
|
153381
|
153382
|
153383
|
153384
|
153442
|
153443
|
153444
|
153445
|
153446
|
153447
|
154361
|
154362
|
154363
|
154364
|
154365
|
154366