added duplicate username checking/warning
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 28 May 2010 15:50:23 +0000 (15:50 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 28 May 2010 15:50:23 +0000 (15:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16530 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/templates/default/actor/user/register_table.tt2

index 0ce7dec..5b4f1ff 100644 (file)
@@ -613,6 +613,36 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
     if(fmcls == 'au') {
         switch(fmfield) {
 
+            case 'usrname':
+                dojo.connect(widget.widget, 'onChange', 
+                    function() {
+                        var input = findWidget('au', 'usrname');
+                        var usrname = input.widget.attr('value');
+
+                        if(!usrname) {
+                            dojo.addClass(dojo.byId('uedit-dupe-username-warning'), 'hidden');
+                            return;
+                        }
+
+                        fieldmapper.standardRequest(
+                            ['open-ils.actor', 'open-ils.actor.username.exists'],
+                            {
+                                params: [openils.User.authtoken, usrname],
+                                oncomplete : function(r) {
+                                    var res = openils.Util.readResponse(r);
+                                    if(res) {
+                                        dojo.removeClass(dojo.byId('uedit-dupe-username-warning'), 'hidden');
+                                    } else {
+                                        dojo.addClass(dojo.byId('uedit-dupe-username-warning'), 'hidden');
+                                    }
+                                }
+                            }
+                        );
+                    }   
+                );
+
+                return;
+
             case 'profile': // when the profile changes, update the expire date
                 dojo.connect(widget.widget, 'onChange', 
                     function() {
index 0acfb11..af67820 100644 (file)
@@ -6,7 +6,14 @@
             <button dojoType='dijit.form.Button' jsId='allCards'>See All</button>
         </td>
     </tr>
-    <tr fmclass='au' fmfield='usrname' required='required'/>
+    <tr fmclass='au' fmfield='usrname' required='required'>
+        <td/><td/><td/>
+        <td>
+            <span id='uedit-dupe-username-warning' style='color:red; font-weight:bold' class='hidden'>
+                Username is already in use
+            </span>
+        </td>
+    </tr>
     <tr fmclass='au' fmfield='passwd' required='required'/>
     <tr fmclass='au' fmfield='passwd2' required='required'><td/><td>Verify Password</td><td/></tr>
     <tr fmclass='au' fmfield='first_given_name' required='required'/>