JBAS-914 Prevent creation of extra lieitem copies
authorBill Erickson <berickxx@gmail.com>
Wed, 30 Sep 2015 21:49:21 +0000 (17:49 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Prevent the API call which creates/modifies copies for a linteitem in
the lineitem copy UI from running if one is already in flight.  This is
done both by disabling the Save Changes button and by checking an
internal flag (in case something besides the button is causing the
action to run).

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js

index 957995c..e4c6e74 100644 (file)
@@ -2901,6 +2901,14 @@ function AcqLiTable() {
             if (!this.confirmBreachedCopyFunds(copies))
                 return;
 
+            if (this._savingCopiesInFlight) {
+                // Save in progress.  Get outta here.
+                return;
+            }
+
+            this._savingCopiesInFlight = true;
+            acqLitSaveCopies.attr('disabled', true);
+
             if (typeof(this._copy_count_cb) == "function")
                 this._copy_count_cb(liId, total);
 
@@ -2917,6 +2925,8 @@ function AcqLiTable() {
                         self.drawCopies(liId, true /* force_fetch */);
                         openils.Util.hide("acq-lit-update-copies-progress");
                         refreshPOSummaryAmounts();
+                        self._savingCopiesInFlight = false;
+                        acqLitSaveCopies.attr('disabled', false);
                     }
                 }
             );