From: Bill Erickson Date: Fri, 3 Feb 2017 19:26:09 +0000 (-0500) Subject: LP#1526163 Web staff supports auto-renew tweaks X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=22891eb1dccb101e097f355b344e1aac20e1ef9d;p=working%2FEvergreen.git LP#1526163 Web staff supports auto-renew tweaks Initiate the auto-renewal earlier in the checkout process, specifically before response data is unnecessarily fleshed. Add an explicit auto_renew toggle to the checkout response blob to more clearly indicate why checkout counts are not modified. Additional code comments and logging. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index 549933baf0..8fc38de8d5 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -151,8 +151,10 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , function(co_resp) { // update stats locally so we don't have to fetch them w/ // each checkout. - //check for renew so that is doesn't update incorrectly - if(co_resp.evt[0].payload.parent_circ == null){ + + // Avoid updating checkout counts when a checkout turns + // into a renewal via auto_renew. + if (!co_resp.auto_renew) { patronSvc.patron_stats.checkouts.out++; patronSvc.patron_stats.checkouts.total_out++; } 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 08ce484a92..62b65022b6 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 @@ -143,6 +143,13 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, if (!angular.isArray(evt)) evt = [evt]; + if (evt[0].payload && evt[0].payload.auto_renew == 1) { + // open circulation found with auto-renew toggle on. + console.debug('Auto-renewing item ' + params.copy_barcode); + options.auto_renew = true; + return service.renew(params, options); + } + return service.flesh_response_data('checkout', evt, params, options) .then(function() { return service.handle_checkout_resp(evt, params, options); @@ -188,6 +195,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, return service.handle_renew_resp(evt, params, options); }) .then(function(final_resp) { + final_resp.auto_renew = options.auto_renew; return service.munge_resp_data(final_resp,'renew',method) }) }); @@ -460,9 +468,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, return service.precat_dialog(params, options); case 'OPEN_CIRCULATION_EXISTS': - if(evt[0].payload.auto_renew == 1){ - return service.renew(params, options); - } + // auto_renew checked in service.checkout() egCore.audio.play('error.checkout.open_circ'); return service.circ_exists_dialog(evt, params, options);