From 82aaab2caaece4ff0c365dbdafd65fa8b158ce0f Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 28 Oct 2016 17:13:29 -0400 Subject: [PATCH] Angular selfcheck WIP Signed-off-by: Bill Erickson --- .../src/templates/staff/circ/selfcheck/index.tt2 | 24 +------- .../web/js/ui/default/staff/circ/selfcheck/app.js | 69 ++++++---------------- 2 files changed, 21 insertions(+), 72 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 index b93c2aec0e..1e9ba8acca 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 @@ -11,20 +11,9 @@ - - +[% INCLUDE 'staff/circ/selfcheck/strings.tt2' %] [% END %] - @@ -50,16 +39,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
-
- [% l('Barcode already scanned: [_1]', '{{scanbox.already_seen}}') %] +
+ {{scanbox.err_str}}
-
- - [% l( - 'Item "[_1]" was not found in the system. Try re-scanning the item.', - '{{scanbox.text}}') - %] -
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 a1742334db..cdc5679a90 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 @@ -357,16 +357,15 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial service.process_checkout_events = function(events, action) { - // For the initial checks, only look at the first event returned. - // Usually there will only be one, but in some cases where an - // override is required, multiple override-able events may - // be returned. - + // For the initial checks, only look at the first event + // returned. Usually there will only be one, but in some cases + // where an override is available, multiple override-able events + // may be returned. var first_evt = events[0]; var payload = first_evt.payload; var textcode = first_evt.textcode; - console.log('checkout event: ' + js2JSON(first_evt)); + console.log('checkout returned: ' + js2JSON(first_evt)); switch(textcode) { @@ -389,42 +388,16 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial // No event handlers have succeeded so far. Handle blocking // penalties. - - return $q.reject(first_evt); - - /* - switch(textcode) { - - case 'MAX_RENEWALS_REACHED' : - displayText = dojo.string.substitute( - localeStrings.MAX_RENEWALS, [item]); - break; - - case 'ITEM_NOT_CATALOGED' : - displayText = dojo.string.substitute( - localeStrings.ITEM_NOT_CATALOGED, [item]); - break; - - case 'OPEN_CIRCULATION_EXISTS' : - displayText = dojo.string.substitute( - localeStrings.OPEN_CIRCULATION_EXISTS, [item]); - - break; - - default: - console.error('Unhandled event ' + result.textcode); - - if (!(displayText = this.failPartMessage(result))) { - if (action == 'checkout' || action == 'renew') { - displayText = dojo.string.substitute( - localeStrings.GENERIC_CIRC_FAILURE, [item]); - } else { - displayText = dojo.string.substitute( - localeStrings.UNKNOWN_ERROR, [result.textcode]); - } - } + var err_str = egCore.strings[textcode]; + if (!err_str) { + if (payload && payload.fail_part) { + var key = "FAIL_PART_" + payload.fail_part.replace(/\./g, "_"); + err_str = egCore.strings['FAIL_PART_' + key]; + } } - */ + if (!err_str) err_str = egCore.strings.GENERIC_CIRC_FAILURE; + + return $q.reject(err_str); } return service; @@ -461,9 +434,7 @@ function($scope, $q, $location , egCore, scSvc) { }, changed : function($event) { - delete $scope.scanbox.already_seen; - delete $scope.scanbox.error_code; - delete $scope.scanbox.error_txt; + delete $scope.scanbox.err_str; if ($event.keyCode != 13) return; // submit on enter. scanbox_handler($scope.scanbox.text); } @@ -474,7 +445,7 @@ function($scope, $q, $location , egCore, scSvc) { if (scSvc.scanned_barcodes.indexOf(barcode) > -1) { // avoid processing barcodes the user has already // scanned in this session. - $scope.scanbox.already_seen = barcode; + $scope.scanbox.err_str = egCore.strings.ITEM_SEEN; return; } @@ -563,12 +534,8 @@ function($scope, $q, $location , egCore, scSvc) { function() { // checkout succeeded. }, - function(evt) { // checkout failed - if (evt) { - $scope.scanbox.error_code = evt.textcode; - // TODO: result.payload.fail_part - // $scope.scanbox.error_txt; - } + function(err_str) { // checkout failed + $scope.scanbox.err_str = err_str; } )['finally']( function() { -- 2.11.0