[open-ils-commits] r11327 - trunk/Open-ILS/web/js/dojo/openils/widget
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Nov 24 23:51:21 EST 2008
Author: erickson
Date: 2008-11-24 23:51:19 -0500 (Mon, 24 Nov 2008)
New Revision: 11327
Added:
trunk/Open-ILS/web/js/dojo/openils/widget/PermGrpFilteringSelect.js
Log:
adding an indented group selector. some of this may be abstracted out to a generic (non-widget) group class later
Added: trunk/Open-ILS/web/js/dojo/openils/widget/PermGrpFilteringSelect.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/PermGrpFilteringSelect.js (rev 0)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/PermGrpFilteringSelect.js 2008-11-25 04:51:19 UTC (rev 11327)
@@ -0,0 +1,73 @@
+if(!dojo._hasResource["openils.widget.PermGrpFilteringSelect"]){
+ dojo._hasResource["openils.widget.PermGrpFilteringSelect"] = true;
+ dojo.provide("openils.widget.PermGrpFilteringSelect");
+ dojo.require("dijit.form.FilteringSelect");
+ dojo.require('dojo.data.ItemFileReadStore');
+ dojo.require('openils.Util');
+
+ dojo.declare(
+ "openils.widget.PermGrpFilteringSelect", [dijit.form.FilteringSelect],
+ {
+ fetchGroups : function(onload) {
+
+ if(this.groupTree)
+ return onload();
+ var self = this;
+
+ fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.groups.tree.retrieve'],
+ { async: true,
+ oncomplete: function(r) {
+ self.groupTree = openils.Util.readResponse(r);
+ onload();
+ }
+ }
+ );
+ },
+
+ flatten : function(node) {
+ if(!node) {
+ node = this.groupTree;
+ this.groupMap = {};
+ }
+ this.groupMap[node.id()] = node;
+ for(var idx in node.children())
+ this.flatten(node.children()[idx]);
+ },
+
+ drawGroups : function() {
+ var self = this;
+ this.fetchGroups(function(){self._drawGroups()});
+ },
+
+ _drawGroups : function(node, depth, list) {
+ if(!node) {
+ node = this.groupTree;
+ list = [];
+ depth = 0;
+ }
+
+ lpad = 6 * depth;
+ var data = pgt.toStoreData([node]).items[0];
+ data._label = '<div style="padding-left:'+lpad+'px;">' + node.name() + '</div>';
+ list.push(data);
+
+ for(var idx in node.children())
+ this._drawGroups(node.children()[idx], depth + 1, list);
+
+ if(depth == 0) {
+ var construct = {data : {identifier : 'id', items: list}};
+ this.store = new dojo.data.ItemFileReadStore(construct);
+ this.startup();
+ }
+ },
+
+ _getMenuLabelFromItem : function(item) {
+ return {
+ html: true,
+ label: item._label
+ };
+ }
+ }
+ );
+}
More information about the open-ils-commits
mailing list