plugged in link to address owner when address is owned by another user (e.g. via...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Oct 2009 20:42:36 +0000 (20:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Oct 2009 20:42:36 +0000 (20:42 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14285 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 9ffb8f6..b48e434 100644 (file)
@@ -797,6 +797,9 @@ function uEditNewAddr(evt, id, mkLinks) {
     if(id == null) 
         id = --uEditAddrVirtId; // new address
 
+    var addr =  patron.addresses().filter(
+        function(i) { return (i.id() == id) })[0];
+
     dojo.forEach(addrTemplateRows, 
         function(row) {
 
@@ -813,9 +816,6 @@ function uEditNewAddr(evt, id, mkLinks) {
 
             } else if(row.getAttribute('name') == 'uedit-addr-pending-row') {
 
-                var addr =  patron.addresses().filter(
-                    function(i) { return (i.id() == id) })[0];
-                
                 // if it's a pending address, show the 'approve' button
                 if(addr && openils.Util.isTrue(addr.pending())) {
                     openils.Util.show(row, 'table-row');
@@ -830,6 +830,43 @@ function uEditNewAddr(evt, id, mkLinks) {
                     }
                 }
 
+            } else if(row.getAttribute('name') == 'uedit-addr-owner-row') {
+                // address is owned by someone else.  provide option to load the
+                // user in a different tab
+                
+                if(addr && addr.usr() != patron.id()) {
+                    openils.Util.show(row, 'table-row');
+                    var link = getByName(row, 'addr-owner');
+
+                    // fetch the linked user so we can present their name in the UI
+                    var addrUser;
+                    if(cloneUserObj && cloneUserObj.id() == addr.usr()) {
+                        addrUser = [
+                            cloneUserObj.first_given_name(), 
+                            cloneUserObj.second_given_name(), 
+                            cloneUserObj.family_name()
+                        ];
+                    } else {
+                        addrUser = fieldmapper.standardRequest(
+                            ['open-ils.actor', 'open-ils.actor.user.retrieve.parts'],
+                            {params: [
+                                openils.User.authtoken, 
+                                addr.usr(), 
+                                ['first_given_name', 'second_given_name', 'family_name']
+                            ]}
+                        );
+                    }
+
+                    link.innerHTML = addrUser[0] + ' ' + addrUser[1] + ' ' + addrUser[2]; // TODO i18n
+                    link.onclick = function() {
+                        if(openils.XUL.isXUL()) { 
+                            window.xulG.spawn_editor({ses:openils.User.authtoken, usr:addr.usr()})
+                        } else {
+                            parent.location.href = location.href.replace(/clone=\d+/, 'usr=' + addr.usr());
+                        }
+                    }
+                }
+
             } 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
                 
index 433f307..e918ef6 100644 (file)
             </td>
         </tr>
 
+        <tr name='uedit-addr-owner-row' type='addr-template' class='pending-addr-row hidden'>
+            <td colspan='3'>
+                <span style='padding-right:10px;'>This address is owned by another user: </span>
+                <a href='javascript:void(0);'  name='addr-owner'></a>
+            </td>
+        </tr>
+
+
         <tr fmclass='aua' fmfield='address_type' type='addr-template' required='show'/>
         <tr fmclass='aua' fmfield='post_code' type='addr-template' required='required'/>
         <tr fmclass='aua' fmfield='street1' type='addr-template' required='required'/>