From d3e315ab46dd91c3b0914af6e80817f9412c0f78 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 24 Jun 2014 17:25:22 -0400 Subject: [PATCH] checkin Signed-off-by: Bill Erickson --- .../web/js/ui/default/staff/circ/services/circ.js | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 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 51825278d9..c0278204f5 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 @@ -12,7 +12,6 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { var service = { // auto-override these events after the first override auto_override_checkout_events : {}, - org_addr_cache : {} // TODO: use egEnv }; service.reset = function() { @@ -320,6 +319,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { if (!evt || !(payload = evt.payload)) return $q.when(); promises.push(service.flesh_copy_location(payload.copy)); + promises.push(service.flesh_copy_status(payload.copy)); // local flesh transit if (transit = payload.transit) { @@ -340,6 +340,18 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { return $q.all(promises); } + // fetches the full list of copy statuses + service.flesh_copy_status = function(copy) { + if (egCore.env.ccs) + return $q.when(copy.status(egCore.env.ccs.map[copy.status()])); + return egCore.pcrud.retrieveAll('ccs', {}, {atomic : true}, + function(list) { + egCore.env.absorbList(list, 'ccs'); + copy.status(egCore.env.ccs.map[copy.status()]); + } + ); + } + // there may be *many* copy locations and we may be handling items // for other locations. Fetch copy locations as-needed and cache. service.flesh_copy_location = function(copy) { @@ -360,20 +372,17 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { } - // fetch/cache for org unit addresses - // TODO: use egEnv instead + // fetch org unit addresses as needed. service.get_org_addr = function(org_id, addr_type) { - if (service.org_addr_cache[org_id]) { - if (service.org_addr_cache[org_id][addr_type]) - return $q.when(service.org_addr_cache[org_id][addr_type]); - } else { - service.org_addr_cache[org_id] = {}; - } + var org = egCore.org.get(org_id); + var addr_id = org[addr_type](); + + if (egCore.env.aoa && egCore.env.aoa.map[addr_id]) + return $q.when(egCore.env.aoa.map[addr_id]); - return egCore.pcrud.retrieve('aoa', - egCore.org.get(org_id)[addr_type]() - ).then(function(addr) { - return service.org_addr_cache[org_id][addr_type] = addr; + return egCore.pcrud.retrieve('aoa', addr_id).then(function(addr) { + egCore.env.absorbList([addr], 'aoa'); + return egCore.env.aoa.map[addr_id]; }); } @@ -660,7 +669,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { case 'SUCCESS': case 'NO_CHANGE': - if (copy.status() == 8 // on holds shelf + if (copy.status().id() == 8 // on holds shelf && hold && hold.pickup_lib() == egCore.auth.user().ws_ou()) { // inform user if the item is on the local holds shelf -- 2.11.0