[open-ils-commits] r15029 - trunk/Open-ILS/web/js/dojo/openils (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Nov 25 15:45:23 EST 2009


Author: miker
Date: 2009-11-25 15:45:18 -0500 (Wed, 25 Nov 2009)
New Revision: 15029

Modified:
   trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
Log:
add object collection for create/update/delete to the last object in the list ... thinko

Modified: trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2009-11-25 20:19:29 UTC (rev 15028)
+++ trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2009-11-25 20:45:18 UTC (rev 15029)
@@ -221,32 +221,40 @@
 
                 if (++pos == obj_list.length) {
                     req.oncomplete = function (r) {
+                        var res = r.recv();
 
-                        _pcrud.session.request({
-                            method : 'open-ils.pcrud.transaction.commit',
-                            timeout : 10,
-                            params : [ _pcrud.auth() ],
-                            onerror : function (r) {
-                                _pcrud.disconnect();
-                                throw 'Transaction commit error';
-                            },      
-                            oncomplete : function (r) {
-                                var res = r.recv();
-                                if ( res && res.content() ) {
-                                    if(req._final_complete)
-                                        req._final_complete(req);
+                        if ( res && res.content() ) {
+                            _return_list.push( res.content() );
+                            _pcrud.session.request({
+                                method : 'open-ils.pcrud.transaction.commit',
+                                timeout : 10,
+                                params : [ _pcrud.auth() ],
+                                onerror : function (r) {
                                     _pcrud.disconnect();
-                                } else {
-                                    _pcrud.disconnect();
                                     throw 'Transaction commit error';
-                                }
-                            },
-                        }).send();
+                                },      
+                                oncomplete : function (r) {
+                                    var res = r.recv();
+                                    if ( res && res.content() ) {
+                                        if(req._final_complete)
+                                            req._final_complete(req);
+                                        _pcrud.disconnect();
+                                    } else {
+                                        _pcrud.disconnect();
+                                        throw 'Transaction commit error';
+                                    }
+                                },
+                            }).send();
+                        } 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);
                     };
 
                 } else {



More information about the open-ils-commits mailing list