From: erickson Date: Tue, 6 Oct 2009 20:42:36 +0000 (+0000) Subject: plugged in link to address owner when address is owned by another user (e.g. via... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a82a7c256363b805e678a2e0352469bc8f940b2b;p=evergreen%2Fmasslnc.git plugged in link to address owner when address is owned by another user (e.g. via cloning) git-svn-id: svn://svn.open-ils.org/ILS/trunk@14285 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index 9ffb8f6e28..b48e434406 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -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 diff --git a/Open-ILS/web/templates/default/actor/user/register.tt2 b/Open-ILS/web/templates/default/actor/user/register.tt2 index 433f307648..e918ef6fc0 100644 --- a/Open-ILS/web/templates/default/actor/user/register.tt2 +++ b/Open-ILS/web/templates/default/actor/user/register.tt2 @@ -143,6 +143,14 @@ + + + This address is owned by another user: + + + + +