[open-ils-commits] r14219 - 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
Wed Sep 30 10:26:52 EDT 2009
Author: erickson
Date: 2009-09-30 10:26:50 -0400 (Wed, 30 Sep 2009)
New Revision: 14219
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 editing staff-managed user settings in the user editor, starting with holds behind shelf. the form entry for this setting is hidded unless the org unit supports behind-the-desk hold pickup
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-09-30 14:20:34 UTC (rev 14218)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-09-30 14:26:50 UTC (rev 14219)
@@ -30,6 +30,8 @@
var uEditCardVirtId = -1;
var uEditAddrVirtId = -1;
var orgSettings = {};
+var userSettings = {};
+var userSettingsToUpdate = {};
var tbody;
var addrTemplateRows;
var cgi;
@@ -65,12 +67,14 @@
orgSettings = fieldmapper.aou.fetchOrgSettingBatch(staff.ws_ou(), [
'global.juvenile_age_threshold',
'patron.password.use_phone',
- 'ui.patron.default_inet_access_level'
+ 'ui.patron.default_inet_access_level',
+ 'circ.holds.behind_desk_pickup_supported'
]);
for(k in orgSettings)
if(orgSettings[k])
orgSettings[k] = orgSettings[k].value;
+ uEditFetchUserSettings(userId);
uEditLoadUser(userId);
var list = pcrud.search('fdoc', {fm_class:fmClasses});
@@ -98,6 +102,13 @@
checkClaimsReturnCountPerm();
}
+function uEditFetchUserSettings(userId) {
+ userSettings = fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'],
+ {params : [openils.User.authtoken, userId, ['circ.holds_behind_desk']]});
+}
+
+
function uEditLoadUser(userId) {
if(!userId) return uEditNewPatron();
patron = fieldmapper.standardRequest(
@@ -111,11 +122,40 @@
var row = tbody.childNodes[idx];
if(row.nodeType != row.ELEMENT_NODE) continue;
var fmcls = row.getAttribute('fmclass');
- if(!fmcls) continue;
- fleshFMRow(row, fmcls);
+ if(fmcls) {
+ fleshFMRow(row, fmcls);
+ } else {
+ if(row.getAttribute('user_setting'))
+ fleshUserSettingRow(row, row.getAttribute('user_setting'))
+ }
}
}
+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 uEditUpdateUserSettings(userId) {
+ return fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.patron.settings.update'],
+ {params : [openils.User.authtoken, userId, userSettingsToUpdate]});
+}
+
function loadAllAddrs() {
dojo.forEach(patron.addresses(),
function(addr) {
@@ -646,7 +686,10 @@
params: [openils.User.authtoken, patron],
oncomplete: function(r) {
newPatron = openils.Util.readResponse(r);
- if(newPatron) uEditFinishSave(newPatron, doClone);
+ if(newPatron) {
+ uEditUpdateUserSettings(newPatron.id());
+ uEditFinishSave(newPatron, doClone);
+ }
}
}
);
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-09-30 14:20:34 UTC (rev 14218)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-09-30 14:26:50 UTC (rev 14219)
@@ -115,6 +115,13 @@
<tr fmclass='au' fmfield='claims_returned_count' wclass='dijit.form.NumberSpinner' wconstraints="{min:0,places:0}" wvalue='0'/>
<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'>
+ <td/>
+ <td>Holds Behind Shelf</td>
+ <td><div dojoType='dijit.form.CheckBox' jsId='holdsBehindShelfBox'/></td>
+ </tr>
+
<!-- Address -->
<tr name='uedit-addr-divider' class='divider' type='addr-template' required='show'>
<td colspan='2'>Address</td>
More information about the open-ils-commits
mailing list