From 5be9d0ecb1e67f4a58b2e6773cdc61cabcfdf958 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 12 May 2014 12:48:38 -0400 Subject: [PATCH] Verify patron credentials UI Signed-off-by: Bill Erickson --- .../templates/staff/circ/patron/creds/index.tt2 | 79 ++++++++++++++++++++ Open-ILS/src/templates/staff/navbar.tt2 | 37 ++++++--- .../js/ui/default/staff/circ/patron/creds/app.js | 87 ++++++++++++++++++++++ 3 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 create mode 100644 Open-ILS/web/js/ui/default/staff/circ/patron/creds/app.js diff --git a/Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 new file mode 100644 index 0000000000..d211ed7fc4 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 @@ -0,0 +1,79 @@ +[% + WRAPPER "staff/base.tt2"; + ctx.page_title = l("Verify Patron Credentials"); + ctx.page_app = "egPatronCredsApp"; +%] + +[% BLOCK APP_JS %] + + + + +[% END %] + + +
+
+
+
+ [% l('Verify Credentials') %] +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ [% l('Succes testing credentials') %] +
+
+ [% l('Failure testing credentials') %] +
+
+ [% l('No user found with the requested username / barcode') %] +
+
+
+ +
+
+
+
+
+[% END %] diff --git a/Open-ILS/src/templates/staff/navbar.tt2 b/Open-ILS/src/templates/staff/navbar.tt2 index b6dea13032..13ff1ca2c4 100644 --- a/Open-ILS/src/templates/staff/navbar.tt2 +++ b/Open-ILS/src/templates/staff/navbar.tt2 @@ -28,6 +28,25 @@
  • + +
  • + +
  • - - - [% l('Patron Search') %] - -
  • -
  • [% l('Check In') %]
  • - +
  • + + + [% l('Verify Credentials') %] + +
  • diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/creds/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/creds/app.js new file mode 100644 index 0000000000..9ef6ffe659 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/creds/app.js @@ -0,0 +1,87 @@ +/** + * Patron Credentials App + */ + +angular.module('egPatronCredsApp', ['ngRoute', 'egCoreMod', 'egUiMod']) + +.config(function($locationProvider, $compileProvider) { + $locationProvider.html5Mode(true); + $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export +}) + + +/** + * Manages edit + */ +.controller('PatronVerifyCredentialsCtrl', + ['$scope','$window','egCore', +function($scope, $window , egCore) { + $scope.verified = null; + $scope.focusMe = true; + + // standalone controller w/ no resolver; load startup manually + egCore.startup.go(); + + // verify login credentials + $scope.verify = function() { + $scope.verified = null; + $scope.notFound = false; + + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.verify_user_password', + egCore.auth.token(), + $scope.barcode, + $scope.username, + hex_md5($scope.password || '') + ).then(function(resp) { + $scope.focusMe = true; + console.debug('verify replied ' + resp); + if (evt = egCore.evt.parse(resp)) { + alert(evt); + } else if (resp == 1) { + $scope.verified = true; + } else { + $scope.verified = false; + } + }); + } + + // load the main patron UI for the provided username or barcode + $scope.load = function($event) { + $scope.notFound = false; + $scope.verified = null; + + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.user.retrieve_id_by_barcode_or_username', + egCore.auth.token(), + $scope.barcode, + $scope.username + ).then(function(resp) { + if (Number(resp)) { + $window.location.href = + $window.location.href + .replace(/creds.*/,resp + '/checkout'); + return; + } + + // something went wrong... + $scope.focusMe = true; + if (evt = egCore.evt.parse(resp)) { + if (evt.textcode == 'ACTOR_USR_NOT_FOUND') { + $scope.notFound = true; + return; + } + return alert(evt); + } else { + alert(resp); + } + }); + + // load() button sits within the verify form. + // avoid submitting the verify() form action on load() + $event.preventDefault(); + } +}]) + -- 2.11.0