added support for setting billing/mailing address on the user account. closes #74
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Oct 2009 13:05:14 +0000 (13:05 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Oct 2009 13:05:14 +0000 (13:05 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14277 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index fffc942..ff5cd31 100644 (file)
@@ -643,6 +643,13 @@ function _uEditSave(doClone) {
                         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':
@@ -733,7 +740,10 @@ function uEditRefreshXUL(newuser) {
 
 
 function uEditNewAddr(evt, id) {
-    if(id == null) id = --uEditAddrVirtId;
+
+    if(id == null) 
+        id = --uEditAddrVirtId; // new address
+
     dojo.forEach(addrTemplateRows, 
         function(row) {
 
@@ -763,6 +773,21 @@ function uEditNewAddr(evt, id) {
                     }
                 }
 
+            } 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(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(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) };