[open-ils-commits] r17416 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Aug 31 17:22:49 EDT 2010
Author: erickson
Date: 2010-08-31 17:22:43 -0400 (Tue, 31 Aug 2010)
New Revision: 17416
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
Log:
added support for specifying a dojo.data-style query to select options in the filtering select to 'disable'. disabling greys the background and prevents selection of the items in question
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2010-08-31 20:09:08 UTC (rev 17415)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2010-08-31 21:22:43 UTC (rev 17416)
@@ -24,6 +24,7 @@
parentField : 'parent',
labelAttr : 'name',
childField : 'children',
+ disableQuery : null,
tree : null,
startup : function() {
@@ -44,26 +45,59 @@
this.store = new dojo.data.ItemFileReadStore({data:storeData});
}
this.inherited(arguments);
+
+ if(this.dataList.length > 0 && this.disableQuery)
+ this._setDisabled();
},
+ _setDisabled : function() {
+
+ // tag disabled items
+ this.store.fetch({
+ query : this.disableQuery,
+ onItem : function(item) { item._disabled = 'true'; }
+ });
+
+ // disallow selecting of disabled items
+ var self = this;
+ dojo.connect(this, 'onChange',
+ function(ident) {
+ if(!ident) return;
+ self.store.fetchItemByIdentity({
+ identity : ident,
+ onItem : function(item) {
+ if(item._disabled == 'true')
+ self.attr('value', '');
+ }
+ });
+ }
+ );
+ },
+
// Compile the tree down to a depth-first list of dojo data items
_makeNodeList : function(node, depth) {
if(!depth) depth = 0;
var storeItem = node.toStoreItem();
storeItem._depth = depth++;
this.dataList.push(storeItem);
+
for(var i in node[this.childField]())
this._makeNodeList(node[this.childField]()[i], depth);
},
// For each item, find the depth at display time by searching up the tree.
_getMenuLabelFromItem : function(item) {
+
+ var style = 'padding-left:'+ (item._depth * this.defaultPad) +'px;';
+
+ if(item._disabled == 'true') // TODO: external CSS
+ style += 'background-color:#CCC;cursor:wait';
+
return {
html: true,
- label: '<div style="padding-left:'+ (item._depth * this.defaultPad) +'px;">' +
- this.store.getValue(item, this.labelAttr) + '</div>'
+ label: '<div style="'+style+'">' + this.store.getValue(item, this.labelAttr) + '</div>'
}
- }
+ },
}
);
}
More information about the open-ils-commits
mailing list