From 28f9527cf2145c0e26fa4e36c37e3fb7dc5a5bb4 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 14 Nov 2025 12:05:23 +0100 Subject: [PATCH] Bug 19814: Polishing js in template Content-Type: text/plain; charset=utf-8 When going back to single mode, we should respond to Enter again. Remove enabling the batch mode from the input event. Obsoleting variable isReceivingRFIDInput. --- .../prog/en/modules/circ/returns.tt | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 00dd18378d..df41206a9a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -1919,9 +1919,8 @@ ], }); - // Debounce variables for RFID batch input + // Debounce variable for RFID batch input let debounceTimer; - let isReceivingRFIDInput = false; // Batch mode toggle functionality $('#batch-mode-toggle').on('change', function() { @@ -1957,43 +1956,26 @@ // Handle RFID input with debouncing $('#barcode').on('input paste', function(e) { - const currentValue = $(this).val(); - - // Clear any existing timer - clearTimeout(debounceTimer); - - // Check if this looks like RFID batch input (contains newlines) - if (currentValue.includes('\n')) { - isReceivingRFIDInput = true; - - // Auto-enable batch mode if not already enabled - if (!$('#batch-mode-toggle').is(':checked')) { - $('#batch-mode-toggle').prop('checked', true).trigger('change'); - } - - // Set a debounce timer to submit after RFID scanning finishes + clearTimeout(debounceTimer); // Clear any existing timer + if ( $(this).val().match('\n$') ) { + // After a newline (in batch mode), set debounce timer + // Form submits when there is no further input debounceTimer = setTimeout(function() { - isReceivingRFIDInput = false; - ChangeBatchCheckinSettings(); $('#checkin-form').submit(); }, debounceInterval); // delay after last input } }); - // Prevent immediate form submission on Enter if receiving RFID input + // Only submit after Enter in single mode $('#barcode').on('keydown', function(e) { - if (e.which === 13 && isReceivingRFIDInput) { + if ( e.which === 13 && !$('#batch-mode-toggle').prop('checked') ) { e.preventDefault(); - return false; + $('#checkin-form').submit(); } }); - // Prevent form submission during RFID input $('#checkin-form').on('submit', function(e) { - if (isReceivingRFIDInput) { - e.preventDefault(); - return false; - } + ChangeBatchCheckinSettings(); }); [% IF ( !(Koha.Preference('TransfersBlockCirc')) && Koha.Preference('AutomaticConfirmTransfer') ) %] -- 2.39.5