[open-ils-commits] r12218 - in trunk/Open-ILS/web: js/ui/default/actor/user templates/default/actor/user (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 18 12:15:17 EST 2009


Author: erickson
Date: 2009-02-18 12:15:13 -0500 (Wed, 18 Feb 2009)
New Revision: 12218

Modified:
   trunk/Open-ILS/web/js/ui/default/actor/user/register.js
   trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
added onchange to copy new barcodes into usrname field

Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js	2009-02-18 07:51:39 UTC (rev 12217)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js	2009-02-18 17:15:13 UTC (rev 12218)
@@ -180,28 +180,46 @@
     widget._fmfield = fmfield;
     widget._addr = args.addr;
     widgetPile.push(widget);
-    attachEvents(fmcls, fmfield, widget);
+    attachWidgetEvents(fmcls, fmfield, widget);
     return widget;
 }
 
-function attachEvents(fmcls, fmfield, widget) {
+function findWidget(wtype, fmfield) {
+    return widgetPile.filter(
+        function(i){
+            return (i._wtype == wtype && i._fmfield == fmfield);
+        }
+    ).pop();
+}
+
+function attachWidgetEvents(fmcls, fmfield, widget) {
+
+    if(fmcls == 'ac') {
+        if(fmfield == 'barcode') {
+            dojo.connect(widget.widget, 'onChange',
+                function() {
+                    var un = findWidget('au', 'usrname');
+                    if(!un.widget.attr('value'))
+                        un.widget.attr('value', this.attr('value'));
+                }
+            );
+        }
+    }
+
     if(fmcls == 'au') {
         switch(fmfield) {
 
             case 'profile': // when the profile changes, update the expire date
                 dojo.connect(widget.widget, 'onChange', 
                     function() {
-
-                        var expireWidget = widgetPile.filter(
-                            function(i){return (i._fmfield == 'expire_date')})[0];
                         var self = this;
-
+                        var expireWidget = findWidget('au', 'expire_date');
                         function found(items) {
                             if(items.length == 0) return;
                             var item = items[0];
                             var interval = self.store.getValue(item, 'perm_interval');
-                            expireWidget.widget.attr('value', 
-                                dojo.date.add(new Date(), 'second', openils.Util.intervalToSeconds(interval)));
+                            expireWidget.widget.attr('value', dojo.date.add(new Date(), 
+                                'second', openils.Util.intervalToSeconds(interval)));
                         }
                         this.store.fetch({onComplete:found, query:{id:this.attr('value')}});
                     }

Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2	2009-02-18 07:51:39 UTC (rev 12217)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2	2009-02-18 17:15:13 UTC (rev 12218)
@@ -11,6 +11,7 @@
         text-align: left;
     }
 
+
     #uedit-save-div {
         position: fixed;
         top:40px;
@@ -56,7 +57,6 @@
     }
 
     .uedit-addr-del-button {margin-left: 10px; color:red;}
-    
 
 </style>
 
@@ -110,7 +110,7 @@
         <tr fmclass='aua' fmfield='within_city_limits' type='addr-template'/>
 
         <tr id='new-addr-row' class='newaddr-row'>
-            <td colspan='0' align='middle'/>
+            <td colspan='0' style='text-align:center;'>
                 <button dojoType='dijit.form.Button' onClick='uEditNewAddr'>New Address</button>
             </td>
         </tr>



More information about the open-ils-commits mailing list