From df8da506b4420e57024ada4116911b391553c7aa Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 12 Oct 2022 18:24:01 +0000 Subject: [PATCH] Bug 28366: Add batch patron modification to patron search results This patch adds the ability to send selected patrons for batch modification. It does this by adding a hidden form which is populated from the borrowernumbers stored in the browser's localStorage when selections are made. To test, apply the patch and perform a patron search in the staff client which will return multiple pages of results. - Select a patron on the first page of results. - The "Add to patron list" and "Batch patron modification" buttons should become active, and the "Patrons selected" box should show "1" - After checking another checkbox the "Merge selected patrons" button should activate and the "selected" count should increment. - Test making selections on other pages of results. The "selected" count should continue to increment. - Test the "Batch patron modification" button, confirming that all the patrons you selected are correctly passed to the batch patron modification tool. - Test that the "Clear" control works correctly to clear all checkboxes and disable all other buttons. - Test that the "Select all" and "Clear all" controls work correctly, enabling all buttons and correctly incrementing the "selected" count. Signed-off-by: Laura Escamilla --- .../prog/en/modules/members/member.tt | 58 +++++++++++++------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt index deb8374d74..d1840df223 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt @@ -96,8 +96,17 @@ [% END %] [% IF CAN_user_borrowers_edit_borrowers %] - +
+ +
+ [% END %] + + [% IF CAN_user_tools_edit_patrons %] +
+ +
[% END %] + + [% IF CAN_user_tools_edit_patrons %] +
+ + +
+ [% END %] @@ -159,7 +174,7 @@ } $(document).ready(function() { - $('#merge-patrons').prop('disabled', true); + $('#merge-patrons, #batch-mod-patrons').prop('disabled', true); $('#memberresultst').on('change', 'input.selection', function() { var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; var borrowernumber = $(this).val(); @@ -182,17 +197,16 @@ } } if ( patron_search_selections.length > 1 ) { - /* More than one checkbox has been checked */ - $('#merge-patrons').prop('disabled', false).removeClass("disabled"); - $("#patronlist-menu").removeClass("disabled").prop("disabled", false); + /* More than one checkbox has been checked. All batch options enabled */ + $("#batch-mod-patrons, #merge-patrons, #patronlist-menu").removeClass("disabled").prop("disabled", false); } else if ( patron_search_selections.length == 1 ) { - /* At least one checkbox has been checked */ + /* Only one checkbox has been checked */ + $("#batch-mod-patrons, #patronlist-menu").removeClass("disabled").prop("disabled", false); + /* Merge requires more than one selection */ $('#merge-patrons').prop('disabled', true).addClass("disabled"); - $("#patronlist-menu").removeClass("disabled").prop("disabled", false); } else { - /* No checkbox has been checked */ - $('#merge-patrons').prop('disabled', true).addClass("disabled"); - $("#patronlist-menu").addClass("disabled").prop("disabled", true); + /* No checkbox has been checked. No batch options enabled */ + $("#batch-mod-patrons, #merge-patrons, #patronlist-menu").addClass("disabled").prop("disabled", true); } }); @@ -204,11 +218,11 @@ $("#clear-patron-selection").on("click", function(e){ e.preventDefault(); - $(".selection").prop("checked", false).change(); + $("input.selection").prop("checked", false).change(); localStorage.removeItem("patron_search_selections"); $("#patron_search_selected").hide(); - $('#merge-patrons').prop('disabled', true).addClass("disabled"); - $("#patronlist-menu").addClass("disabled").prop("disabled", true); + $('#merge-patrons, #patronlist-menu, #batch-mod-patrons').prop('disabled', true).addClass("disabled"); + $("#borrowernumberlist").val(""); }); $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ @@ -230,7 +244,16 @@ patronListAdd(); } - }) + }); + + $("#batch-mod-patrons").on("click", function(e) { + e.preventDefault(); + var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; + if( patron_search_selections.length > 0 ){ + $("#borrowernumberlist").html( patron_search_selections.join('\n') ); + $("#patron_batchmod_form").submit(); + } + }); /* Submit selected patrons to a list via AJAX */ $("#new-patron-list_form").on('submit', function(e){ @@ -255,7 +278,7 @@ $("#select_all").on("click",function(e){ e.preventDefault(); - $(".selection").each(function(){ + $("input.selection").each(function(){ if( $(this).prop("checked") == false ){ $(this).prop( "checked", true ).change(); } @@ -263,7 +286,7 @@ }); $("#clear_all").on("click",function(e){ e.preventDefault(); - $(".selection").each(function(){ + $("input.selection").each(function(){ if( $(this).prop("checked") ){ $(this).prop("checked", false ).change(); } @@ -339,8 +362,7 @@ }); if( selected_patrons.length > 1 ){ - $('#merge-patrons').removeClass("disabled").prop('disabled', false); - $('#patronlist-menu').removeClass("disabled").prop('disabled', false); + $('#batch-mod-patrons, #merge-patrons, #patronlist-menu').removeClass("disabled").prop('disabled', false); } } } -- 2.30.2