[open-ils-commits] r17461 - in branches/rel_2_0/Open-ILS/web/js: dojo/openils/widget ui/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Sep 2 17:13:04 EDT 2010
Author: erickson
Date: 2010-09-02 17:12:58 -0400 (Thu, 02 Sep 2010)
New Revision: 17461
Modified:
branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
back-porting: 17416 17417 17418 => filtering-tree-select disable fields query w/ auto-widget pass-thru; disable non-user-group fields in patron editor
Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2010-09-02 21:11:26 UTC (rev 17460)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2010-09-02 21:12:58 UTC (rev 17461)
@@ -44,6 +44,8 @@
* dataLoader : Bypass the default PermaCrud linked data fetcher and use this function instead.
* Function arguments are (link class name, search filter, callback)
* The fetched objects should be passed to the callback as an array
+ * disableQuery : dojo.data query passed to FilteringTreeSelect-based widgets to disable
+ * (but leave visible) certain options.
*/
constructor : function(args) {
for(var k in args)
@@ -560,6 +562,7 @@
_buildPermGrpSelector : function() {
dojo.require('openils.widget.FilteringTreeSelect');
this.widget = new openils.widget.FilteringTreeSelect(this.dijitArgs, this.parentNode);
+ this.widget.disableQuery = this.disableQuery;
this.widget.searchAttr = 'name';
if(this.cache.permGrpTree) {
Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2010-09-02 21:11:26 UTC (rev 17460)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FilteringTreeSelect.js 2010-09-02 21:12:58 UTC (rev 17461)
@@ -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>'
}
- }
+ },
}
);
}
Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js 2010-09-02 21:11:26 UTC (rev 17460)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/actor/user/register.js 2010-09-02 21:12:58 UTC (rev 17461)
@@ -549,12 +549,7 @@
if(value !== null)
dijitArgs.value = value;
- // fetch profile groups non-async so existing expire_date is
- // not overwritten when the profile groups arrive and update
- var sync = (fmfield == 'profile') ? true : false;
-
- var widget = new openils.widget.AutoFieldWidget({
- forceSync : sync,
+ var wargs = {
idlField : fieldIdl,
fmObject : fmObject,
fmClass : fmcls,
@@ -563,8 +558,18 @@
dijitArgs : dijitArgs,
orgDefaultsToWs : true,
orgLimitPerms : ['UPDATE_USER'],
- });
+ };
+ if(fmfield == 'profile') {
+ // fetch profile groups non-async so existing expire_date is
+ // not overwritten when the profile groups arrive and update
+ wargs.forceSync = true;
+ wargs.disableQuery = {usergroup : 'f'};
+ } else {
+ wargs.forceSync = false;
+ }
+
+ var widget = new openils.widget.AutoFieldWidget(wargs);
widget.build();
// now put it back before we register the widget
More information about the open-ils-commits
mailing list