From 48b4d086847d6bce439616c924de3e7ebb793d3d Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Fri, 24 May 2024 13:10:37 -0400 Subject: [PATCH] Improve handling of transfer, confirmation and alert dialogs --- .../RFID/static_files/rfid.js | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Koha/Plugin/Com/ByWaterSolutions/RFID/static_files/rfid.js b/Koha/Plugin/Com/ByWaterSolutions/RFID/static_files/rfid.js index afbe03b..b5ac95f 100644 --- a/Koha/Plugin/Com/ByWaterSolutions/RFID/static_files/rfid.js +++ b/Koha/Plugin/Com/ByWaterSolutions/RFID/static_files/rfid.js @@ -54,22 +54,37 @@ function handle_one_at_a_time( ? form_submit : barcode_input.closest("form").find(":submit"); - const message = $("div.dialog.alert"); - const modal = $("#circ-needsconfirmation-modal"); - - if (modal.length) { + if ($("#wrong-transfer-modal").length && !continue_processing) { + console.log("WRONG TRANSFER"); // Do nothing, the built in modal will reload the page when a button in it is clicked - } else if (message.length && !continue_processing) { + } else if ( + $("#circ-needsconfirmation-modal").length && + !continue_processing + ) { + console.log("NEEDS CONFIMRATION"); + const button = $("#circ-needsconfirmation-modal button.deny"); + button.on("click", function () { + continue_processing = true; + initiate_rfid_scanning(); + }); + } else if ($("div.dialog.alert").length && !continue_processing) { if (action != "renew") { - // renew has it's own "continue" button - console.log("THERE IS A MESSAGE"); + console.log("NEEDS ALERT CONFIRMATION"); + const message = $("div.dialog.alert"); + + //FIXME: Show this button only when necessary const btn = ``; message.append(btn); message.on("click", "button.rfid-continue", function () { - console.log("CLICKED rfid-continue BUTTON"); $("button.rfid-continue").hide(); continue_processing = true; - handle_one_at_a_time(); + handle_one_at_a_time( + action, + security_setting, + barcode_input, + form_submit, + submit_form_automatically, + ); }); } } else if (barcode_input.length) {