From: Bill Erickson Date: Thu, 27 Oct 2016 19:44:47 +0000 (-0400) Subject: Angular selfcheck WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d9edd1c3521d813d2f6941b039edc475a7bec245;p=working%2FEvergreen.git Angular selfcheck WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 index 04be1059d7..c6c22619ed 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 @@ -24,13 +24,16 @@ angular.module('egCoreMod').run(['egStrings', function(s) { [% END %] + + + +
[% l('Welcome, [_1]', '{{patron().first_given_name()}}') %]
-
+
-
+
[% l('Items Checked Out') %] -
[% l('Total items this session: [_1]', - '{{counts("session_circ")}}') %]
-
[% l('Total items on account: [_1]', - '{{counts("total_circ")}}') %]
-
[% l('Holds') %] -
[% l('You have [_1] item(s) ready for pickup', - '{{counts("hold_ready")}}') %]
-
[% l('You have [_1] total holds', - '{{counts("total_hold")}}') %]
-
[% l('Fines') %] -
diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/t_items.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_items.tt2 new file mode 100644 index 0000000000..55511c63ee --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/selfcheck/t_items.tt2 @@ -0,0 +1,19 @@ + +
+
+
[% 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/src/templates/staff/circ/selfcheck/t_login.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 index 3e15c44b32..411a5260e8 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 @@ -1,41 +1,39 @@ -
-
-
-
-
- [% l('Please log in with your username or library barcode.') %] +
+
+
+
+ [% l('Please log in with your username or library barcode.') %] -
-
- -
- -
+ +
+ +
+
+
-
- -
- -
+
+ +
+
+
-
-
- -
-
- [% l('Login Failed') %] -
+
+
+
+
+ [% l('Login Failed') %] +
+
- -
-
-
-
+ +
+
+
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 d6c631a98c..beb3a216df 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 @@ -2,6 +2,12 @@ * Self-Checkout App */ +/* + * TODO: add support auth.js for forcing a re-login when navigating + * away from the selfcheck UI. Consider sessionStorage item + * that restricts access. + */ + angular.module('egSelfCheckApp', ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'ngToast']) @@ -60,6 +66,12 @@ angular.module('egSelfCheckApp', resolve : resolver }); + $routeProvider.when('/circ/selfcheck/items', { + templateUrl: './circ/selfcheck/t_items', + controller: 'ItemsCtrl', + resolve : resolver + }); + $routeProvider.otherwise({redirectTo : '/circ/selfcheck/login'}); }) @@ -90,8 +102,14 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial }; + // called with each path load + service.new_path_init = function() { + if (!service.patron) + return service.logout_patron(); + service.reset_login_timer(); + } + service.show_timeout_warning = function() { - // TODO: force logout after warning timeout egConfirmDialog.open( egCore.strings.CONFIRM_TIMEOUT_TITLE, @@ -103,6 +121,8 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial egCore.strings.CONFIRM_TIMEOUT_LOGOUT ); + // If the patron choses no action from the above dialog, + // force a logout after the configured amount of time. service.login_warning_timer = $timeout( service.logout_patron, service.login_timeout_warning ); @@ -160,12 +180,31 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial }); } + /* + * Returns true if the username string looks like a barcode. + */ + service.username_is_barcode = function(username) { + var regstr = + egCore.env.aous['circ.selfcheck.patron_password_required']; + if (regstr) { + var reg = new RegExp(regstr); + return reg && username.match(reg); + } + return false; + } + + /* + * Test password if required, then fetch the user data. + */ service.login_patron = function(username, password) { - // TODO: test barcode regex - var barcode = null; + var barcode; + if (service.username_is_barcode(username)) { + barcode = username; + username = null; + } - if (true) { // TODO: test password required + if (egCore.env.aous['circ.selfcheck.patron_password_required']) { return egCore.auth.verify({ username : username, barcode : barcode, @@ -178,12 +217,31 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial } } + /* + * Return to the login page via full page load to clear + * stored user data. + */ service.logout_patron = function() { - // force a page reload to clear all cached data. $window.location.href = $location.absUrl().replace( /\/selfcheck\/.*/, '/selfcheck/login'); } + /* + * Returns a notify-stream of open circ blobs. + * Resets total circ count to match the server. + */ + service.get_items_out = function() { + service.total_circ_count = 0; + return egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.actor.user.checked_out', + egCore.auth.token(), service.patron.id() + ).then(null, null, function(circ_blob) { + service.total_circ_count++; + return circ_blob; + }); + } + return service; }]) @@ -205,6 +263,10 @@ function($scope, $q, $location , egCore, scSvc) { return $location.path() == '/circ/selfcheck/login'; } + $scope.dyn_content_class = function() { + return $scope.is_login_page() ? 'col-md-12' : 'col-md-8'; + } + $scope.scanbox = { text : '', focus : false, @@ -216,6 +278,13 @@ function($scope, $q, $location , egCore, scSvc) { $scope.patron = function() { return scSvc.patron } + $scope.show_pane = function(name) { + if (name && name.match(/(login|checkout|items|holds|fines)$/)) { + console.log('navigating to pane ' + name); + $location.path('/circ/selfcheck/' + name); + } + } + }]) @@ -228,10 +297,15 @@ function($scope, $q, $location , egCore, scSvc) { ['$scope','$q','$location','egCore','scSvc', function($scope, $q, $location , egCore, scSvc) { + $scope.focus_username = true; + $scope.password_required = + egCore.env.aous['circ.selfcheck.patron_password_required']; + $scope.login = function(args) { $scope.login_failed = false; if (!args.username) return; + if ($scope.password_required && !args.password) return; scSvc.login_patron(args.username, args.password).then( function() { @@ -249,14 +323,20 @@ function($scope, $q, $location , egCore, scSvc) { .controller('CheckoutCtrl', ['$scope','$q','$location','egCore','scSvc', function($scope, $q, $location , egCore, scSvc) { + scSvc.new_path_init(); + $scope.scanbox.focus = true; - if (!scSvc.patron) { - $location.path('/circ/selfcheck/login'); - return; - } +}]) - scSvc.reset_login_timer(); +.controller('ItemsCtrl', + ['$scope','$q','$location','egCore','scSvc', +function($scope, $q, $location , egCore, scSvc) { + scSvc.new_path_init(); $scope.scanbox.focus = true; + $scope.circs = []; + + scSvc.get_items_out().then(null, null, + function(circ_blob) { $scope.circs.push(circ_blob) }); }])