Bug 35127: Fix 'Search type' for patron search

We need to fallback on the syspref DefaultPatronSearchMethod but keep
the value when one is passed!

Test plan:
Search for patrons, and use the "search type". Set it to different
values than DefaultPatronSearchMethod and confirm that the value is
kept.
Fix is expected when searching for patrons in the header (use the
options to select a different value and run the search)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-10-24 15:32:53 +02:00 committed by Tomas Cohen Arazi
parent 5b803d2b2a
commit e08bf3bb4c
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 7 additions and 5 deletions

View file

@ -4,7 +4,7 @@
[% USE Koha %]
[% PROCESS 'patronfields.inc' %]
[% IF CAN_user_borrowers_edit_borrowers %]
[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%]
[%- SET searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%]
[% IF( bs_tab_active ) %]
<div id="patron_search" role="tabpanel" class="tab-pane active">
[% ELSE %]

View file

@ -23,7 +23,7 @@
[%# - sort2: select patron sort2 field %]
[%# - search_field: select patron field list %]
[%# - search_type: select 'contains' or 'starts with' %]
[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%]
[%- searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%]
[% BLOCK patron_search_filters %]
<form id="patron_search_form">
<fieldset class="brief">
@ -318,7 +318,7 @@
"-and": function(){
let filters = [];
let search_type = $("#searchtype_filter").val() || "contains";
let search_type = $("#searchtype_filter").val();
let search_fields = $("#searchfieldstype_filter").val() || "standard";
let pattern = $("#search_patron_filter").val();
@ -817,7 +817,7 @@
function clearFilters() {
$("#searchfieldstype_filter option:first").prop("selected", true);
$("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true);
$("#searchtype_filter option[value='[% searchtype | html %]']").prop("selected", true);
$("#categorycode_filter option:first").prop("selected", true);
$("#branchcode_filter option:first").prop("selected", true);
$("#sort1_filter").val('').trigger("change");

View file

@ -11,7 +11,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') %]
[% SET searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') %]
[% PROCESS 'patron-search.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]

View file

@ -65,6 +65,7 @@ if ( $quicksearch and $searchmember && !$circsearch ) {
}
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
my $searchtype = $input->param('searchtype');
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
@ -75,6 +76,7 @@ $template->param(
searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'),
searchtype => $searchtype,
searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
do_not_defer_loading => !$defer_loading,