row_item.circ = payload.circ;
row_item.mbts = payload.circ ?
payload.circ.billable_transaction().summary() : null;
- row_item.mvr = payload.record;
+ row_item.record = payload.record;
row_item.acp = payload.copy;
row_item.acn = payload.volume ?
payload.volume : payload.copy.call_number();
row_item.au = payload.patron;
+ row_item.transit = payload.transit;
row_item.status = payload.status;
row_item.message = payload.message;
+ row_item.title = final_resp.evt.title;
+ row_item.author = final_resp.evt.author;
+ row_item.isbn = final_resp.evt.isbn;
}
- // TODO
- //row_item.route_to
+ if (row_item.transit) {
+ row_item.route_to = row_item.transit.dest().shortname();
+ } else if (row_item.acp) {
+ row_item.route_to = row_item.acp.location().name();
+ // TODO holds shelf, cataloging
+ }
if ($scope.trim_list && checkinSvc.checkins.length > 20)
checkinSvc.checkins = checkinSvc.checkins.splice(0, 20);
-
- return egCirc.flesh_copy_location(row_item.acp)
- .then(function(copy) {
- if (copy && !row_item.route_to)
- row_item.route_to = copy.location().name();
- });
},
function() {
- // Circ was rejected somewhere along the way.
+ // Checkin was rejected somewhere along the way.
// Remove the copy from the grid since there was no action.
- // note: since checkouts are unshifted onto the array, the
+ // note: since checkins are unshifted onto the array, the
// index value does not (generally) match the array position.
var pos = -1;
- angular.forEach($scope.checkouts, function(ci, idx) {
+ angular.forEach(checkinSvc.checkins, function(ci, idx) {
if (ci.index == row_item.index) pos = idx;
});
checkinSvc.checkin.splice(pos, 1);
if (checkinSvc.checkins.length == 0) return $q.when();
- angular.forEach(checkinSvc.checkins, function(evt) {
+ angular.forEach(checkinSvc.checkins, function(checkin) {
var checkin = {
- copy : egCore.idl.toHash(evt.payload.copy) || {},
- copy_barcode : evt.copy_barcode,
+ copy : egCore.idl.toHash(checkin.acp) || {},
+ call_number : egCore.idl.toHash(checkin.acn) || {},
+ copy_barcode : checkin.copy_barcode,
+ title : checkin.title,
+ author : checkin.author
}
- checkin.title = evt.payload.record ? evt.payload.record.title() :
- (checkin.copy ? checkin.copy.dummy_title : '');
-
- checkin.call_number =
- typeof checkin.copy.call_number == 'object' ?
- checkin.copy.call_number :
- egCore.idl.toHash(evt.payload.volume);
-
print_data.checkins.push(checkin);
});
).then(function(evt) {
if (angular.isArray(evt)) evt = evt[0];
- return service.handle_checkout_resp(evt, params, options);
+
+ return service.flesh_response_data(
+ 'checkout', evt, params, options)
+ .then(function() {
+ return service.handle_checkout_resp(evt, params, options);
+ })
});
});
}
).then(function(evt) {
if (angular.isArray(evt)) evt = evt[0];
- return service.handle_checkout_resp(evt, params, options);
+
+ return service.flesh_response_data(
+ 'renew', evt, params, options)
+ .then(function() {
+ return service.handle_checkout_resp(evt, params, options);
+ })
});
}
).then(function(evt) {
if (angular.isArray(evt)) evt = evt[0];
- return service.handle_checkin_response(evt, params, options);
+ return service.flesh_response_data(
+ 'checkin', evt, params, options)
+ .then(function() {
+ return service.handle_checkin_resp(evt, params, options);
+ })
});
});
}
});
}
+ // ideally all of these data should be returned with the response,
+ // but until then, grab what we need.
+ service.flesh_response_data = function(action, evt, params, options) {
+ var promises = [];
+ var payload;
+ if (!evt || !(payload = evt.payload)) return $q.when();
+
+ promises.push(service.flesh_copy_location(payload.copy));
+
+ // local flesh transit
+ if (transit = payload.transit) {
+ transit.source(egCore.org.get(transit.source()));
+ transit.dest(egCore.org.get(transit.dest()));
+ }
+
+ // extract precat values
+ evt.title = payload.record ? payload.record.title() :
+ (payload.copy ? payload.copy.dummy_title() : null);
+
+ evt.author = payload.record ? payload.record.author() :
+ (payload.copy ? payload.copy.dummy_author() : null);
+
+ evt.isbn = payload.record ? payload.record.isbn() :
+ (payload.copy ? payload.copy.dummy_isbn() : null);
+
+ return $q.all(promises);
+ }
+
// 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) {
// units locally.
service.find_copy_transit = function(evt, params, options) {
- if (evt && evt.payload && (transit = evt.payload.transit)) {
- transit.source(egCore.org.get(transit.source()));
- transit.dest(egCore.org.get(transit.dest()));
- return $q.when(transit);
- }
+ if (evt && evt.payload && evt.payload.transit)
+ return $q.when(evt.payload.transit);
return egCore.pcrud.search('atc',
{ dest_recv_time : null},
);
}
- service.handle_checkin_response = function(evt, params, options) {
+ service.handle_checkin_resp = function(evt, params, options) {
var final_resp = {evt : evt, params : params, options : options};
var print_context = {
copy : egCore.idl.toHash(evt.payload.copy),
- title : evt.payload.record.title(),
- author : evt.payload.record.author()
+ title : evt.title,
+ author : evt.author
}
if (data.transit) {