From b39f669fa8879653754f1deb707e8b4da9f446d3 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 9 Feb 2024 18:14:50 +0000 Subject: [PATCH] Bug 36060: Simplify logic to enable/disable CheckinChecked/RenewChecked buttons This patch attempts to simplify for disabling/enabling the 'Check in selected items' and 'Renewal selected items' buttons. To test: 1. APPLY patch, clear browser's cache 2. Have more than 1 checkout issued to a borrower. 3. Load the checkout table on circ/circulation.pl 4. Notice that there is now 'Renew selected items' and 'Checkin selected items' button. 5. Play around with each making sure that they work as excepted when checkouts are checked in either the 'Check in' or 'Renew' columns. 6. Uncheck everything in the 'Renew column', the 'Renew selected items' button should be disabled. 7. Uncheck everything in the 'Checkin column', the 'Checkin selected items' button should be disabled. 8. Try unchecking some of these to make sure the Renew/Checkin button is properly disabled when no related checkboxes are checked. 9. Try using the select all/none options at the top of both the 'Renew' and 'Checkin' columns. Make sure the 'Renew selected items' and 'Checkin selected items' become properly disabled/enabled. 10. Make sure the 'Renew all' button still works properly. 11. Have two checkouts. Click one for Renew and one for Checkin. Click on Check in selected items. 12. When the table reloads the 'renew' selections should be retained 13. Have two checkouts. Click one for Renew and one for Checkin. Click on Renew selected items. 14. When the table reloads the 'check in' selections should be retained 15. Have overdues 16. Go to a patron account and load the issue table 17. The items that are overdue are checked for renewal by default 16. The 'Renew selected items' button show be enabled. Signed-off-by: Brendan Lawlor Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 39 ++++++++------------ 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index c5b474e027..449ce57e97 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,5 +1,9 @@ /* global __ */ +function CheckRenewCheckinBoxes() { + $('#RenewChecked').prop('disabled', !$('.renew:checked').length ); + $('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); +} function RefreshIssuesTable() { var table = $('#issues-table').DataTable(); @@ -10,21 +14,9 @@ function RefreshIssuesTable() { return this.value; }).get(); table.ajax.reload( function() { - $('#RenewChecked, #CheckinChecked').prop('disabled' , true ); - if ( renewchecked.length ) { - $('#RenewChecked').prop('disabled' , false ); - renewchecked.forEach( function(checked) { - $('.renew[value="'+checked+'"]').prop('checked' , true ); - }); - } - if ( checkinchecked.length ) { - $('#CheckinChecked').prop('disabled' , false ); - checkinchecked.forEach( function(checked) { - $('.checkin[value="'+checked+'"]').prop('checked' , true ); - }); - } - var checkout_count = table.page.info().recordsTotal; - $('.checkout_count').text(checkout_count); + CheckRenewCheckinBoxes(); + var checkout_count = table.page.info().recordsTotal; + $('.checkout_count').text(checkout_count); }); } @@ -437,6 +429,8 @@ function LoadIssuesTable() { } }, "initComplete": function(oSettings, json) { + CheckRenewCheckinBoxes(); + // Build a summary of checkouts grouped by itemtype var checkoutsByItype = json.aaData.reduce(function (obj, row) { obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1; @@ -502,13 +496,13 @@ $(document).ready(function() { $("#CheckAllRenewals").on("click",function(){ $("#UncheckAllCheckins").click(); $(".renew:visible").prop("checked", true); - $('#RenewChecked').prop('disabled', !$('.renew:checked').length ); + CheckRenewCheckinBoxes(); showHideOnHoldRenewal(); return false; }); $("#UncheckAllRenewals").on("click",function(){ $(".renew:visible").prop("checked", false); - $('#RenewChecked').prop('disabled', !$('.renew:checked').length ); + CheckRenewCheckinBoxes(); showHideOnHoldRenewal(); return false; }); @@ -516,12 +510,12 @@ $(document).ready(function() { $("#CheckAllCheckins").on("click",function(){ $("#UncheckAllRenewals").click(); $(".checkin:visible").prop("checked", true); - $('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); + CheckRenewCheckinBoxes(); return false; }); $("#UncheckAllCheckins").on("click",function(){ $(".checkin:visible").prop("checked", false); - $('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); + CheckRenewCheckinBoxes(); return false; }); @@ -540,15 +534,13 @@ $(document).ready(function() { if ( $(this).is(":checked") ) { $( "#checkin_" + $(this).val() ).prop("checked", false); } - $('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); - $('#RenewChecked').prop('disabled', !$('.renew:checked').length ); + CheckRenewCheckinBoxes(); }); $(document).on("change", '.checkin', function(){ if ( $(this).is(":checked") ) { $( "#renew_" + $(this).val() ).prop("checked", false); } - $('#CheckinChecked').prop('disabled', !$('.checkin:checked').length ); - $('#RenewChecked').prop('disabled', !$('.renew:checked').length ); + CheckRenewCheckinBoxes(); }); // Display on hold due dates input when an on hold item is @@ -647,6 +639,7 @@ $(document).ready(function() { $('#RenewChecked, #CheckinChecked').prop('disabled' , true ); }); + CheckRenewCheckinBoxes(); // Prevent form submit return false; }); -- 2.39.5