[open-ils-commits] r13323 - in trunk/Open-ILS/web: js/ui/default/actor/user templates/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jun 4 18:33:38 EDT 2009
Author: erickson
Date: 2009-06-04 18:33:33 -0400 (Thu, 04 Jun 2009)
New Revision: 13323
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
plugged in pending addr approval. just need to fill in replaced addr details
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-06-04 22:27:08 UTC (rev 13322)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-06-04 22:33:33 UTC (rev 13323)
@@ -484,22 +484,86 @@
if(id == null) id = --uEditAddrVirtId;
dojo.forEach(addrTemplateRows,
function(row) {
+
row = tbody.insertBefore(row.cloneNode(true), dojo.byId('new-addr-row'));
row.setAttribute('type', '');
row.setAttribute('addr', id+'');
+
if(row.getAttribute('fmclass')) {
fleshFMRow(row, 'aua', {addr:id});
+
+ } 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');
+ dojo.query('[name=approve-button]', row)[0].onclick =
+ function() { uEditApproveAddress(addr); };
+
+ if(addr.replaces()) {
+ var div = dojo.query('[name=replaced-addr]', row)[0]
+ div.innerHTML = addr.replaces();
+ } else {
+ openils.Util.hide(dojo.query('[name=replaced-addr-div]', row)[0]);
+ }
+ }
+
} else {
- var btn = dojo.query('[name=delete-button]', row)[0];
- if(btn) btn.onclick = function(){ uEditDeleteAddr(id) };
+ var btn = dojo.query('[name=delete-button]', row)[0];
+ if(btn) btn.onclick = function(){ uEditDeleteAddr(id) };
}
}
);
}
+function uEditApproveAddress(addr) {
+ fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.user.pending_address.approve'],
+ { async: true,
+ params: [openils.User.authtoken, addr],
-function uEditDeleteAddr(id) {
- if(!confirm('Delete address ' + id)) return; /* XXX i18n */
+ oncomplete : function(r) {
+ var oldId = openils.Util.readResponse(r);
+
+ // remove addrs from UI
+ dojo.forEach(
+ patron.addresses(),
+ function(addr) { uEditDeleteAddr(addr.id(), true); }
+ );
+
+ if(oldId != null) {
+
+ // remove the replaced address
+ if(oldId != addr.id()) {
+ patron.addresses(
+ patron.addresses().filter(
+ function(i) { return (i.id() != oldId); }
+ )
+ );
+ }
+
+ // fix the the new address
+ addr.id(oldId);
+ addr.replaces(null);
+ addr.pending('f');
+
+ }
+
+ // redraw addrs
+ loadAllAddrs();
+ }
+ }
+ );
+}
+
+
+function uEditDeleteAddr(id, noAlert) {
+ if(!noAlert) {
+ if(!confirm('Delete address ' + id)) return; /* XXX i18n */
+ }
var rows = dojo.query('tr[addr='+id+']', tbody);
for(var i = 0; i < rows.length; i++)
rows[i].parentNode.removeChild(rows[i]);
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-06-04 22:27:08 UTC (rev 13322)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-06-04 22:33:33 UTC (rev 13323)
@@ -56,6 +56,8 @@
border-right:1px dashed #d9e8f9;
}
+ .pending-addr-row td { border:1px solid #aaa; }
+
.uedit-addr-del-button {margin-left: 10px; color:red;}
.dijitTextBoxFocused, .dijitFocused { border:1px dashed #3e3e3e; color: #303030; font-weight:bold;}
@@ -110,6 +112,18 @@
<button name='delete-button' class='uedit-addr-del-button'>X</button>
</td>
</tr>
+
+ <tr name='uedit-addr-pending-row' type='addr-template' class='pending-addr-row hidden'>
+ <td colspan='3'>
+ <span style='padding-right:10px;'>This is a pending address: </span>
+ <button name='approve-button'>Approve Address</button>
+ <div name='replaced-addr-div'>
+ <span>This address replaces:</span>
+ <div name='replaced-addr'></div>
+ </div>
+ </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'/>
More information about the open-ils-commits
mailing list