From f053083af35e0ed8c897eab538f6b2327f0779b6 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 8 Jun 2021 08:26:40 +0200 Subject: [PATCH] SCI-5789: Fix multiple requests being triggered after saving report to inventory. --- .../reports/save_pdf_to_inventory.js | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/reports/save_pdf_to_inventory.js b/app/assets/javascripts/reports/save_pdf_to_inventory.js index bb5968fb0..cecd7af94 100644 --- a/app/assets/javascripts/reports/save_pdf_to_inventory.js +++ b/app/assets/javascripts/reports/save_pdf_to_inventory.js @@ -226,26 +226,24 @@ clearDropdownResultsCallback(INVENTORY_PICKER); } - function initializeSubmitAction() { - $('#content-reports-index').on('click', '#savePDFtoInventorySubmit', function() { - animateSpinner(); - $.ajax({ - url: $('#savePDFtoInventorySubmit').data('target-url'), - data: SELECTED_IDS, - type: 'POST', - success: function(data) { - animateSpinner(null, false); - HelperModule.flashAlertMsg(data.message, 'success'); - $('#savePDFtoInventory').modal('hide'); - }, - error: function(xhr) { - animateSpinner(null, false); - HelperModule.flashAlertMsg(xhr.responseJSON.message, 'danger'); - $('#savePDFtoInventory').modal('hide'); - } - }); + $('#content-reports-index').on('click', '#savePDFtoInventorySubmit', function() { + animateSpinner(); + $.ajax({ + url: $('#savePDFtoInventorySubmit').data('target-url'), + data: SELECTED_IDS, + type: 'POST', + success: function(data) { + animateSpinner(null, false); + HelperModule.flashAlertMsg(data.message, 'success'); + $('#savePDFtoInventory').modal('hide'); + }, + error: function(xhr) { + animateSpinner(null, false); + HelperModule.flashAlertMsg(xhr.responseJSON.message, 'danger'); + $('#savePDFtoInventory').modal('hide'); + } }); - } + }); /* * INITIALIZERS @@ -254,7 +252,6 @@ function initializeSavePDFtoInventoryModal() { $('#content-reports-index').on('shown.bs.modal', '#savePDFtoInventory', function() { initInventoriesSelectPicker(); - initializeSubmitAction(); clearErrors(); // refresh the dropdown state $('#selectInventory').parent().find('input').trigger('keyup');