<hr/>
<eg-grid
- id-field="id"
+ id-field="index"
features="-display,-sort,-multisort"
main-label="[% l('Checkouts') %]"
items-provider="gridDataProvider"
--- /dev/null
+<div>
+ <div class="modal-header">
+ <button type="button" class="close"
+ ng-click="cancel()" aria-hidden="true">×</button>
+ <h4 class="modal-title">[% l('Copy In Transit') %]</h4>
+ </div>
+ <div class="modal-body">
+ <div class="strong-text">
+ [% l('There is an open transit on copy [_1]',
+ '{{transit.target_copy().barcode()}}') %]
+ </div>
+ <div class="pad-vert"></div>
+ <div class="row">
+ <div class="col-md-4">[% l('Transit Date:') %]</div>
+ <div class="col-md-8">{{transit.source_send_time() | date:'short'}}</div>
+ </div>
+ <div class="row">
+ <div class="col-md-4">[% l('Transit Source:') %]</div>
+ <div class="col-md-8">{{transit.source().shortname()}}</div>
+ </div>
+ <div class="row">
+ <div class="col-md-4">[% l('Transit Destination:') %]</div>
+ <div class="col-md-8">{{transit.dest().shortname()}}</div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <input type="submit" class="btn btn-primary" ng-click="ok()"
+ value="[% l('Abort Transit then Checkout') %]"/>
+ <button class="btn btn-warning"
+ ng-click="cancel()">[% l('Cancel') %]</button>
+ </div>
+</div>
}
});
+ // avoid multiple, in-flight attempts on the same barcode
+ var pending_barcodes = {};
+
var printOnComplete = true;
egCore.org.settings([
'circ.staff_client.do_not_auto_attempt_print'
args.copy_barcode = ''; // reset UI input
params.noncat_type = ''; // "barcode"
+
+ if (pending_barcodes[params.copy_barcode]) {
+ console.log(
+ "Skipping checkout of redundant barcode "
+ + params.copy_barcode
+ );
+ return;
+ }
+
+ pending_barcodes[params.copy_barcode] = true;
send_checkout(params);
} else {
munge_checkout_resp(co_resp);
// copy the response event into the original grid row item
- angular.copy(co_resp.evt, row_item);
+ // note: angular.copy clobbers the destination
+ angular.forEach(co_resp.evt, function(v, k) {
+ row_item[k] = v;
+ });
},
function() {
// Circ was rejected somewhere along the way.
$scope.checkouts.splice(row_item.index, 1);
$scope.gridDataProvider.refresh();
}
- );
+
+ )['finally'](function() {
+
+ // regardless of the outcome of the circ, remove the
+ // barcode from the pending list.
+ if (params.copy_barcode)
+ delete pending_barcodes[params.copy_barcode];
+ });
}
// move some stuff around so it will play nice w/ the template
case 'OPEN_CIRCULATION_EXISTS':
return service.circ_exists_dialog(evt, params, options);
+ case 'COPY_IN_TRANSIT':
+ return service.copy_in_transit_dialog(evt, params, options);
+
/* stuff to consider
PERM_FAILURE
PATRON_BARRED
);
}
+ service.copy_in_transit_dialog = function(evt, params, options) {
+ return $modal.open({
+ templateUrl: './circ/share/t_copy_in_transit_dialog',
+ controller:
+ ['$scope','$modalInstance','transit',
+ function($scope , $modalInstance , transit) {
+ $scope.transit = transit;
+ $scope.ok = function() { $modalInstance.close(transit) }
+ $scope.cancel = function() { $modalInstance.dismiss() }
+ }],
+ resolve : {
+ // fetch the conflicting open transit w/ fleshed copy
+ transit : function() {
+ return egCore.pcrud.search('atc',
+ { dest_recv_time : null},
+ { flesh : 1,
+ flesh_fields : {atc : ['target_copy']},
+ join : {
+ acp : {
+ filter : {
+ barcode : params.copy_barcode,
+ deleted : 'f'
+ }
+ }
+ },
+ limit : 1,
+ order_by : {atc : 'source_send_time desc'},
+ }
+ ).then(function(transit) {
+ transit.source(egCore.org.get(transit.source()));
+ transit.dest(egCore.org.get(transit.dest()));
+ return transit;
+ });
+ }
+ }
+ }).result.then(
+ function(transit) {
+ // user chose to abort the transit then checkout
+ return service.abort_transit(transit.id())
+ .then(function() {
+ return service.checkout(params, options);
+ });
+ }
+ );
+ }
+
+ service.abort_transit = function(transit_id) {
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.transit.abort',
+ egCore.auth.token(), {transitid : transit_id}
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ alert(evt);
+ return $q.reject();
+ }
+ return $q.when();
+ });
+ }
+
service.circ_exists_dialog = function(evt, params, options) {
return $modal.open({
templateUrl: './circ/share/t_circ_exists_dialog',