[open-ils-commits] r11754 - trunk/Open-ILS/web/js/dojo/openils/widget
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 6 21:23:05 EST 2009
Author: miker
Date: 2009-01-06 21:23:03 -0500 (Tue, 06 Jan 2009)
New Revision: 11754
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
Log:
allow display of a forest, instead of just one tree; refactor to use standard searchAttr and override labelAttr and labelType
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2009-01-06 18:43:45 UTC (rev 11753)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2009-01-07 02:23:03 UTC (rev 11754)
@@ -1,6 +1,6 @@
/* EXAMPLES:
-<div dojoType="openils.widget.FilteringTreeSelect" tree="orgTree" parentField="parent_ou" nameField="shortname"/>
+<div dojoType="openils.widget.FilteringTreeSelect" tree="orgTree" parentField="parent_ou" searchAttr="shortname"/>
<div dojoType="openils.widget.FilteringTreeSelect" tree="grpTree"/>
The tree attribute is expected to be a tree-shaped pile of OpenSRF objects.
@@ -21,21 +21,30 @@
defaultPad : 6,
childField : 'children',
parentField : 'parent',
- nameField : 'name',
valueField : '',
tree : "",
options : [],
values : [],
startup : function () {
+ this.labelAttr = '_label'; // force it
+ this.labelType = 'html'; // force it
+
this._tree = dojox.jsonPath.query(window, '$.' + this.tree, {evalType:"RESULT"});
+ if (!dojo.isArray(this._tree)) this._tree = [ this._tree ];
+
this._datalist = [];
if (!this.valueField) this.valueField = this._tree.Identifier;
- this._add_items( this._tree, 0 );
+ var self = this;
+ this._tree.forEach( function (node) { self._add_items( node, 0 ); } );
- var construct = {data : {identifier : this.valueField, items: this.datalist}};
- this.store = new dojo.data.ItemFileReadStore(construct);
+ this.store = new dojo.data.ItemFileReadStore({
+ data : {
+ identifier : this.valueField,
+ items : this._datalist
+ }
+ });
this.inherited(arguments);
},
@@ -44,7 +53,7 @@
var lpad = this.defaultPad * depth++;
var data = node.toStoreData();
- data._label = '<div style="padding-left:'+lpad+'px;">' + node[this.nameField]() + '</div>';
+ data._label = '<div style="padding-left:'+lpad+'px;">' + node[this.searchAttr]() + '</div>';
this._datalist.push( data );
@@ -54,13 +63,6 @@
}
return null;
- },
-
- _getMenuLabelFromItem : function(item) {
- return {
- html: true,
- label: item._label
- };
}
}
);
More information about the open-ils-commits
mailing list