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');
var addrTemplateRows;
var cgi;
var cloneUser;
+var claimReturnedPermList;
if(!window.xulG) var xulG = null;
else loadAllAddrs();
loadStatCats();
loadSurveys();
+ checkClaimsReturnCountPerm();
}
function uEditLoadUser(userId) {
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 = {};
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,
fmClass : fmcls,
parentNode : span,
widgetClass : wclass,
- dijitArgs : {
- style: wstyle,
- required : required
- },
+ dijitArgs : dijitArgs,
orgLimitPerms : ['UPDATE_USER'],
});
).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') {
function(newVal) { uEditDupeSearch('phone', newVal); });
return;
+ case 'home_ou':
+ dojo.connect(widget.widget, 'onChange',
+ function(newVal) { checkClaimsReturnCountPerm(); });
+ return;
+
}
}