[open-ils-commits] r11741 - in trunk/Open-ILS/web/opac: locale/en-US skin/default/js skin/default/xml/myopac
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 5 11:49:07 EST 2009
Author: erickson
Date: 2009-01-05 11:49:04 -0500 (Mon, 05 Jan 2009)
New Revision: 11741
Modified:
trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
trunk/Open-ILS/web/opac/skin/default/js/myopac.js
trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml
Log:
more prototyping of patron-manged pending address changes
Modified: trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2009-01-05 16:48:11 UTC (rev 11740)
+++ trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2009-01-05 16:49:04 UTC (rev 11741)
@@ -278,6 +278,7 @@
<!ENTITY myopac.summary.address.city "City">
<!ENTITY myopac.summary.address.county "County">
<!ENTITY myopac.summary.address.state "State">
+<!ENTITY myopac.summary.address.country "Country">
<!ENTITY myopac.summary.address.zip "Zip">
<!ENTITY myopac.summary.username.error "Please enter a username">
<!ENTITY myopac.summary.username.dup "The requested username is not available. Please choose a different username.">
Modified: trunk/Open-ILS/web/opac/skin/default/js/myopac.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2009-01-05 16:48:11 UTC (rev 11740)
+++ trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2009-01-05 16:49:04 UTC (rev 11741)
@@ -866,12 +866,14 @@
function myOPACDrawAddr(row, addr, addrs) {
appendClear($n(row, 'myopac_addr_type'),text(addr.address_type()));
- var street = (addr.street2()) ? addr.street1() + ", " + addr.street2() : addr.street1();
- appendClear($n(row, 'myopac_addr_street'),text(street));
+ appendClear($n(row, 'myopac_addr_street'),text(addr.street1()));
+ appendClear($n(row, 'myopac_addr_street2'),text(addr.street2()));
appendClear($n(row, 'myopac_addr_city'),text(addr.city()));
appendClear($n(row, 'myopac_addr_county'),text(addr.county()));
appendClear($n(row, 'myopac_addr_state'),text(addr.state()));
+ appendClear($n(row, 'myopac_addr_country'),text(addr.country()));
appendClear($n(row, 'myopac_addr_zip'),text(addr.post_code()));
+ $n(row, 'myopac_addr_edit_link').onclick = function(){myopacEditAddress(addr)};
/* if we have a replacement address, plop it into the table next to this addr */
var repl = grep(addrs,
@@ -880,20 +882,101 @@
}
);
+ $n(row, 'myopac_pending_addr_td').id = 'myopac_pending_addr_td_' + addr.id();
+
if(repl) {
+ hideMe($n(row, 'myopac_addr_edit_td')); // hide the edit link
repl = repl[0];
- unHideMe($n(row, 'myopac_pending_addr_td'));
- $n(row, 'myopac_pending_addr_type').value = repl.address_type();
- var street = (repl.street2()) ? repl.street1() + ", " + repl.street2() : repl.street1();
- $n(row, 'myopac_pending_addr_street').value = street;
- $n(row, 'myopac_pending_addr_city').value = repl.city();
- $n(row, 'myopac_pending_addr_county').value = repl.county();
- $n(row, 'myopac_pending_addr_state').value = repl.state();
- $n(row, 'myopac_pending_addr_zip').value = repl.post_code();
+ myopacSetAddrInputs(row, repl);
}
}
+function myopacEditAddress(addr) {
+ var td = $('myopac_pending_addr_td_' + addr.id());
+ var row = td.parentNode;
+ myopacSetAddrInputs(row, addr);
+}
+function myopacSetAddrInputs(row, addr, prefix) {
+ unHideMe($n(row, 'myopac_pending_addr_td'));
+ $n(row, 'myopac_pending_addr_type').value = addr.address_type();
+ $n(row, 'myopac_pending_addr_street').value = addr.street1();
+ $n(row, 'myopac_pending_addr_street2').value = addr.street2();
+ $n(row, 'myopac_pending_addr_city').value = addr.city();
+ $n(row, 'myopac_pending_addr_county').value = addr.county();
+ $n(row, 'myopac_pending_addr_state').value = addr.state();
+ $n(row, 'myopac_pending_addr_country').value = addr.country();
+ $n(row, 'myopac_pending_addr_zip').value = addr.post_code();
+ $n(row, 'myopac_pending_addr_edit_link').onclick = function(){myopacSaveAddress(row, addr)};
+ $n(row, 'myopac_pending_addr_del_link').onclick = function(){myopacSaveAddress(row, addr, true)};
+}
+
+// if no pending addr exists, this is called with the original address
+function myopacSaveAddress(row, addr, deleteMe) {
+
+ if(addr.replaces() == null) {
+ // we are editing a non-pending address. create a pending address to manage that
+ var repl = new aua();
+ repl.usr(addr.usr());
+ repl.address_type(addr.address_type());
+ repl.within_city_limits(addr.within_city_limits());
+ repl.replaces(addr.id());
+ repl.isnew(true);
+ repl.id(null);
+ addr = repl;
+ }
+
+ if(deleteMe) {
+ if(addr.id() == null) {
+ hideMe($n(row, 'myopac_pending_addr_td'));
+ return;
+ }
+ addr.isdeleted(true);
+ } else {
+ addr.address_type($n(row, 'myopac_pending_addr_type').value);
+ addr.street1($n(row, 'myopac_pending_addr_street').value);
+ addr.street2($n(row, 'myopac_pending_addr_street2').value);
+ addr.city($n(row, 'myopac_pending_addr_city').value);
+ addr.county($n(row, 'myopac_pending_addr_county').value);
+ addr.state($n(row, 'myopac_pending_addr_state').value);
+ addr.country($n(row, 'myopac_pending_addr_country').value);
+ addr.post_code($n(row, 'myopac_pending_addr_zip').value);
+ }
+
+ var req = new Request(
+ 'open-ils.actor:open-ils.actor.user.address.pending.cud',
+ G.user.session, addr);
+
+ req.callback(
+ function(r) {
+ var resp = r.getResultObject();
+
+ if(addr.isnew()) {
+ // new, add to list of addrs
+ addr.id(resp);
+ fleshedUser.addresses().push(addr);
+
+ } else {
+ // deleted, remove from list of addrs
+ if(addr.isdeleted()) {
+ hideMe($n(row, 'myopac_pending_addr_td'));
+ var addrs = [];
+ for(var i in fleshedUser.addresses()) {
+ var a = fleshedUser.addresses()[i];
+ if(a.id() != addr.id())
+ addrs.push(a);
+ }
+ fleshedUser.addresses(addrs);
+ }
+ }
+
+ alert('done');
+ }
+ );
+ req.send();
+};
+
+
function myOPACUpdateUsername() {
var username = $('myopac_new_username').value;
if(username == null || username == "") {
Modified: trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml 2009-01-05 16:48:11 UTC (rev 11740)
+++ trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml 2009-01-05 16:49:04 UTC (rev 11741)
@@ -189,6 +189,10 @@
<td name='myopac_addr_street'> </td>
</tr>
<tr>
+ <td>&myopac.summary.address.street;</td>
+ <td name='myopac_addr_street2'> </td>
+ </tr>
+ <tr>
<td>&myopac.summary.address.city;</td>
<td name='myopac_addr_city'> </td>
</tr>
@@ -201,9 +205,18 @@
<td name='myopac_addr_state'> </td>
</tr>
<tr>
+ <td>&myopac.summary.address.country;</td>
+ <td name='myopac_addr_country'> </td>
+ </tr>
+ <tr>
<td>&myopac.summary.address.zip;</td>
<td name='myopac_addr_zip'> </td>
</tr>
+ <tr>
+ <td name='myopac_addr_edit_td' colspan='2'>
+ <a class='classic_link' name='myopac_addr_edit_link' href='javascript:void(0);'>Edit Address</a>
+ </td>
+ </tr>
</table>
</td>
<td class='hide_me' name='myopac_pending_addr_td'>
@@ -217,6 +230,10 @@
<td><input name='myopac_pending_addr_street'/> </td>
</tr>
<tr>
+ <td>&myopac.summary.address.street;</td>
+ <td><input name='myopac_pending_addr_street2'/> </td>
+ </tr>
+ <tr>
<td>&myopac.summary.address.city;</td>
<td><input name='myopac_pending_addr_city'/> </td>
</tr>
@@ -229,9 +246,19 @@
<td><input name='myopac_pending_addr_state'/> </td>
</tr>
<tr>
+ <td>&myopac.summary.address.country;</td>
+ <td><input name='myopac_pending_addr_country'/> </td>
+ </tr>
+ <tr>
<td>&myopac.summary.address.zip;</td>
<td><input name='myopac_pending_addr_zip'/> </td>
</tr>
+ <tr>
+ <td name='myopac_addr_edit_td' colspan='2'>
+ <a class='classic_link' name='myopac_pending_addr_edit_link' href='javascript:void(0);'>Save Changes</a>
+ <a style='padding-left:10px;' class='classic_link' name='myopac_pending_addr_del_link' href='javascript:void(0);'>Discard Pending Address</a>
+ </td>
+ </tr>
</table>
</td>
</tr>
More information about the open-ils-commits
mailing list