[open-ils-commits] r13050 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon May 4 12:26:08 EDT 2009
Author: erickson
Date: 2009-05-04 12:26:06 -0400 (Mon, 04 May 2009)
New Revision: 13050
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
Log:
added special handler for copy location fetching to fetch locations owned at workstation ancestors + descendents, instead of entire tree
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-05-04 14:17:11 UTC (rev 13049)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-05-04 16:26:06 UTC (rev 13050)
@@ -42,6 +42,11 @@
if(!this.idlField)
throw new Error("AutoFieldWidget could not determine which field to render. We need more information.");
+
+ this.auth = openils.User.authtoken;
+ if(!this.cache[this.auth]) {
+ this.cache[this.auth] = {};
+ }
},
/**
@@ -193,15 +198,18 @@
return;
}
- // first try the object list cache
- if(this.cache[lclass]) {
- for(var k in this.cache[lclass]) {
- var cc = this.cache[lclass][k];
- if(cc[linkInfo.vfield.name]() == this.widgetValue) {
- this.widgetValue = cc[linkInfo.vfield.selector]();
- return;
+ // first try the store cache
+ var self = this;
+ if(this.cache[this.auth][lclass]) {
+ var store = this.cache[this.auth][lclass];
+ var query = {};
+ query[linkInfo.vfield.name] = this.widgetValue;
+ store.fetch({query:query, onComplete:
+ function(list) {
+ self.widgetValue = store.getValue(list[0], linkInfo.vfield.selector);
}
- }
+ });
+ return;
}
// then try the single object cache
@@ -266,7 +274,10 @@
return this._buildPermGrpSelector();
if(linkClass == 'aou')
return this._buildOrgSelector();
+ if(linkClass == 'acpl')
+ return this._buildCopyLocSelector();
+
dojo.require('openils.PermaCrud');
dojo.require('dojo.data.ItemFileReadStore');
dojo.require('dijit.form.FilteringSelect');
@@ -280,14 +291,16 @@
if(list) {
self.widget.store =
new dojo.data.ItemFileReadStore({data:fieldmapper[linkClass].toStoreData(list)});
- self.cache[linkClass] = list;
+ self.cache[self.auth][linkClass] = self.widget.store;
+ } else {
+ self.widget.store = self.cache[self.auth][linkClass];
}
self.widget.startup();
self._widgetLoaded();
};
- if(this.cache[linkClass]) {
- oncomplete(this.cache[linkClass]);
+ if(this.cache[self.auth][linkClass]) {
+ oncomplete();
} else {
new openils.PermaCrud().retrieveAll(linkClass, {
@@ -357,7 +370,7 @@
if(this.cache.permGrpTree) {
this.widget.tree = this.cache.permGrpTree;
this.widget.startup();
- return;
+ return true;
}
var self = this;
@@ -385,6 +398,41 @@
});
return true;
+ },
+
+ _buildCopyLocSelector : function() {
+ dojo.require('dijit.form.FilteringSelect');
+ this.widget = new dijit.form.FilteringSelect(this.dijitArgs, this.parentNode);
+ this.widget.searchAttr = this.widget.labalAttr = 'name';
+ this.widget.valueAttr = 'id';
+
+ if(this.cache.copyLocStore) {
+ this.widget.store = this.cache.copyLocStore;
+ this.widget.startup();
+ this.async = false;
+ return true;
+ }
+
+ // my orgs
+ var ws_ou = openils.User.user.ws_ou();
+ var orgs = fieldmapper.aou.findOrgUnit(ws_ou).orgNodeTrail().map(function (i) { return i.id() });
+ orgs = orgs.concat(fieldmapper.aou.descendantNodeList(ws_ou).map(function (i) { return i.id() }));
+
+ var self = this;
+ new openils.PermaCrud().search('acpl', {owning_lib : orgs}, {
+ async : !this.forceSync,
+ oncomplete : function(r) {
+ var list = openils.Util.readResponse(r, false, true);
+ if(!list) return;
+ self.widget.store =
+ new dojo.data.ItemFileReadStore({data:fieldmapper.acpl.toStoreData(list)});
+ self.cache.copyLocStore = self.widget.store;
+ self.widget.startup();
+ self._widgetLoaded();
+ }
+ });
+
+ return true;
}
});
}
More information about the open-ils-commits
mailing list