var service = {
// auto-override these events after the first override
auto_override_checkout_events : {},
- org_addr_cache : {} // TODO: use egEnv
};
service.reset = function() {
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) {
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) {
}
- // 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];
});
}
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