[open-ils-commits] r14681 - in trunk/Open-ILS: web/js/dojo/openils/widget xul/staff_client/server/admin (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Oct 29 14:55:22 EDT 2009
Author: erickson
Date: 2009-10-29 14:55:18 -0400 (Thu, 29 Oct 2009)
New Revision: 14681
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
Log:
added feauture to org unit settings interface to display friendly values and selector widgets for settings with type of 'link' where pcrud for the link type is supported
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-10-29 17:55:49 UTC (rev 14680)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-10-29 18:55:18 UTC (rev 14681)
@@ -22,6 +22,11 @@
* orgLimitPerms -- If this field defines a set of org units and an orgLimitPerms
* is defined, the code will limit the org units in the set to those
* allowed by the permission
+ * selfReference -- The primary purpose of an AutoFieldWidget is to render the value
+ * or widget for a field on an object (that may or may not link to another object).
+ * selfReference allows you to sidestep the indirection and create a selector widget
+ * based purely on an fmClass. To get a dropdown of all of the 'abc'
+ * objects, pass in {selfReference : true, fmClass : 'abc'}.
*/
constructor : function(args) {
for(var k in args)
@@ -33,12 +38,27 @@
this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
this.suppressLinkedFields = args.suppressLinkedFields || [];
- if(!this.idlField) {
- this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
- var fields = this.fmIDL.fields;
- for(var f in fields)
- if(fields[f].name == this.fmField)
- this.idlField = fields[f];
+ if(this.selfReference) {
+ this.fmField = fieldmapper.IDL.fmclasses[this.fmClass].pkey;
+
+ // create a mock-up of the idlField object.
+ this.idlField = {
+ datatype : 'link',
+ 'class' : this.fmClass,
+ reltype : 'has_a',
+ key : this.fmField,
+ name : this.fmField
+ };
+
+ } else {
+
+ if(!this.idlField) {
+ this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
+ var fields = this.fmIDL.fields;
+ for(var f in fields)
+ if(fields[f].name == this.fmField)
+ this.idlField = fields[f];
+ }
}
if(!this.idlField)
@@ -355,7 +375,7 @@
} else {
this.baseWidgetValue(this.widgetValue);
- if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence)
+ if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence && !this.selfReference)
this.widget.attr('disabled', true);
if(this.disableWidgetTest && this.disableWidgetTest(this.idlField.name, this.fmObject))
this.widget.attr('disabled', true);
Modified: trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js 2009-10-29 17:55:49 UTC (rev 14680)
+++ trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js 2009-10-29 18:55:18 UTC (rev 14681)
@@ -1,3 +1,4 @@
+dojo.require('fieldmapper.AutoIDL');
dojo.require("dijit.layout.LayoutContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require('dijit.form.FilteringSelect');
@@ -12,17 +13,20 @@
dojo.require('openils.Event');
dojo.require('openils.widget.OrgUnitFilteringSelect');
dojo.require('openils.PermaCrud');
+dojo.require('openils.widget.AutoFieldWidget');
var authtoken;
var contextOrg;
var user;
var workOrgs;
var osSettings = {};
+var osEditAutoWidget;
function osInit(data) {
- authtoken = dojo.cookie('ses') || new openils.CGI().param('ses');
+ authtoken = new openils.CGI().param('ses') || dojo.cookie('ses');
user = new openils.User({authtoken:authtoken});
contextOrg = user.user.ws_ou();
+ openils.User.authtoken = authtoken;
fieldmapper.standardRequest(
[ 'open-ils.actor',
@@ -149,6 +153,7 @@
var setting = osSettings[data.name];
var value = setting[this.field];
if(value == null) return '';
+
switch(this.field) {
case 'context':
return fieldmapper.aou.findOrgUnit(value).shortname();
@@ -157,6 +162,21 @@
return value + ' *';
return value;
case 'value':
+ if(setting.fm_class) {
+ var autoWidget = new openils.widget.AutoFieldWidget(
+ {
+ fmClass : setting.fm_class,
+ selfReference : true,
+ widgetValue : value,
+ forceSync : true,
+ readOnly : true
+ }
+ );
+ autoWidget.build();
+ if(autoWidget.getDisplayString())
+ return autoWidget.getDisplayString();
+ }
+
if(setting.type == 'bool') {
if(value)
return dojo.byId('os-true').innerHTML;
@@ -192,54 +212,89 @@
dojo.style(osEditNumberTextBox.domNode, 'display', 'none');
dojo.style(osEditBoolSelect.domNode, 'display', 'none');
- var widget;
- switch(osSettings[name].type) {
- case 'number':
- widget = osEditNumberTextBox;
- break;
- case 'currency':
- widget = osEditCurrencyTextBox;
- break;
- case 'bool':
- widget = osEditBoolSelect;
- break;
- default:
- widget = osEditTextBox;
- }
+ var fmClass = osSettings[name].fm_class;
- dojo.style(widget.domNode, 'display', 'block');
- widget.setValue(osSettings[name].value);
-}
+ if(fmClass) {
-function osEditSetting(deleteMe) {
- osEditDialog.hide();
- var name = osEditDialog._osattr;
+ if(osEditAutoWidget) {
+ osEditAutoWidget.domNode.parentNode.removeChild(osEditAutoWidget.domNode);
+ osEditAutoWidget.destroy();
+ }
- var obj = {};
- if(deleteMe) {
- obj[name] = null;
+ var autoWidget = new openils.widget.AutoFieldWidget(
+ {
+ fmClass : fmClass,
+ selfReference : true,
+ parentNode : dojo.create('div', null, dojo.byId('os-edit-auto-widget')),
+ widgetValue : osSettings[name].value
+ }
+ );
+ autoWidget.build(
+ function(w) {
+ osEditAutoWidget = w;
+ }
+ );
} else {
-
+ var widget;
switch(osSettings[name].type) {
case 'number':
- obj[name] = osEditNumberTextBox.getValue();
- if(obj[name] == null) return;
+ widget = osEditNumberTextBox;
break;
case 'currency':
- obj[name] = osEditCurrencyTextBox.getValue();
- if(obj[name] == null) return;
+ widget = osEditCurrencyTextBox;
break;
case 'bool':
- var val = osEditBoolSelect.getValue();
- obj[name] = (val == 'true') ? true : false;
+ widget = osEditBoolSelect;
break;
default:
- obj[name] = osEditTextBox.getValue();
- if(obj[name] == null) return;
+ widget = osEditTextBox;
}
+
+ dojo.style(widget.domNode, 'display', 'block');
+ widget.setValue(osSettings[name].value);
}
+}
+function osEditSetting(deleteMe) {
+ osEditDialog.hide();
+ var name = osEditDialog._osattr;
+
+ var obj = {};
+ if(deleteMe) {
+ obj[name] = null;
+
+ } else {
+
+ if(osSettings[name].fm_class) {
+ var val = osEditAutoWidget.attr('value');
+ osEditAutoWidget.domNode.parentNode.removeChild(osEditAutoWidget.domNode);
+ osEditAutoWidget.destroy();
+ osEditAutoWidget = null;
+ if(val == null || val == '') return;
+ obj[name] = val;
+
+ } else {
+ switch(osSettings[name].type) {
+ case 'number':
+ obj[name] = osEditNumberTextBox.getValue();
+ if(obj[name] == null) return;
+ break;
+ case 'currency':
+ obj[name] = osEditCurrencyTextBox.getValue();
+ if(obj[name] == null) return;
+ break;
+ case 'bool':
+ var val = osEditBoolSelect.getValue();
+ obj[name] = (val == 'true') ? true : false;
+ break;
+ default:
+ obj[name] = osEditTextBox.getValue();
+ if(obj[name] == null) return;
+ }
+ }
+ }
+
fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.org_unit.settings.update'],
{ async: true,
Modified: trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2009-10-29 17:55:49 UTC (rev 14680)
+++ trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2009-10-29 18:55:18 UTC (rev 14681)
@@ -85,6 +85,7 @@
<option value='true'>&common.true;</option>
<option value='false'>&common.false;</option>
</select>
+ <div id='os-edit-auto-widget'></div>
</td>
</tr>
<tr>
More information about the open-ils-commits
mailing list