Bug 31566: 'Patrons selected' counter doubles on 'Select all'

This patch refines the JavaScript which is run when the "Select all"
or "Clear all" controls are clicked. The script now checks to see
whether the checkbox is checked before triggering the change function.

To test, apply the patch and perform a patron search in the staff
interface which will return multiple results.

- After the patron search results are displayed, test the "Select
  all" control. The visible search results should all be checked,
  and the "Patrons selected" counter at the top should be
  incremented correctly.
- Clicking the "Select all" control again should have no effect.
  The "Patrons selected" counter should not increment again.
- Test the "Clear all" control to confirm that checkboxes are
  unchecked and the counter updates correctly.
- Test with multiple pages of patron search results to confirm
  that the controls work correctly on any page of results..

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2022-09-23 15:22:34 +00:00 committed by Tomas Cohen Arazi
parent 1524afa8c7
commit aa49b1bed9
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -252,11 +252,19 @@
$("#select_all").on("click",function(e){
e.preventDefault();
$(".selection").prop("checked", true).change();
$(".selection").each(function(){
if( $(this).prop("checked") == false ){
$(this).prop( "checked", true ).change();
}
});
});
$("#clear_all").on("click",function(e){
e.preventDefault();
$(".selection").prop("checked", false).change();
$(".selection").each(function(){
if( $(this).prop("checked") ){
$(this).prop("checked", false ).change();
}
});
});
[% IF searchmember %]