[open-ils-commits] r8528 - in trunk:
Evergreen/xul/staff_client/server/patron
Open-ILS/src/perlmods/OpenILS/Application
Open-ILS/web/opac/skin/default/js
Open-ILS/xul/staff_client/server/patron
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 29 14:41:52 EST 2008
Author: dbs
Date: 2008-01-29 14:14:29 -0500 (Tue, 29 Jan 2008)
New Revision: 8528
Modified:
trunk/Evergreen/xul/staff_client/server/patron/ue_config.js
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/web/opac/skin/default/js/myopac.js
trunk/Open-ILS/xul/staff_client/server/patron/ue_config.js
Log:
Return explicit nulls if no matching username / barcode is found (and modify tests accordingly).
We suspect JSON::XS started returning '0' instead of 0, which threw off our logic.
Modified: trunk/Evergreen/xul/staff_client/server/patron/ue_config.js
===================================================================
--- trunk/Evergreen/xul/staff_client/server/patron/ue_config.js 2008-01-29 18:23:56 UTC (rev 8527)
+++ trunk/Evergreen/xul/staff_client/server/patron/ue_config.js 2008-01-29 19:14:29 UTC (rev 8528)
@@ -37,12 +37,12 @@
function uEditUsrnameBlur(field) {
var usrname = uEditNodeVal(field);
- if(!usrname) return;
+ if (!usrname) { return; }
var req = new Request(CHECK_USERNAME, SESSION, usrname);
req.callback(
function(r) {
var res = r.getResultObject();
- if( res && res != patron.id() ) {
+ if( res !== null && res != patron.id() ) {
field.widget.onblur = null; /* prevent alert storm */
alertId('ue_dup_username');
field.widget.onblur = uEditUsrnameBlur;
@@ -67,7 +67,7 @@
req.callback(
function(r) {
var res = r.getResultObject();
- if( res && res != patron.id() ) {
+ if( res !== null && res != patron.id() ) {
field.widget.onblur = null; /* prevent alert storm */
alertId('ue_dup_barcode');
field.widget.onblur = uEditBarcodeBlur;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-01-29 18:23:56 UTC (rev 8527)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-01-29 19:14:29 UTC (rev 8528)
@@ -2704,7 +2704,7 @@
method => 'usrname_exists',
api_name => 'open-ils.actor.username.exists',
signature => q/
- Returns 1 if the requested username exists, returns 0 otherwise
+ Returns the user ID of the requested username if that username exists, returns null otherwise
/
);
@@ -2714,14 +2714,14 @@
return $e->event unless $e->checkauth;
my $a = $e->search_actor_user({usrname => $usrname, deleted=>'f'}, {idlist=>1});
return $$a[0] if $a and @$a;
- return 0;
+ return undef;
}
__PACKAGE__->register_method(
method => 'barcode_exists',
api_name => 'open-ils.actor.barcode.exists',
signature => q/
- Returns 1 if the requested barcode exists, returns 0 otherwise
+ Returns the user ID for the requested barcode if that barcode exists, returns null otherwise
/
);
@@ -2730,8 +2730,8 @@
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
my $card = $e->search_actor_card({barcode => $barcode});
- return 0 unless @$card;
- return $card->[0]->usr;
+ return undef unless @$card;
+ return $card->[0]->usr;
}
Modified: trunk/Open-ILS/web/opac/skin/default/js/myopac.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2008-01-29 18:23:56 UTC (rev 8527)
+++ trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2008-01-29 19:14:29 UTC (rev 8528)
@@ -859,7 +859,14 @@
var req = new Request(CHECK_USERNAME, G.user.session, username);
req.send(true);
var res = req.result();
- if( res && res == G.user.id() ) {
+ /* If the username does not already exist, res will be null;
+ * we can move on to updating the username.
+ *
+ * If the username does exist, then res will be the user ID.
+ * G.user.id() gives us the currently authenticated user ID.
+ * If res == G.user.id(), we try to update the username anyways.
+ */
+ if( res !== null && res != G.user.id() ) {
alertId('myopac_username_dup');
return;
}
Modified: trunk/Open-ILS/xul/staff_client/server/patron/ue_config.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/ue_config.js 2008-01-29 18:23:56 UTC (rev 8527)
+++ trunk/Open-ILS/xul/staff_client/server/patron/ue_config.js 2008-01-29 19:14:29 UTC (rev 8528)
@@ -52,12 +52,12 @@
function uEditUsrnameBlur(field) {
var usrname = uEditNodeVal(field);
- if(!usrname) return;
+ if (!usrname) { return; }
var req = new Request(CHECK_USERNAME, SESSION, usrname);
req.callback(
function(r) {
var res = r.getResultObject();
- if( res && res != patron.id() ) {
+ if( res !== null && res != patron.id() ) {
field.widget.onblur = null; /* prevent alert storm */
alertId('ue_dup_username');
field.widget.onblur = uEditUsrnameBlur;
@@ -81,7 +81,7 @@
req.callback(
function(r) {
var res = r.getResultObject();
- if( res && res != patron.id() ) {
+ if( res !== null && res != patron.id() ) {
field.widget.onblur = null; /* prevent alert storm */
alertId('ue_dup_barcode');
field.widget.onblur = uEditBarcodeBlur;
More information about the open-ils-commits
mailing list