[open-ils-commits] r14097 - 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
Tue Sep 22 15:48:49 EDT 2009
Author: erickson
Date: 2009-09-22 15:48:44 -0400 (Tue, 22 Sep 2009)
New Revision: 14097
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
user editor: check the claims returned count update permission to see if that field needs to be disabled for editing
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-22 19:47:13 UTC (rev 14096)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-09-22 19:48:44 UTC (rev 14097)
@@ -2,6 +2,7 @@
dojo.require('dijit.form.Textarea');
dojo.require('dijit.form.FilteringSelect');
dojo.require('dijit.form.ComboBox');
+dojo.require('dijit.form.NumberSpinner');
dojo.require('fieldmapper.IDL');
dojo.require('openils.PermaCrud');
dojo.require('openils.widget.AutoGrid');
@@ -33,6 +34,7 @@
var addrTemplateRows;
var cgi;
var cloneUser;
+var claimReturnedPermList;
if(!window.xulG) var xulG = null;
@@ -93,6 +95,7 @@
else loadAllAddrs();
loadStatCats();
loadSurveys();
+ checkClaimsReturnCountPerm();
}
function uEditLoadUser(userId) {
@@ -195,6 +198,7 @@
var fmfield = row.getAttribute('fmfield');
var wclass = row.getAttribute('wclass');
var wstyle = row.getAttribute('wstyle');
+ var wconstraints = row.getAttribute('wconstraints');
var fieldIdl = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield];
if(!args) args = {};
@@ -229,7 +233,17 @@
function(i) { return (i.id() == args.addr) })[0];
break;
}
-
+
+ var dijitArgs = {
+ style: wstyle,
+ required : required,
+ constraints : (wconstraints) ? eval('('+wconstraints+')') : {} // the ()'s prevent Invalid Label errors with eval
+ };
+
+ var value = row.getAttribute('wvalue');
+ if(value !== null)
+ dijitArgs.value = value;
+
var required = row.getAttribute('required') == 'required';
var widget = new openils.widget.AutoFieldWidget({
idlField : fieldIdl,
@@ -237,10 +251,7 @@
fmClass : fmcls,
parentNode : span,
widgetClass : wclass,
- dijitArgs : {
- style: wstyle,
- required : required
- },
+ dijitArgs : dijitArgs,
orgLimitPerms : ['UPDATE_USER'],
});
@@ -265,6 +276,26 @@
).pop();
}
+/**
+ * if the user does not have the UPDATE_PATRON_CLAIM_RETURN_COUNT,
+ * they are not allowed to directly alter the claim return count.
+ * This function checks the perm and disable/enables the widget.
+ */
+function checkClaimsReturnCountPerm() {
+ new openils.User().getPermOrgList(
+ 'UPDATE_PATRON_CLAIM_RETURN_COUNT',
+ function(orgList) {
+ var cr = findWidget('au', 'claims_returned_count');
+ if(orgList.indexOf(patron.home_ou()) == -1)
+ cr.widget.attr('disabled', true);
+ else
+ cr.widget.attr('disabled', false);
+ },
+ true,
+ true
+ );
+}
+
function attachWidgetEvents(fmcls, fmfield, widget) {
if(fmcls == 'ac') {
@@ -344,6 +375,11 @@
function(newVal) { uEditDupeSearch('phone', newVal); });
return;
+ case 'home_ou':
+ dojo.connect(widget.widget, 'onChange',
+ function(newVal) { checkClaimsReturnCountPerm(); });
+ return;
+
}
}
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-09-22 19:47:13 UTC (rev 14096)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-09-22 19:48:44 UTC (rev 14097)
@@ -112,7 +112,7 @@
<tr fmclass='au' fmfield='active'/>
<tr fmclass='au' fmfield='barred'/>
<tr fmclass='au' fmfield='master_account'/>
- <tr fmclass='au' fmfield='claims_returned_count'/>
+ <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'/>
<!-- Address -->
More information about the open-ils-commits
mailing list