[open-ils-commits] r14284 - trunk/Open-ILS/web/js/ui/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Oct 6 13:44:52 EDT 2009
Author: erickson
Date: 2009-10-06 13:44:48 -0400 (Tue, 06 Oct 2009)
New Revision: 14284
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
starting clone support. added cloning for home org, phone numbers, and mailing/billing addresses. like previous user editor, addresses are only directly editable by the address owner. TODO, add address detachment and linking to addr owner
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-10-06 17:15:13 UTC (rev 14283)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-10-06 17:44:48 UTC (rev 14284)
@@ -38,6 +38,7 @@
var addrTemplateRows;
var cgi;
var cloneUser;
+var cloneUserObj;
var claimReturnedPermList;
@@ -77,8 +78,16 @@
orgSettings[k] = orgSettings[k].value;
uEditFetchUserSettings(userId);
- uEditLoadUser(userId);
+ if(userId) {
+ patron = uEditLoadUser(userId);
+ } else {
+ patron = uEditNewPatron();
+ if(cloneUser)
+ uEditCopyCloneData(patron);
+ }
+
+
var list = pcrud.search('fdoc', {fm_class:fmClasses});
for(var i in list) {
var doc = list[i];
@@ -96,7 +105,7 @@
surveyQuestionTemplate = tbody.removeChild(dojo.byId('survey-question-row-template'));
loadStaticFields();
- if(patron.isnew())
+ if(patron.isnew() && patron.addresses().length == 0)
uEditNewAddr(null, uEditAddrVirtId, true);
else loadAllAddrs();
loadStatCats();
@@ -104,6 +113,35 @@
checkClaimsReturnCountPerm();
}
+/*
+ * clone the home org, phone numbers, and billing/mailing address
+ */
+function uEditCopyCloneData(patron) {
+ cloneUserObj = uEditLoadUser(cloneUser);
+
+ dojo.forEach( [
+ 'home_ou',
+ 'day_phone',
+ 'evening_phone',
+ 'other_phone',
+ 'billing_address',
+ 'mailing_address' ],
+ 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())
+ patron.addresses().push(patron.billing_address());
+
+ if(patron.mailing_address() && (
+ patron.addresses().length == 0 ||
+ patron.mailing_address().id() != patron.billing_address().id()) )
+ patron.addresses().push(patron.mailing_address());
+}
+
+
function uEditFetchUserSettings(userId) {
userSettings = fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'],
@@ -112,12 +150,12 @@
function uEditLoadUser(userId) {
- if(!userId) return uEditNewPatron();
- patron = fieldmapper.standardRequest(
+ var patron = fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.user.fleshed.retrieve'],
{params : [openils.User.authtoken, userId]}
);
openils.Event.parse_and_raise(patron);
+ return patron;
}
function loadStaticFields() {
@@ -268,19 +306,23 @@
wtd.appendChild(span);
var fmObject = null;
+ var disabled = false;
switch(fmcls) {
case 'au' : fmObject = patron; break;
case 'ac' : fmObject = patron.card(); break;
case 'aua' :
fmObject = patron.addresses().filter(
function(i) { return (i.id() == args.addr) })[0];
+ if(fmObject && fmObject.usr() != patron.id())
+ disabled = true;
break;
}
var dijitArgs = {
style: wstyle,
required : required,
- constraints : (wconstraints) ? eval('('+wconstraints+')') : {} // the ()'s prevent Invalid Label errors with eval
+ constraints : (wconstraints) ? eval('('+wconstraints+')') : {}, // the ()'s prevent Invalid Label errors with eval
+ disabled : disabled
};
var value = row.getAttribute('wvalue');
@@ -594,6 +636,7 @@
patron.survey_responses([]);
patron.addresses([]);
uEditMakeRandomPw(patron);
+ return patron;
}
function uEditMakeRandomPw(patron) {
@@ -708,7 +751,7 @@
function uEditFinishSave(newPatron, doClone) {
- if(doClone &&cloneUser == null)
+ if(doClone && cloneUser == null)
cloneUser = newPatron.id();
if( doClone ) {
@@ -718,7 +761,7 @@
uEditRefresh();
} else {
- location.href = href.replace(/\?.*/, '') + '?clone=' + cloneUser;
+ location.href = location.href.replace(/\?.*/, '') + '?clone=' + cloneUser;
}
} else {
More information about the open-ils-commits
mailing list