From 2cd719c00e662fd4168e9c5fa7f1a1323d9be6b9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 28 Oct 2016 11:49:24 -0400 Subject: [PATCH] Angular selfcheck WIP Signed-off-by: Bill Erickson --- .../src/templates/staff/circ/selfcheck/index.tt2 | 8 +++- .../templates/staff/circ/selfcheck/t_checkout.tt2 | 19 +++++++- .../web/js/ui/default/staff/circ/selfcheck/app.js | 52 +++++++++++++++++++++- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 index 67704112ae..887dbe0065 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 @@ -39,11 +39,17 @@ angular.module('egCoreMod').run(['egStrings', function(s) { -
+
+
+ [% l('Barcode already scanned: [_1]', '{{scanbox.already_seen}}') %] +
+
diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 index b8f076ec29..1730180ac2 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 @@ -1,2 +1,19 @@ -

CHECKOUT

+ +
+
+
[% l('Barcode') %]
+
[% l('Title') %]
+
[% l('Author') %]
+
[% l('Due Date') %]
+
+ +
+
+ +
+
{{circ.copy.barcode()}}
+
{{circ.record.title()}}
+
{{circ.record.author()}}
+
{{circ.circ.due_date() | date:'short'}}
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js index 7dd85af500..afccab462d 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js @@ -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', -- 2.11.0