From: erickson Date: Tue, 6 Oct 2009 14:57:26 +0000 (+0000) Subject: backporting -r14276:14278. added support for setting billing/mailing address on... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=37d751f6f12ba82a0fd4e8dd3d032326baf57a41;p=Evergreen.git backporting -r14276:14278. added support for setting billing/mailing address on the user account. make new addresses valid by default. make the 1st address on a new patron the billing/mailing address git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@14279 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 f018daca7a..3dffc85873 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -11,6 +11,8 @@ dojo.require('dijit.form.Button'); dojo.require('dojo.date'); dojo.require('openils.CGI'); dojo.require('openils.XUL'); +dojo.require('openils.Util'); +dojo.require('openils.Event'); dojo.requireLocalization('openils.actor', 'register'); var localeStrings = dojo.i18n.getLocalization('openils.actor', 'register'); @@ -89,7 +91,7 @@ function load() { loadStaticFields(); if(patron.isnew()) - uEditNewAddr(null, uEditAddrVirtId); + uEditNewAddr(null, uEditAddrVirtId, true); else loadAllAddrs(); loadStatCats(); loadSurveys(); @@ -101,6 +103,7 @@ function uEditLoadUser(userId) { ['open-ils.actor', 'open-ils.actor.user.fleshed.retrieve'], {params : [openils.User.authtoken, userId]} ); + openils.Event.parse_and_raise(patron); } function loadStaticFields() { @@ -565,6 +568,13 @@ function _uEditSave(doClone) { addr.ischanged(1); } addr[w._fmfield](val); + + if(dojo.byId('uedit-billing-address-' + addr.id()).checked) + patron.billing_address(addr.id()); + + if(dojo.byId('uedit-mailing-address-' + addr.id()).checked) + patron.mailing_address(addr.id()); + break; case 'survey': @@ -651,8 +661,18 @@ function uEditRefreshXUL(newuser) { } -function uEditNewAddr(evt, id) { - if(id == null) id = --uEditAddrVirtId; +/** + * Create a new address and insert it into the DOM + * @param evt ignored + * @param id The address id + * @param mkLinks If true, set the new address as the + * mailing/billing address for the user + */ +function uEditNewAddr(evt, id, mkLinks) { + + if(id == null) + id = --uEditAddrVirtId; // new address + dojo.forEach(addrTemplateRows, function(row) { @@ -661,7 +681,11 @@ function uEditNewAddr(evt, id) { row.setAttribute('addr', id+''); if(row.getAttribute('fmclass')) { - fleshFMRow(row, 'aua', {addr:id}); + var widget = fleshFMRow(row, 'aua', {addr:id}); + + // make new addresses valid by default + if(id < 0 && row.getAttribute('fmfield') == 'valid') + widget.widget.attr('value', true); } else if(row.getAttribute('name') == 'uedit-addr-pending-row') { @@ -682,6 +706,21 @@ function uEditNewAddr(evt, id) { } } + } 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 + + // billing address + var ba = getByName(row, 'billing_address'); + ba.id = 'uedit-billing-address-' + id; + if(mkLinks || (patron.billing_address() && patron.billing_address().id() == id)) + ba.checked = true; + + // mailing address + var ma = getByName(row, 'mailing_address'); + ma.id = 'uedit-mailing-address-' + id; + if(mkLinks || (patron.mailing_address() && patron.mailing_address().id() == id)) + ma.checked = true; + } else { var btn = dojo.query('[name=delete-button]', row)[0]; if(btn) btn.onclick = function(){ uEditDeleteAddr(id) };