[open-ils-commits] r14279 - branches/rel_1_6/Open-ILS/web/js/ui/default/actor/user (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Oct 6 10:57:29 EDT 2009


Author: erickson
Date: 2009-10-06 10:57:26 -0400 (Tue, 06 Oct 2009)
New Revision: 14279

Modified:
   branches/rel_1_6/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
backporting -r14276:14278.  added support for setting billing/mailing address on the user account.  make new addresses valid by default. make the 1st address on a new patron the billing/mailing address

Modified: branches/rel_1_6/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/js/ui/default/actor/user/register.js	2009-10-06 14:53:30 UTC (rev 14278)
+++ branches/rel_1_6/Open-ILS/web/js/ui/default/actor/user/register.js	2009-10-06 14:57:26 UTC (rev 14279)
@@ -11,6 +11,8 @@
 dojo.require('dojo.date');
 dojo.require('openils.CGI');
 dojo.require('openils.XUL');
+dojo.require('openils.Util');
+dojo.require('openils.Event');
 
 dojo.requireLocalization('openils.actor', 'register');
 var localeStrings = dojo.i18n.getLocalization('openils.actor', 'register');
@@ -89,7 +91,7 @@
 
     loadStaticFields();
     if(patron.isnew()) 
-        uEditNewAddr(null, uEditAddrVirtId);
+        uEditNewAddr(null, uEditAddrVirtId, true);
     else loadAllAddrs();
     loadStatCats();
     loadSurveys();
@@ -101,6 +103,7 @@
         ['open-ils.actor', 'open-ils.actor.user.fleshed.retrieve'],
         {params : [openils.User.authtoken, userId]}
     );
+    openils.Event.parse_and_raise(patron);
 }
 
 function loadStaticFields() {
@@ -565,6 +568,13 @@
                         addr.ischanged(1);
                 }
                 addr[w._fmfield](val);
+
+                if(dojo.byId('uedit-billing-address-' + addr.id()).checked) 
+                    patron.billing_address(addr.id());
+
+                if(dojo.byId('uedit-mailing-address-' + addr.id()).checked)
+                    patron.mailing_address(addr.id());
+
                 break;
 
             case 'survey':
@@ -651,8 +661,18 @@
 }
 
 
-function uEditNewAddr(evt, id) {
-    if(id == null) id = --uEditAddrVirtId;
+/**
+ * Create a new address and insert it into the DOM
+ * @param evt ignored
+ * @param id The address id
+ * @param mkLinks If true, set the new address as the 
+ *  mailing/billing address for the user
+ */
+function uEditNewAddr(evt, id, mkLinks) {
+
+    if(id == null) 
+        id = --uEditAddrVirtId; // new address
+
     dojo.forEach(addrTemplateRows, 
         function(row) {
 
@@ -661,8 +681,12 @@
             row.setAttribute('addr', id+'');
 
             if(row.getAttribute('fmclass')) {
-                fleshFMRow(row, 'aua', {addr:id});
+                var widget = fleshFMRow(row, 'aua', {addr:id});
 
+                // make new addresses valid by default
+                if(id < 0 && row.getAttribute('fmfield') == 'valid') 
+                    widget.widget.attr('value', true); 
+
             } else if(row.getAttribute('name') == 'uedit-addr-pending-row') {
 
                 var addr =  patron.addresses().filter(
@@ -682,6 +706,21 @@
                     }
                 }
 
+            } else if(row.getAttribute('name') == 'uedit-addr-divider') {
+                // link up the billing/mailing address and give the inputs IDs so we can acces the later
+                
+                // billing address
+                var ba = getByName(row, 'billing_address');
+                ba.id = 'uedit-billing-address-' + id;
+                if(mkLinks || (patron.billing_address() && patron.billing_address().id() == id))
+                    ba.checked = true;
+
+                // mailing address
+                var ma = getByName(row, 'mailing_address');
+                ma.id = 'uedit-mailing-address-' + id;
+                if(mkLinks || (patron.mailing_address() && patron.mailing_address().id() == id))
+                    ma.checked = true;
+
             } else {
                 var btn = dojo.query('[name=delete-button]', row)[0];
                 if(btn) btn.onclick = function(){ uEditDeleteAddr(id) };



More information about the open-ils-commits mailing list