Bug 41039: Prevent patron search button from being spammed triggering multiple api requests

Every click of the "Search" button on members/members-home.pl or other area that utilizes patrons searching,
will trigger another patron search api request. This button should be disabled until the first searches results are displayed.

To demonstrate, open the network tab of the developer console on your web browser. Note each click if the button show another patron search api request.

Test Plan:
1) Browse to members-home.pl
2) Open the network tab of the developer console on your web browser
3) Double click the Search button
4) Note the two api requests in the network tab
5) Apply this patch
6) Reload the page
7) Double click the Search button
8) Note only one api request is made

If your results come back too fast, you may perform an initial search,
then change the number of results from the default 20 to "All" to
create a search that will take longer.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 7db2818bf0)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Kyle M Hall 2025-10-17 07:14:35 -04:00 committed by Paul Derscheid
parent 6733943bd3
commit e203ba8dcc
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 8 additions and 2 deletions

View File

@ -16,7 +16,7 @@
<form method="get" class="patron_search_form">
<div class="hint">Enter patron card number or partial name:</div>
<input type="text" size="40" id="search_patron_filter_simple" class="search_patron_filter focus" autocomplete="off" />
<input type="submit" class="btn btn-primary" value="Search" />
<input type="submit" class="btn btn-primary search_patron_filter_btn" value="Search" />
</form>
[% END %]
@ -105,7 +105,7 @@
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" class="btn btn-primary" value="Search" />
<input type="submit" class="btn btn-primary search_patron_filter_btn" value="Search" />
<input type="button" value="Clear" class="btn btn-default clear_search" />
</fieldset>
</form>
@ -789,6 +789,8 @@
patron_search_form.on('submit', update_search_type);
patron_search_form.on('submit', function(){
parent_block.find(".searchheader").show();
// Disable the search button until results are returned and displayed
patron_search_form.find(".search_patron_filter_btn").prop({disabled: true});
});
@ -911,6 +913,9 @@
}
patrons_table.data('loaded_from_state', false);
first_draw = 1; // Only redirect if we are coming from here
table_dt.on('draw.dt', function () {
patron_search_form.find(".search_patron_filter_btn").prop({disabled: false});
});
table_dt.draw();
return false;
}
@ -924,6 +929,7 @@
patron_search_form.find(".branchcode_filter option:first").prop("selected", true);
patron_search_form.find("select[name='sort1_filter']").val('').trigger("change");
patron_search_form.find("select[name='sort2_filter']").val('').trigger("change");
patron_search_form.find(".search_patron_filter_btn").prop({disabled: false});
parent_block.find(".firstletter_filter").val('');
patron_search_form.find(".search_patron_filter").val('');
[% IF adjust_history %]