Angular selfcheck WIP
authorBill Erickson <berickxx@gmail.com>
Fri, 28 Oct 2016 15:49:24 +0000 (11:49 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 28 Oct 2016 15:49:24 +0000 (11:49 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/circ/selfcheck/index.tt2
Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2
Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js

index 6770411..887dbe0 100644 (file)
@@ -39,11 +39,17 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
         <input 
           class="form-control"
           focus-me="scanbox.focus" 
+          select-me="scanbox.focus"
           ng-model="scanbox.text"
+          ng-keyup="scanbox.changed($event)"
           ng-disabled="scanbox.disabled()"
           type="text"/> 
       </div>
-      <div class="col-md-5"></div>
+      <div class="col-md-5">
+        <div class="alert alert-warning" ng-if="scanbox.already_seen">
+          [% l('Barcode already scanned: [_1]', '{{scanbox.already_seen}}') %]
+        </div>
+      </div>
     </div>
   </div>
 </div>
index b8f076e..1730180 100644 (file)
@@ -1,2 +1,19 @@
-<h2>CHECKOUT</h2>
+
+<div class="row">
+  <div class="col-md-1"></div>
+  <div class="col-md-2">[% l('Barcode') %]</div>
+  <div class="col-md-3">[% l('Title') %]</div>
+  <div class="col-md-3">[% l('Author') %]</div>
+  <div class="col-md-2">[% l('Due Date') %]</div>
+</div>
+
+<div class="row" ng-repeat="circ in circs">
+  <div class="col-md-1">
+    <img src="/opac/extras/ac/jacket/small/r/{{circ.record.doc_id()}}"/>
+  </div>
+  <div class="col-md-2">{{circ.copy.barcode()}}</div>
+  <div class="col-md-3">{{circ.record.title()}}</div>
+  <div class="col-md-3">{{circ.record.author()}}</div>
+  <div class="col-md-2">{{circ.circ.due_date() | date:'short'}}</div>
+</div>
 
index 7dd85af..afccab4 100644 (file)
@@ -114,7 +114,10 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial
         total_circ_count : 0,
         ready_hold_count : 0,
         total_hold_count : 0,
-        total_owed_count : 0
+        total_owed_count : 0,
+
+        pending_barcode : null, // most recently scanned barcode
+        scanned_barcodes : [], // all scanned barcodes
     };
 
     // patron_id is set in cases where the patron has not yet been fetched.
@@ -350,8 +353,39 @@ function($scope,  $q,  $location , egCore,  scSvc) {
         text : '',
         focus : false,
         disabled : function() {
-            // TODO: inactive barcode, etc.
+            // TODO: do we need this?
             return false;
+        },
+
+        changed : function($event) {
+            delete $scope.scanbox.already_seen;
+            if ($event.keyCode != 13) return; // submit on enter.
+            scanbox_handler($scope.scanbox.text);
+        }
+    }
+
+    function scanbox_handler(barcode) {
+
+        if (scSvc.scanned_barcodes.indexOf(barcode) > -1) {
+            // avoid processing barcodes the user has already
+            // scanned in this session.
+            $scope.scanbox.already_seen = barcode;
+            return;
+        }
+
+        scSvc.pending_barcode = barcode; 
+        scSvc.scanned_barcodes.push(barcode);
+
+        if ($location.path() == '/circ/selfcheck/checkout') {
+            // Already on the checkout page.  Tell the checkout
+            // controller to process the barcode.
+            $scope.scanbox.handle_barcode();
+
+        } else {
+            // User scanned a barcode from a UI that's not the
+            // checkout UI.  Direct the user back to the checkout
+            // UI so the checkout can continue.
+            $location.path('/circ/selfcheck/checkout');
         }
     }
 
@@ -413,6 +447,18 @@ function($scope,  $q,  $location , egCore,  scSvc) {
     scSvc.new_path_init();
     $scope.scanbox.focus = true;
 
+    $scope.scanbox.handle_barcode = function() {
+        var barcode = scSvc.pending_barcode;
+        delete scSvc.pending_barcode;
+
+        console.debug('Processing copy barcode ' + barcode);
+
+        // TODO: checkout item and toss it into the list.
+    
+        // always re-focus after scan
+        $scope.scanbox.focus = true;
+    }
+
 }])
 
 .controller('ItemsCtrl',
@@ -425,6 +471,8 @@ function($scope,  $q,  $location , egCore,  scSvc) {
     scSvc.get_items_out().then(null, null, 
         function(circ_blob) { $scope.circs.push(circ_blob) });
 
+    // TODO: support batch renewal.
+
 }])
 
 .controller('HoldsCtrl',