if(id == null)
id = --uEditAddrVirtId; // new address
+ var addr = patron.addresses().filter(
+ function(i) { return (i.id() == id) })[0];
+
dojo.forEach(addrTemplateRows,
function(row) {
} 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');
}
}
+ } 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