From: Bill Erickson Date: Mon, 17 Sep 2018 22:16:28 +0000 (-0400) Subject: LP#1787274 Prevent multiple active copy checkins X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a03994fe3ba4b6cf0d18f9fa6b6c0f245ead67ef;p=evergreen%2Fjoelewis.git LP#1787274 Prevent multiple active copy checkins In the staff client checkin service, track which copies are currently in-flight to the checkin API call and prevent additional checkin API calls for any copy that is currently in flight. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index 25e4fc1ce4..724ae7fee6 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -19,7 +19,8 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl hold_shelf_slip : false, hold_transit_slip : false, transit_slip : false - } + }, + in_flight_checkins: {} }; egCore.startup.go().finally(function() { @@ -266,10 +267,20 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl var method = 'open-ils.circ.checkin'; if (options.override) method += '.override'; + // Multiple checkin API calls should never be active + // for a single barcode. + if (service.in_flight_checkins[barcode]) { + console.error('Barcode ' + barcode + + ' is already in flight for checkin, skipping'); + return $q.reject(); + } + service.in_flight_checkins[barcode] = true; + return egCore.net.request( 'open-ils.circ', method, egCore.auth.token(), params ).then(function(evt) { + delete service.in_flight_checkins[barcode]; if (!angular.isArray(evt)) evt = [evt]; return service.flesh_response_data( @@ -280,7 +291,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl .then(function(final_resp) { return service.munge_resp_data(final_resp,'checkin',method) }) - }); + }, function() {delete service.in_flight_checkins[barcode]}); }); }); }