[open-ils-commits] r13319 - trunk/Open-ILS/web/js/ui/default/actor/user (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jun 4 16:35:53 EDT 2009


Author: erickson
Date: 2009-06-04 16:35:49 -0400 (Thu, 04 Jun 2009)
New Revision: 13319

Modified:
   trunk/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
added support for reading zip code db and alerting when alert msg is present

Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js	2009-06-04 19:44:52 UTC (rev 13318)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js	2009-06-04 20:35:49 UTC (rev 13319)
@@ -243,10 +243,13 @@
     return widget;
 }
 
-function findWidget(wtype, fmfield) {
+function findWidget(wtype, fmfield, callback) {
     return widgetPile.filter(
         function(i){
-            return (i._wtype == wtype && i._fmfield == fmfield);
+            if(i._wtype == wtype && i._fmfield == fmfield) {
+                if(callback) return callback(i);
+                return true;
+            }
         }
     ).pop();
 }
@@ -285,6 +288,30 @@
                 );
         }
     }
+
+    if(fmclass = 'aua') {
+        switch(fmfield) {
+            case 'post_code':
+                dojo.connect(widget.widget, 'onChange',
+                    function(e) { 
+                        fieldmapper.standardRequest(
+                            ['open-ils.search', 'open-ils.search.zip'],
+                            {   async: true,
+                                params: [e],
+                                oncomplete : function(r) {
+                                    var res = openils.Util.readResponse(r);
+                                    var callback = function(w) { return w._addr == widget._addr; };
+                                    if(res.city) findWidget('aua', 'city', callback).widget.attr('value', res.city);
+                                    if(res.state) findWidget('aua', 'state', callback).widget.attr('value', res.state);
+                                    if(res.county) findWidget('aua', 'county', callback).widget.attr('value', res.county);
+                                    if(res.alert) alert(res.alert);
+                                }
+                            }
+                        );
+                    }
+                );
+        }
+    }
 }
 
 function getByName(node, name) {



More information about the open-ils-commits mailing list