added support for requiring workstation and patron password via org unit setting
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Nov 2009 22:39:07 +0000 (22:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Nov 2009 22:39:07 +0000 (22:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15018 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index f5e687e..3296ec5 100644 (file)
@@ -14,6 +14,7 @@
     'LOGIN_FAILED' : 'Login for ${0} failed',
     'UNKNOWN_ERROR' : 'An unhandled exception occurred with error code ${0}',
     'MAX_RENEWALS' : 'No more renewals allowed for item ${0}',
-    'ITEM_NOT_CATALOGED' : 'Item ${0} was not found in the system.  Try re-scanning the item.'
+    'ITEM_NOT_CATALOGED' : 'Item ${0} was not found in the system.  Try re-scanning the item.',
+    'WORKSTATION_REQUIRED' : 'Workstation is required.  Set the workstation name with URL param "ws"'
 }
 
index 0330c7a..cb14b4e 100644 (file)
@@ -16,6 +16,7 @@ const SET_ALERT_ON_CHECKOUT_EVENT = 'circ.selfcheck.alert_on_checkout_event';
 const SET_AUTO_OVERRIDE_EVENTS = 'circ.selfcheck.auto_override_checkout_events';
 const SET_PATRON_PASSWORD_REQUIRED = 'circ.selfcheck.patron_password_required';
 const SET_AUTO_RENEW_INTERVAL = 'circ.checkout_auto_renew_age';
+const SET_WORKSTATION_REQUIRED = 'circ.selfcheck.workstation_required';
 
 //openils.Util.playAudioUrl('/xul/server/skin/media/audio/bonus.wav');
 
@@ -71,6 +72,11 @@ SelfCheckManager.prototype.init = function() {
     this.authtoken = openils.User.authtoken;
     this.loadOrgSettings();
 
+    // workstation is required but none provided
+    if(this.orgSettings[SET_WORKSTATION_REQUIRED] && !this.workstation) {
+        alert(dojo.string.substitute(localeStrings.WORKSTATION_REQUIRED));
+        return;
+    }
     
     var self = this;
     // connect onclick handlers to the various navigation links
@@ -111,6 +117,7 @@ SelfCheckManager.prototype.loadOrgSettings = function() {
             SET_AUTO_OVERRIDE_EVENTS,
             SET_PATRON_PASSWORD_REQUIRED,
             SET_AUTO_RENEW_INTERVAL,
+            SET_WORKSTATION_REQUIRED
         ]
     );
 
@@ -134,7 +141,8 @@ SelfCheckManager.prototype.drawLoginPage = function() {
             // password is required.  wire up the scan box to read it
             self.updateScanBox({
                 msg : 'Please enter your password', // TODO i18n 
-                handler : function(pw) { self.loginPatron(barcode, pw); }
+                handler : function(pw) { self.loginPatron(barcode, pw); },
+                password : true
             });
 
         } else {
@@ -155,6 +163,12 @@ SelfCheckManager.prototype.drawLoginPage = function() {
 SelfCheckManager.prototype.loginPatron = function(barcode, passwd) {
 
     if(this.orgSettings[SET_PATRON_PASSWORD_REQUIRED]) {
+        
+        if(!passwd) {
+            // would only happen in dev/debug mode when using the patron= param
+            alert('password required by org setting.  remove patron= from URL'); 
+            return;
+        }
 
         // patron password is required.  Verify it.
 
@@ -165,7 +179,10 @@ SelfCheckManager.prototype.loginPatron = function(barcode, passwd) {
 
         if(res == 0) {
             // user-not-found results in login failure
-            this.handleXactResult('login', barcode, {textcode : 'ACTOR_USER_NOT_FOUND'});
+            dojo.byId('oils-selfck-status-div').innerHTML = 
+                dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]);
+            this.drawLoginPage();
+            return;
         }
     } 
 
@@ -177,7 +194,10 @@ SelfCheckManager.prototype.loginPatron = function(barcode, passwd) {
 
     var evt = openils.Event.parse(this.patron);
     if(evt) {
-        this.handleXactResult('login', barcode, evt);
+
+        dojo.byId('oils-selfck-status-div').innerHTML = 
+            dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]);
+        this.drawLoginPage();
 
     } else {
 
@@ -203,6 +223,12 @@ SelfCheckManager.prototype.updateScanBox = function(args) {
         selfckScanBox.attr('value', '');
     }
 
+    if(args.password) {
+        selfckScanBox.domNode.setAttribute('type', 'password');
+    } else {
+        selfckScanBox.domNode.setAttribute('type', '');
+    }
+
     if(args.value)
         selfckScanBox.attr('value', args.value);
 
@@ -592,11 +618,6 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
 
         switch(result.textcode) {
 
-            case 'ACTOR_USER_NOT_FOUND' : 
-                displayText = dojo.string.substitute(
-                    localeStrings.LOGIN_FAILED, [item]);
-                break;
-
             case 'MAX_RENEWALS_REACHED' :
                 displayText = dojo.string.substitute(
                     localeStrings.MAX_RENEWALS, [item]);