[open-ils-commits] r15028 - trunk/Open-ILS/web/js/dojo/openils (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 25 15:19:34 EST 2009
Author: miker
Date: 2009-11-25 15:19:29 -0500 (Wed, 25 Nov 2009)
New Revision: 15028
Modified:
trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
Log:
teach open-ils.PermaCrud to return objects created by .create, updated by .update, and the list of ids deleted by .delete/.eliminate
Modified: trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js 2009-11-25 18:49:34 UTC (rev 15027)
+++ trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js 2009-11-25 20:19:29 UTC (rev 15028)
@@ -205,6 +205,7 @@
if (!this.connected) this.connect();
var _pcrud = this;
+ var _return_list = [];
function _CUD_recursive ( obj_list, pos, final_complete, final_error ) {
var obj = obj_list[pos];
@@ -254,12 +255,18 @@
req.oncomplete = function (r) {
var res = r.recv();
if ( res && res.content() ) {
+ _return_list.push( res.content() );
_CUD_recursive( r._obj_list, r._pos, r._final_complete );
} else {
_pcrud.disconnect();
throw '_CUD: Error creating, deleting or updating ' + js2JSON(obj);
}
};
+ req.onerror = function (r) {
+ if (r._final_error) r._final_error(r);
+ _pcrud.disconnect();
+ throw '_CUD: Error creating, deleting or updating ' + js2JSON(obj);
+ };
}
req.send();
@@ -286,18 +293,30 @@
}
},
}).send();
+
+ return _return_list;
+
},
create : function ( list, opts ) {
- this._CUD( 'create', list, opts );
+ return this._CUD( 'create', list, opts );
},
update : function ( list, opts ) {
- this._CUD( 'update', list, opts );
+ var id_list = this._CUD( 'update', list, opts );
+ var obj_list = [];
+
+ for (var idx = 0; idx < id_list.length; idx++) {
+ obj_list.push(
+ this.retrieve( list[idx].classname, id_list[idx] )
+ );
+ }
+
+ return obj_list;
},
delete : function ( list, opts ) {
- this._CUD( 'delete', list, opts );
+ return this._CUD( 'delete', list, opts );
},
/*
@@ -305,7 +324,7 @@
* in browsers like IE or Chrome, so we define a safe synonym
*/
eliminate: function ( list, opts ) {
- this._CUD( 'delete', list, opts );
+ return this._CUD( 'delete', list, opts );
},
apply : function ( list, opts ) {
More information about the open-ils-commits
mailing list