[open-ils-commits] r15142 - 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
Fri Dec 11 10:41:19 EST 2009
Author: erickson
Date: 2009-12-11 10:41:16 -0500 (Fri, 11 Dec 2009)
New Revision: 15142
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
added support for staff control of event-def opt-in user settings. iow, staff can turn on the X-day overdue notice for patrons if it is an opt-in notice
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-12-11 15:40:17 UTC (rev 15141)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-12-11 15:41:16 UTC (rev 15142)
@@ -34,12 +34,14 @@
var orgSettings = {};
var userSettings = {};
var userSettingsToUpdate = {};
+var userSettingTypes;
var tbody;
var addrTemplateRows;
var cgi;
var cloneUser;
var cloneUserObj;
var stageUser;
+var optInSettings;
if(!window.xulG) var xulG = null;
@@ -224,9 +226,32 @@
function uEditFetchUserSettings(userId) {
+
+ var baseNode = fieldmapper.aou.findOrgUnit(staff.ws_ou());
+ var orgs = fieldmapper.aou.orgNodeTrail(baseNode);
+ orgs = orgs.map(function(node) { return node.id(); });
+
+ /* fetch any user setting types we need + any that offer opt-in */
+ userSettingTypes = pcrud.search('cust', {
+ '-or' : [
+ {name:['circ.holds_behind_desk']},
+ {name : {
+ 'in': {
+ select : {atevdef : ['opt_in_setting']},
+ from : 'atevdef',
+ // we only care about opt-in settings for event_defs our users encounter
+ where : {'+atevdef' : {owner : orgs}}
+ }
+ }}
+ ]
+ });
+
+ var names = userSettingTypes.map(function(obj) { return obj.name() });
+
+ /* fetch any values set for this user */
userSettings = fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'],
- {params : [openils.User.authtoken, userId, ['circ.holds_behind_desk']]});
+ {params : [openils.User.authtoken, userId, names]});
}
@@ -247,29 +272,29 @@
if(fmcls) {
fleshFMRow(row, fmcls);
} else {
- if(row.getAttribute('user_setting'))
- fleshUserSettingRow(row, row.getAttribute('user_setting'))
+
+ if(row.id == 'uedit-settings-divider') {
+
+ var template = tbody.removeChild(dojo.byId('uedit-user-setting-template'));
+ dojo.forEach(userSettingTypes, function(type) { uEditDrawSettingRow(tbody, row, template, type); } );
+
+ if(userSettingTypes.length > 1 || orgSettings['circ.holds.behind_desk_pickup_supported']) {
+ openils.Util.show('uedit-settings-divider', 'table-row');
+ }
+ }
}
}
}
-function fleshUserSettingRow(row, userSetting) {
- switch(userSetting) {
- case 'circ.holds_behind_desk':
- if(orgSettings['circ.holds.behind_desk_pickup_supported']) {
- openils.Util.show('uedit-settings-divider', 'table-row');
- openils.Util.show(row, 'table-row');
- if(userSettings[userSetting])
- holdsBehindShelfBox.attr('checked', true);
-
- // if the setting changes, add it to the list of settings that need updating
- dojo.connect(
- holdsBehindShelfBox,
- 'onChange',
- function(newVal) { userSettingsToUpdate['circ.holds_behind_desk'] = newVal; }
- );
- }
- }
+function uEditDrawSettingRow(tbody, dividerRow, template, stype) {
+ var row = template.cloneNode(true);
+ row.setAttribute('user_setting', stype.name());
+ getByName(row, 'label').innerHTML = stype.label();
+ var cb = new dijit.form.CheckBox({}, getByName(row, 'widget'));
+ cb.attr('value', userSettings[stype.name()]);
+ dojo.connect(cb, 'onChange', function(newVal) { userSettingsToUpdate[stype.name()] = newVal; });
+ tbody.insertBefore(row, dividerRow.nextSibling);
+ openils.Util.show(row, 'table-row');
}
function uEditUpdateUserSettings(userId) {
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-12-11 15:40:17 UTC (rev 15141)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-12-11 15:41:16 UTC (rev 15142)
@@ -117,10 +117,10 @@
<tr fmclass='au' fmfield='alert_message' wclass='dijit.form.Textarea' wstyle='height:5em'/>
<tr class='divider hidden' id='uedit-settings-divider'><td colspan='0'>User Settings</td></tr>
- <tr user_setting='circ.holds_behind_desk'class='hidden'>
+ <tr class='hidden' id='uedit-user-setting-template'>
<td/>
- <td>Holds Behind Shelf</td>
- <td><div dojoType='dijit.form.CheckBox' jsId='holdsBehindShelfBox'/></td>
+ <td><span name='label'></span></td>
+ <td><div name='widget'></div></td>
</tr>
<!-- Address -->
More information about the open-ils-commits
mailing list