From: erickson Date: Fri, 23 Jan 2009 15:56:34 +0000 (+0000) Subject: don't forget the forests X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b0761740a6da45f7aa066269b6d3f2c71b6f3d02;p=Evergreen.git don't forget the forests git-svn-id: svn://svn.open-ils.org/ILS/trunk@11933 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js b/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js index 48424d085a..30e1a81f31 100644 --- a/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js +++ b/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js @@ -25,6 +25,7 @@ if(!dojo._hasResource["openils.widget.FilteringTreeSelect"]){ labelAttr : 'name', childField : 'children', tree : null, + dataList : [], startup : function() { this.tree = (typeof this.tree == 'string') ? @@ -33,19 +34,19 @@ if(!dojo._hasResource["openils.widget.FilteringTreeSelect"]){ console.log("openils.widget.FilteringTreeSelect: Tree needed!"); return; } - var list = this._makeNodeList(this.tree); + if(!dojo.isArray(this.tree)) this.tree = [this.tree]; + var self = this; + this.tree.forEach(function(node) { self._makeNodeList(node); }); this.store = new dojo.data.ItemFileReadStore( - {data:fieldmapper[list[0].classname].toStoreData(list)}); + {data:fieldmapper[this.dataList[0].classname].toStoreData(this.dataList)}); this.inherited(arguments); }, // Compile the tree down to a dept-first list of nodes - _makeNodeList : function(node, list) { - if(!list) list = []; - list.push(node); + _makeNodeList : function(node) { + this.dataList.push(node); for(var i in node[this.childField]()) - this._makeNodeList(node[this.childField]()[i], list); - return list; + this._makeNodeList(node[this.childField]()[i]); }, // For each item, find the depth at display time by searching up the tree.