From 56ea32b96874820c9f0c578ae70e796ec3f7579d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 21 Oct 2018 13:10:07 -0400 Subject: [PATCH] Try rearranging the code to look up new copy status only once. --- .../web/js/ui/default/staff/circ/services/circ.js | 56 ++++++++-------------- 1 file changed, 21 insertions(+), 35 deletions(-) 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 35dfef60cd..7fc2b12adb 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 @@ -1380,7 +1380,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl // If any new back end mark_item calls are added, also add // them here to use them from the staff client. // TODO: I didn't find any JS constants for copy status. - switch (markstatus) { + switch (markstatus.id()) { case 2: // Not implemented in the staff client, yet. // req = "open-ils.circ.mark_item_bindery"; @@ -1412,35 +1412,18 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl break; } - function get_status(statusID) { - var deferred = $q.defer() - egCore.pcrud.retrieve('ccs', statusID) - .then(function(resp) { - deferred.resolve(resp); - }, function(resp) { - deferred.reject(resp); - }); - return deferred.promise; - } - - var newStatus; - return get_status(markstatus).then(function(resp) { - newStatus = resp; - return egCore.net.request( - 'open-ils.circ', - req, - egCore.auth.token(), - copy.id, - args - ).then(function(resp) { - if (resp == 1) { - console.debug(req + ' succeeded for ' + copy.barcode); - } else if (evt = egCore.evt.parse(resp)) { - console.error(req + ' failed for ' + copy.barcode + ': ' + resp.textcode); - } - }); - }, function(resp) { - /* noop */ + return egCore.net.request( + 'open-ils.circ', + req, + egCore.auth.token(), + copy.id, + args + ).then(function(resp) { + if (resp == 1) { + console.debug(req + ' succeeded for ' + copy.barcode); + } else if (evt = egCore.evt.parse(resp)) { + console.error(req + ' failed for ' + copy.barcode + ': ' + resp.textcode); + } }); } @@ -1453,11 +1436,14 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl cancel : function() {} } ).result.then(function() { - var promises = []; - angular.forEach(copies, function(copy) { - promises.push(service.mark_item(copy, 13, {})) - }); - return $q.all(promises); + egCore.pcrud.retrieve('ccs', 13) + .then(function(resp) { + var promises = []; + angular.forEach(copies, function(copy) { + promises.push(service.mark_item(copy, resp, {})) + }); + return $q.all(promises); + }); }); } -- 2.11.0