From 898cf628b0ab194d06205a0f637efbf29eb601a7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 24 Jun 2014 10:26:12 -0400 Subject: [PATCH] checkin mods cont Signed-off-by: Bill Erickson --- .../src/templates/staff/circ/checkin/index.tt2 | 54 ++++++++++ .../web/js/ui/default/staff/circ/checkin/app.js | 109 ++++++++++++++------- 2 files changed, 130 insertions(+), 33 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 index 77436f7122..a63fb16aee 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 @@ -36,6 +36,20 @@ class="alert-danger pad-all-min"> [% l('Auto-Print Hold and Transit Slips') %] +
+ [% l('Clear Holds Shelf') %] +
+
+
+ [% l('Always Retarget Local Holds') %] +
+
+ [% l('Retarget Local Holds') %] +
+
+
+ [% l('Capture Local Holds As Transits') %] +
@@ -153,6 +167,46 @@ [% l('Auto-Print Hold and Transit Slips') %] +
  • + + + + [% l('Clear Holds Shelf') %] + +
  • +
  • + + + + [% l('Retarget Local Holds') %] + +
  • +
  • + + + + [% l('Retarget All Statuses') %] + +
  • +
  • + + + + [% l('Capture Local Holds As Transits') %] + +
  • diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index 072c2452ad..fc2cee0d12 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -53,51 +53,94 @@ function($scope , $q , egCore , checkinSvc , egGridDataProvider , egCirc) { } }); - $scope.checkin = function(args) { - - if (args && args.copy_barcode) { - var params = angular.copy(args); + // turns the various inputs (form args, modifiers, etc.) into + // checkin params and options. + function compile_checkin_args(args) { + var params = angular.copy(args); + + if (params.backdate) { + params.backdate = + params.backdate.toISOString().replace(/T.*/,''); + + // a backdate of 'today' is not really a backdate + if (params.backdate == $scope.max_backdate) + delete params.backdate; + } - if (params.backdate) { - params.backdate = - params.backdate.toISOString().replace(/T.*/,''); + angular.forEach(['noop','void_overdues', + 'clear_expired','hold_as_transit','manual_float'], + function(opt) { + if ($scope.modifiers[opt]) params[opt] = true; + } + ); - // a backdate of 'today' is not really a backdate - if (params.backdate == $scope.max_backdate) - delete params.backdate; + if ($scope.modifiers.retarget_holds) { + if ($scope.modifiers.retarget_holds_all) { + params.retarget_mode = 'retarget.all'; + } else { + params.retarget_mode = 'retarget'; } + } - if ($scope.modifiers.noop) - params.noop = true; - if ($scope.modifiers.void_overdues) - params.void_overdues = true; + var options = { + check_barcode : $scope.strict_barcode, + no_precat_alert : $scope.modifiers.no_precat_alert, + auto_print_holds_transits : + $scope.modifiers.auto_print_holds_transits + }; - var options = { - check_barcode : $scope.strict_barcode, - no_precat_alert : $scope.modifiers.no_precat_alert, - auto_print_holds_transits : - $scope.modifiers.auto_print_holds_transits - }; + return {params : params, options: options}; + } + + $scope.checkin = function(args) { - egCirc.checkin(params, options) - .then(function(final_resp) { - final_resp.evt.index = checkinSvc.checkins.length; - final_resp.evt.copy_barcode = params.copy_barcode; + var compiled = compile_checkin_args(args); + args.copy_barcode = ''; // reset UI for next scan + $scope.focusMe = true; - checkinSvc.checkins.unshift(final_resp.evt); - if (checkinSvc.checkins.length > 20) - checkinSvc.checkins = checkinSvc.checkins.splice(0, 20); + var params = compiled.params; + var options = compiled.options; - checkinGrid.refresh(); + if (!params.copy_barcode) return; - // in case we lost focus to a dialog - $scope.focusMe = true; + var row_item = { + index : checkinSvc.checkins.length, + copy_barcode : params.copy_barcode + }; + + // track the item in the grid before sending the request + checkinSvc.checkins.unshift(row_item); + checkinGrid.refresh(); + + egCirc.checkin(params, options).then( + function(final_resp) { + + // copy the response event into the original grid row item + // note: angular.copy clobbers the destination + angular.forEach(final_resp.evt, function(v, k) { + row_item[k] = v; + }); + + if (checkinSvc.checkins.length > 20) + checkinSvc.checkins = checkinSvc.checkins.splice(0, 20); + }, + function() { + // Circ 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 + // index value does not (generally) match the array position. + var pos = -1; + angular.forEach($scope.checkouts, function(ci, idx) { + if (ci.index == row_item.index) pos = idx; }); + checkinSvc.checkin.splice(pos, 1); - args.copy_barcode = ''; // reset UI for next scan - } + })['finally'](function() { - $scope.focusMe = true; + // when all is said and done, refresh the grid and refocus + checkinGrid.refresh(); + $scope.focusMe = true; + }); } $scope.print_receipt = function() { -- 2.11.0