[open-ils-commits] r15707 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Mar 5 10:20:36 EST 2010
Author: erickson
Date: 2010-03-05 10:20:34 -0500 (Fri, 05 Mar 2010)
New Revision: 15707
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
Log:
added ability to use an external function (bypassing pcrud) for retrieving linked data lists
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2010-03-05 15:06:16 UTC (rev 15706)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2010-03-05 15:20:34 UTC (rev 15707)
@@ -36,6 +36,9 @@
* represented as field names on the remote linked object.
* E.g.
* labelFormat : [ '${0} (${1})', 'obj_field_1', 'obj_field_2' ]
+ * 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
*/
constructor : function(args) {
for(var k in args)
@@ -427,17 +430,27 @@
oncomplete();
} else {
- var _cb = function(r) {
- oncomplete(openils.Util.readResponse(r, false, true));
- };
- if (this.searchFilter) {
- new openils.PermaCrud().search(linkClass, this.searchFilter, {
- async : !this.forceSync, oncomplete : _cb
- });
+
+ if(this.dataLoader) {
+
+ // caller provided an external function for retrieving the data
+ this.dataLoader(linkClass, this.searchFilter, oncomplete);
+
} else {
- new openils.PermaCrud().retrieveAll(linkClass, {
- async : !this.forceSync, oncomplete : _cb
- });
+
+ var _cb = function(r) {
+ oncomplete(openils.Util.readResponse(r, false, true));
+ };
+
+ if (this.searchFilter) {
+ new openils.PermaCrud().search(linkClass, this.searchFilter, {
+ async : !this.forceSync, oncomplete : _cb
+ });
+ } else {
+ new openils.PermaCrud().retrieveAll(linkClass, {
+ async : !this.forceSync, oncomplete : _cb
+ });
+ }
}
}
More information about the open-ils-commits
mailing list