[open-ils-commits] r17481 - in branches/rel_2_0/Open-ILS: src/sql/Pg src/sql/Pg/upgrade web/js/ui/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Sep 3 15:15:23 EDT 2010
Author: erickson
Date: 2010-09-03 15:15:18 -0400 (Fri, 03 Sep 2010)
New Revision: 17481
Added:
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0386.data.org-setting-patron-clone-copy-addr.sql
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/950.data.seed-values.sql
branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
back-porting: 17480 => patron address copy on clone instead of link
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-03 19:13:08 UTC (rev 17480)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-03 19:15:18 UTC (rev 17481)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0385'); -- gmc
+INSERT INTO config.upgrade_log (version) VALUES ('0386'); -- berick
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-09-03 19:13:08 UTC (rev 17480)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-09-03 19:15:18 UTC (rev 17481)
@@ -6820,3 +6820,23 @@
(35, 'usr.card'),
(35, 'pickup_lib')
;
+
+-- 0386.data.org-setting-patron-clone-copy-addr.sql
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+ 'circ.patron_edit.clone.copy_address',
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'Patron Registration: Cloned patrons get address copy',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'In the Patron editor, copy addresses from the cloned user instead of linking directly to the address',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+);
+
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0386.data.org-setting-patron-clone-copy-addr.sql (from rev 17480, trunk/Open-ILS/src/sql/Pg/upgrade/0386.data.org-setting-patron-clone-copy-addr.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0386.data.org-setting-patron-clone-copy-addr.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0386.data.org-setting-patron-clone-copy-addr.sql 2010-09-03 19:15:18 UTC (rev 17481)
@@ -0,0 +1,22 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0386');
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+ 'circ.patron_edit.clone.copy_address',
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'Patron Registration: Cloned patrons get address copy',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.patron_edit.clone.copy_address',
+ 'In the Patron editor, copy addresses from the cloned user instead of linking directly to the address',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+);
+
+COMMIT;
Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js 2010-09-03 19:13:08 UTC (rev 17480)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js 2010-09-03 19:15:18 UTC (rev 17481)
@@ -44,6 +44,7 @@
var stageUser;
var optInSettings;
var allCardsTemplate;
+var uEditCloneCopyAddr; // if true, copy addrs on clone instead of link
var dupeUsrname = false;
var dupeBarcode = false;
@@ -81,12 +82,15 @@
'global.juvenile_age_threshold',
'patron.password.use_phone',
'ui.patron.default_inet_access_level',
- 'circ.holds.behind_desk_pickup_supported'
+ 'circ.holds.behind_desk_pickup_supported',
+ 'circ.patron_edit.clone.copy_address'
]);
+
for(k in orgSettings)
if(orgSettings[k])
orgSettings[k] = orgSettings[k].value;
+ uEditCloneCopyAddr = orgSettings['circ.patron_edit.clone.copy_address'];
uEditUsePhonePw = orgSettings['patron.password.use_phone'];
uEditFetchUserSettings(userId);
@@ -285,34 +289,69 @@
function uEditCopyCloneData(patron) {
cloneUserObj = uEditLoadUser(cloneUser);
- dojo.forEach( [
+ var cloneFields = [
'home_ou',
'day_phone',
'evening_phone',
'other_phone',
- 'billing_address',
- 'usrgroup',
- 'mailing_address' ],
+ 'usrgroup'
+ ];
+
+ if(!uEditCloneCopyAddr)
+ cloneFields = cloneFields.concat(['mailing_address', 'billing_address']);
+
+ dojo.forEach(
+ cloneFields,
function(field) {
patron[field](cloneUserObj[field]());
}
);
- // don't grab all addresses(). the only ones we can link to are billing/mailing
- if(patron.billing_address()) {
- var t = patron.addresses();
- if (!t) { t = []; }
- t.push(patron.billing_address());
- patron.addresses(t);
- }
+ if(uEditCloneCopyAddr) {
+ var billAddr, mailAddr;
- if(patron.mailing_address() && (
- patron.addresses().length == 0 ||
- patron.mailing_address().id() != patron.billing_address().id()) ) {
- var t = patron.addresses();
- if (!t) { t = []; }
- t.push(patron.mailing_address());
- patron.addresses(t);
+ // copy the billing and mailing addresses into new addresses
+ function cloneAddr(addr) {
+ var newAddr = addr.clone();
+ newAddr.isnew(true);
+ newAddr.id(uEditAddrVirtId--);
+ newAddr.usr(patron.id());
+ patron.addresses().push(newAddr);
+ return newAddr;
+ }
+
+ if(billAddr = cloneUserObj.billing_address())
+ patron.billing_address(cloneAddr(billAddr));
+
+ if(mailAddr = cloneUserObj.mailing_address()) {
+ if (billAddr && billAddr.id() == mailAddr.id()) {
+ patron.mailing_address(patron.billing_address());
+ } else {
+ patron.mailing_address(cloneAddr(mailAddr));
+ }
+ }
+
+ if(!billAddr) // if there was no billing addr, use the mailing addr
+ patron.billing_address(patron.mailing_address());
+
+ } else {
+
+ // link the billing and mailing addresses
+ if(patron.billing_address()) {
+ var t = patron.addresses();
+ if (!t) { t = []; }
+ t.push(patron.billing_address());
+ patron.addresses(t);
+ }
+
+ if(patron.mailing_address() && (
+ patron.addresses().length == 0 ||
+ patron.mailing_address().id() != patron.billing_address().id()) ) {
+ var t = patron.addresses();
+ if (!t) { t = []; }
+ t.push(patron.mailing_address());
+ patron.addresses(t);
+ }
}
}
More information about the open-ils-commits
mailing list