Bug 41040: Prevent form submission if no filters have been selected

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Kyle M Hall 2025-11-04 08:54:02 -05:00 committed by Lucas Gass
parent 222e3161cc
commit 4fe4809518
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 21 additions and 5 deletions

View File

@ -6,7 +6,20 @@
[% IF CAN_user_borrowers_edit_borrowers || CAN_user_borrowers_list_borrowers %]
[%- SET searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%]
[% WRAPPER tab_panel tabname="patron_search" bt_active= bs_tab_active %]
<form method="get" action="/cgi-bin/koha/members/member.pl">
<form method="get" action="/cgi-bin/koha/members/member.pl" onsubmit="return validatePatronSearch(this);">
<script>
function validatePatronSearch(form) {
const searchTerm = form.searchmember.value.trim();
const branchSelected = form.branchcode_filter && form.branchcode_filter.value !== "";
const categorySelected = form.categorycode_filter && form.categorycode_filter.value !== "";
if (!searchTerm && !branchSelected && !categorySelected) {
alert("Please enter a search term or select a library/category");
return false;
}
return true;
}
</script>
<input type="hidden" name="quicksearch" value="1" />
<div class="form-title">
@ -23,7 +36,7 @@
<button type="button" class="form-extra-content-toggle" title="More options"><i class="form-extra-content-icon fa-solid fa-sliders" aria-hidden="true"></i></button>
</div>
<button type="submit" aria-label="Search"><i class="fa fa-arrow-right"></i></button>
<button type="submit" class="btn btn-primary" aria-label="Search"><i class="fa fa-arrow-right"></i></button>
<div class="form-extra-content">
<div> [% INCLUDE patron_fields_dropdown search_box=1 %] </div>

View File

@ -69,16 +69,19 @@ my $searchtype = $input->param('searchtype');
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
my $branchcode_filter = scalar $input->param('branchcode_filter');
my $categorycode_filter = scalar $input->param('categorycode_filter');
$template->param(
patron_lists => [ GetPatronLists() ],
searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'),
branchcode_filter => $branchcode_filter,
categorycode_filter => $categorycode_filter,
searchtype => $searchtype,
searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
circsearch => $circsearch,
defer_loading => $searchmember ? 0 : 1,
defer_loading => ( $searchmember || $branchcode_filter || $categorycode_filter ) ? 0 : 1,
);
output_html_with_http_headers $input, $cookie, $template->output;