Bugzilla – Attachment 152828 Details for
Bug 34094
Apply DefaultPatronSearchMethod to all patron search forms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34094: Use DefaultPatronSearchMethod consistently
Bug-34094-Use-DefaultPatronSearchMethod-consistent.patch (text/plain), 9.81 KB, created by
Sam Lau
on 2023-06-28 15:47:56 UTC
(
hide
)
Description:
Bug 34094: Use DefaultPatronSearchMethod consistently
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2023-06-28 15:47:56 UTC
Size:
9.81 KB
patch
obsolete
>From afcc6b2b633878a14a2aa63457772c93d4fd1473 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 22 Jun 2023 15:37:55 +0100 >Subject: [PATCH] Bug 34094: Use DefaultPatronSearchMethod consistently > >This patch updates the patron search bar and pages to default search >method to that defined by DefaultPatronSearchMethod system preference. > >Test plan >1) Prior to this patch confirm that regardless of what you set > DefaultPatronSearchMethod to, the search in /members/member.pl, > members/members-home.pl and the search from the patrons search top bar > all default to 'contains'. >2) Apply the patch >3) Confirm that the system preference now affects the default option for > match type upon page load. > >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > circ/circulation.pl | 2 -- > .../prog/en/includes/member-search-box.inc | 11 +++++---- > .../prog/en/includes/patron-search.inc | 23 ++++++++++--------- > .../prog/en/modules/members/member.tt | 3 ++- > members/member.pl | 1 - > 5 files changed, 20 insertions(+), 20 deletions(-) > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 7b35a8c860..9b925e29ad 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -150,8 +150,6 @@ my @failedreturns = $query->multi_param('failedreturn'); > our %return_failed = (); > for (@failedreturns) { $return_failed{$_} = 1; } > >-my $searchtype = $query->param('searchtype') || q{contain}; >- > my $branch = C4::Context->userenv->{'branch'}; > > for my $barcode ( @$barcodes ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-search-box.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-search-box.inc >index 09d3a4e3a0..42543b2a1e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-search-box.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-search-box.inc >@@ -4,6 +4,7 @@ > [% USE Koha %] > [% PROCESS 'patronfields.inc' %] > [% IF CAN_user_borrowers_edit_borrowers %] >+ [%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%] > [% IF( bs_tab_active ) %] > <div id="patron_search" role="tabpanel" class="tab-pane active"> > [% ELSE %] >@@ -36,12 +37,12 @@ > <div> > <label for="searchtype" class="control-label">Search type</label> > <select name="searchtype" id="searchtype" class="form-control"> >- [% IF searchtype == 'start_with' %] >- <option value='start_with' selected='selected'>Starts with</option> >- <option value='contain'>Contains</option> >+ [% IF searchtype == 'starts_with' %] >+ <option value='starts_with' selected='selected'>Starts with</option> >+ <option value='contains'>Contains</option> > [% ELSE %] >- <option value='start_with'>Starts with</option> >- <option value='contain' selected='selected'>Contains</option> >+ <option value='starts_with'>Starts with</option> >+ <option value='contains' selected='selected'>Contains</option> > [% END %] > </select> > </div> >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 0a603483b6..fcd5dbb677 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -20,7 +20,8 @@ > [%# - branch: select library list %] > [%# - category: select patron category list %] > [%# - search_field: select patron field list %] >-[%# - search_type: select 'contain' or 'start with' %] >+[%# - search_type: select 'contains' or 'starts with' %] >+[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%] > [% BLOCK patron_search_filters %] > <form id="patron_search_form"> > <fieldset class="brief"> >@@ -74,12 +75,12 @@ > <li> > <label for="searchtype_filter">Search type:</label> > <select name="searchtype" id="searchtype_filter"> >- [% IF searchtype == "start_with" %] >- <option value='start_with' selected="selected">Starts with</option> >- <option value="contain">Contains</option> >+ [% IF searchtype == "starts_with" %] >+ <option value='starts_with' selected="selected">Starts with</option> >+ <option value="contains">Contains</option> > [% ELSE %] >- <option value='start_with'>Starts with</option> >- <option value="contain" selected="selected">Contains</option> >+ <option value='starts_with'>Starts with</option> >+ <option value="contains" selected="selected">Contains</option> > [% END %] > </select> > </li> >@@ -339,7 +340,7 @@ > } > let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length }); > >- let search_type = $("#searchtype_filter").val() || "contain"; >+ let search_type = $("#searchtype_filter").val() || "contains"; > let search_fields = $("#searchfieldstype_filter").val(); > if ( !search_fields ) { > search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; >@@ -349,7 +350,7 @@ > patterns.forEach(function(pattern,i){ > let sub_or = []; > search_fields.split(',').forEach(function(attr,ii){ >- sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}}); >+ sub_or.push({["me."+attr]:{"like":(search_type == "contains" ? "%" : "" ) + pattern + "%"}}); > if ( attr == 'dateofbirth' ) { > try { > let d = $date_to_rfc3339(pattern); >@@ -368,7 +369,7 @@ > patterns.forEach(function(pattern,i){ > let sub_or = []; > sub_or.push({ >- "extended_attributes.value": { "like": "%" + pattern + (search_type == "contain" ? "%" : "" )}, >+ "extended_attributes.value": { "like": "%" + pattern + (search_type == "contains" ? "%" : "" )}, > "extended_attributes.code": extended_attribute_types > }); > subquery_and.push(sub_or); >@@ -758,7 +759,7 @@ > function update_search_description(){ > var searched = $("#searchfieldstype_filter").find("option:selected").text(); > if ( $("#search_patron_filter").val() ) { >- if ( $("#searchtype_filter").val() == 'start_with' ) { >+ if ( $("#searchtype_filter").val() == 'starts_with' ) { > searched += _(" starting with "); > } else { > searched += _(" containing "); >@@ -846,7 +847,7 @@ > > function clearFilters() { > $("#searchfieldstype_filter option:first").prop("selected", true); >- $("#searchtype_filter option[value='contain']").prop("selected", true); >+ $("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true); > $("#categorycode_filter option:first").prop("selected", true); > $("#branchcode_filter option:first").prop("selected", true); > $("#sort1_filter").val('').trigger("change"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >index 1966c6e8a9..7b747e8171 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >@@ -9,6 +9,7 @@ > [% SET libraries = Branches.all %] > [% SET categories = Categories.all.unblessed %] > [% SET columns = ['cardnumber', 'name-address', 'dateofbirth', 'branch', 'category', 'dateexpiry', 'checkouts', 'account_balance', 'borrowernotes', 'action'] %] >+[% SET searchtype = Koha.Preference('DefaultPatronSearchMethod') %] > [% PROCESS 'patron-search.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Patrons[% IF ( searching ) %] › Search results[% END %] › Koha</title> >@@ -282,7 +283,7 @@ > $("searchfieldstype_filter").val("[% searchfieldstype | html %]"); > [% END %] > [% IF searchtype %] >- $("#searchtype_filter").val("[% searchtype | html %]"); >+ $("#searchtype_filter option[value='[% searchtype | html %]']").prop("selected", true); > [% END %] > [% IF categorycode_filter %] > $("#categorycode_filter").val("[% categorycode_filter | html %]"); >diff --git a/members/member.pl b/members/member.pl >index 54c3e81ac1..909341bcd7 100755 >--- a/members/member.pl >+++ b/members/member.pl >@@ -75,7 +75,6 @@ $template->param( > searchmember => $searchmember, > branchcode_filter => scalar $input->param('branchcode_filter'), > categorycode_filter => scalar $input->param('categorycode_filter'), >- searchtype => scalar $input->param('searchtype') || 'contain', > searchfieldstype => $searchfieldstype, > PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, > do_not_defer_loading => !$defer_loading, >-- >2.30.2
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 34094
:
152567
|
152726
|
152742
|
152787
|
152827
|
152828
|
152881
|
153324