[open-ils-commits] r12087 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 5 19:08:38 EST 2009
Author: erickson
Date: 2009-02-05 19:08:37 -0500 (Thu, 05 Feb 2009)
New Revision: 12087
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
Log:
added support for auto-building select options from has_a links, using the selector attribute when defined. mostly functional, needs some tweaking
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-02-05 23:10:29 UTC (rev 12086)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-02-06 00:08:37 UTC (rev 12087)
@@ -104,6 +104,9 @@
this.widgetValue = openils.Util.isTrue(this.widgetValue);
break;
+ case 'link':
+ if(this._buildLinkSelector()) break;
+
default:
dojo.require('dijit.form.TextBox');
this.widget = new dijit.form.TextBox(this.dijitArgs, this.parentNode);
@@ -113,6 +116,50 @@
return this.widget;
},
+ _buildLinkSelector : function() {
+ if(this.idlField.reltype != 'has_a') return false;
+ dojo.require('openils.PermaCrud');
+ dojo.require('dojo.data.ItemFileReadStore');
+ dojo.require('dijit.form.FilteringSelect');
+
+ var self = this;
+ this.async = true;
+ var linkClass = this.idlField['class'];
+ this.widget = new dijit.form.FilteringSelect(this.dijitArgs, this.parentNode);
+ var rclassIdl = fieldmapper.IDL.fmclasses[linkClass];
+ var vfield;
+ for(var f in rclassIdl.fields) {
+ if(self.idlField.key == rclassIdl.fields[f].name) {
+ vfield = rclassIdl.fields[f];
+ break;
+ }
+ }
+ this.widget.searchAttr = this.widget.labelAttr = vfield.selector || vfield.name;
+ this.widget.valueAttr = vfield.name;
+ var list = new openils.PermaCrud().retrieveAll(linkClass);
+
+ self.widget.store = new dojo.data.ItemFileReadStore(
+ {data:fieldmapper[linkClass].toStoreData(list)}
+ );
+ self.widget.startup();
+ self._widgetLoaded();
+
+ /*
+ new openils.PermaCrud().retrieveAll(linkClass, {
+ async : true,
+ oncomplete : function(r) {
+ var list = openils.Util.readResponse(r, false, true);
+ if(list) {
+ self.widget.store =
+ new dojo.data.ItemFileReadStore({data:fieldmapper[linkClass].toStoreData(list)});
+ }
+ self.widget.startup();
+ self._widgetLoaded();
+ }
+ });
+ */
+ },
+
/**
* For widgets that run asynchronously, provide a callback for finishing up
*/
More information about the open-ils-commits
mailing list