integrate creds check UI into patron app..
authorBill Erickson <berick@esilibrary.com>
Mon, 12 May 2014 18:22:37 +0000 (14:22 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 12 May 2014 18:22:37 +0000 (14:22 -0400)
to better support the patron-specific Test Password feature, which uses
the same UI.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 [deleted file]
Open-ILS/src/templates/staff/circ/patron/index.tt2
Open-ILS/src/templates/staff/circ/patron/t_credentials.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/creds/app.js [deleted file]

diff --git a/Open-ILS/src/templates/staff/circ/patron/creds/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/creds/index.tt2
deleted file mode 100644 (file)
index d211ed7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-[%
-  WRAPPER "staff/base.tt2";
-  ctx.page_title = l("Verify Patron Credentials"); 
-  ctx.page_app = "egPatronCredsApp";
-%]
-
-[% BLOCK APP_JS %]
-<!-- needed for password mangling -->
-<script src="[% ctx.media_prefix %]/js/dojo/opensrf/md5.js"></script>
-<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
-<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/creds/app.js"></script>
-[% END %]
-
-
-<div class="container" ng-controller="PatronVerifyCredentialsCtrl">
-  <div class="row">
-    <div class="col-md-6">
-      <fieldset>
-        <legend>[% l('Verify Credentials') %]</legend>
-        <form ng-submit="verify()" 
-          name="verify-creds-form" class="form-horizontal" role="form">
-
-          <div class="form-group">
-            <label class="col-md-4 control-label" 
-              for="verify-username">[% l('Username') %]</label>
-            <div class="col-md-8">
-              <input type="text" id="verify-username" class="form-control" 
-                focus-me="focusMe" 
-                placeholder="[% l('Username') %]" ng-model="username"/>
-            </div>
-          </div>
-
-          <div class="form-group">
-            <label class="col-md-4 control-label" 
-              for="verify-barcode">[% l('Barcode') %]</label>
-            <div class="col-md-8">
-              <input type="text" id="verify-barcode" class="form-control" 
-                placeholder="[% l('Barcode') %]" ng-model="barcode"/>
-            </div>
-          </div>
-
-          <div class="form-group">
-            <label class="col-md-4 control-label" 
-              for="verify-password">[% l('Password') %]</label>
-            <div class="col-md-8">
-              <input type="password" id="verify-password" class="form-control" 
-                placeholder="[% l('Password') %]" ng-model="password"/>
-            </div>
-          </div>
-
-          <div class="form-group">
-            <div class="col-md-offset-4 col-md-2">
-              <button type="submit" class="btn btn-default">[% l('Verify') %]</button>
-            </div>
-            <div class="col-md-2">
-              <button class="btn btn-default" ng-click="load($event)">[% l('Retrieve') %]</button>
-            </div>
-          </div>
-
-          <div class="form-group" ng-cloak>
-            <div class="col-md-offset-4 col-md-8">
-              <div class="alert alert-success" ng-show="verified">
-                [% l('Succes testing credentials') %]
-              </div>
-              <div class="alert alert-danger" ng-show="verified === false">
-                [% l('Failure testing credentials') %]
-              </div>
-              <div class="alert alert-danger" ng-show="notFound">
-                [% l('No user found with the requested username / barcode') %]
-              </div>
-            </div>
-          </div>
-
-        </form>
-      </fieldset>
-    <div><!-- col -->
-  </div><!-- row -->
-</div><!-- container -->
-[% END %]
index f3f80ca..9f7acdf 100644 (file)
@@ -11,6 +11,9 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/user.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/app.js"></script>
 
+<!-- required for credentials verify API -->
+<script src="[% ctx.media_prefix %]/js/dojo/opensrf/md5.js"></script>
+
 <!-- load on demand? -->
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/checkout.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/items_out.js"></script>
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_credentials.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_credentials.tt2
new file mode 100644 (file)
index 0000000..46f6e04
--- /dev/null
@@ -0,0 +1,64 @@
+<div class="container">
+  <div class="row">
+    <div class="col-md-6">
+      <fieldset>
+        <legend>[% l('Verify Credentials') %]</legend>
+        <form ng-submit="verify()" 
+          name="verify-creds-form" class="form-horizontal" role="form">
+
+          <div class="form-group">
+            <label class="col-md-4 control-label" 
+              for="verify-username">[% l('Username') %]</label>
+            <div class="col-md-8">
+              <input type="text" id="verify-username" class="form-control" 
+                focus-me="focusMe" 
+                placeholder="[% l('Username') %]" ng-model="username"/>
+            </div>
+          </div>
+
+          <div class="form-group">
+            <label class="col-md-4 control-label" 
+              for="verify-barcode">[% l('Barcode') %]</label>
+            <div class="col-md-8">
+              <input type="text" id="verify-barcode" class="form-control" 
+                placeholder="[% l('Barcode') %]" ng-model="barcode"/>
+            </div>
+          </div>
+
+          <div class="form-group">
+            <label class="col-md-4 control-label" 
+              for="verify-password">[% l('Password') %]</label>
+            <div class="col-md-8">
+              <input type="password" id="verify-password" class="form-control" 
+                placeholder="[% l('Password') %]" ng-model="password"/>
+            </div>
+          </div>
+
+          <div class="form-group">
+            <div class="col-md-offset-4 col-md-2">
+              <button type="submit" class="btn btn-default">[% l('Verify') %]</button>
+            </div>
+            <div class="col-md-2">
+              <button class="btn btn-default" ng-click="load($event)">[% l('Retrieve') %]</button>
+            </div>
+          </div>
+
+          <div class="form-group" ng-cloak>
+            <div class="col-md-offset-4 col-md-8">
+              <div class="alert alert-success" ng-show="verified">
+                [% l('Succes testing credentials') %]
+              </div>
+              <div class="alert alert-danger" ng-show="verified === false">
+                [% l('Failure testing credentials') %]
+              </div>
+              <div class="alert alert-danger" ng-show="notFound">
+                [% l('No user found with the requested username / barcode') %]
+              </div>
+            </div>
+          </div>
+
+        </form>
+      </fieldset>
+    <div><!-- col -->
+  </div><!-- row -->
+</div><!-- container -->
index 13ff1ca..c2de8b8 100644 (file)
@@ -69,7 +69,7 @@
           </li>
           <li class="divider"></li>
           <li>
-            <a href="./circ/patron/creds/index" target="_self">
+            <a href="./circ/patron/credentials" target="_self">
               <span class="glyphicon glyphicon-ok"></span>
               <span>[% l('Verify Credentials') %]</span>
             </a>
index 394bc26..61f938a 100644 (file)
@@ -56,6 +56,11 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap',
         resolve : resolver
     });
 
+    $routeProvider.when('/circ/patron/credentials', {
+        templateUrl: './circ/patron/t_credentials',
+        controller: 'PatronVerifyCredentialsCtrl',
+        resolve : resolver
+    });
 
     $routeProvider.when('/circ/patron/:id/checkout', {
         templateUrl: './circ/patron/t_checkout',
@@ -588,3 +593,74 @@ function($scope,  $routeParams,  egCore) {
     $scope.initTab('edit', $routeParams.id);
 }])
 
+/**
+ * Credentials tester
+ */
+.controller('PatronVerifyCredentialsCtrl',
+       ['$scope','$location','egCore',
+function($scope,  $location , egCore) {
+    $scope.verified = null;
+    $scope.focusMe = true;
+
+    // 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;
+            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)) {
+                $location.path('/circ/patron/' + 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();
+    }
+}])
+
+
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
deleted file mode 100644 (file)
index 9ef6ffe..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * 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();
-    }
-}])
-