Bug 41040: (follow-up) Move JS to global JS file

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2026-02-13 11:31:30 -05:00 committed by Laura Escamilla
parent 5477c637d0
commit b1fdee831e
No known key found for this signature in database
GPG Key ID: 6B1D9CA1AF817BC3
2 changed files with 30 additions and 20 deletions

View File

@ -6,25 +6,7 @@
[% 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" 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) {
$(form.searchmember)
.tooltip({ trigger: "manual", placement: "bottom", title: _("Please enter a card number or name") })
.tooltip("show");
$(document).on("click", function () {
$(form.searchmember).tooltip("hide");
});
return false;
}
return true;
}
</script>
<form id="patron_header_search" method="get" action="/cgi-bin/koha/members/member.pl">
<input type="hidden" name="quicksearch" value="1" />
<div class="form-title">

View File

@ -1,5 +1,5 @@
/* global shortcut delBasket AUDIO_ALERT_PATH Cookies */
/* exported addBibToContext delBibToContext escape_str escape_price openWindow _ removeFocus toUC confirmDelete confirmClone playSound */
/* exported addBibToContext delBibToContext escape_str escape_price openWindow _ removeFocus toUC confirmDelete confirmClone playSound validatePatronSearch */
if (KOHA === undefined) var KOHA = {};
function _(s) {
@ -464,6 +464,11 @@ $(document).ready(function () {
e.preventDefault();
togglePanel($(this));
});
$("#patron_header_search").on("submit", function (e) {
e.preventDefault();
validatePatronSearch($(this)[0]);
});
});
function removeLastBorrower() {
@ -1023,3 +1028,26 @@ function getScrollto(target, elemid) {
}
return yoffset.top - elem_height - 20;
}
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) {
$(form.searchmember)
.tooltip({
trigger: "manual",
placement: "bottom",
title: __("Please enter a card number or name"),
})
.tooltip("show");
$(document).on("click", function () {
$(form.searchmember).tooltip("hide");
});
return false;
}
return true;
}