pcrud.apply repairs.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Aug 2010 03:52:51 +0000 (03:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Aug 2010 03:52:51 +0000 (03:52 +0000)
Skip objects that require no action instead of throwing an exception
In last oncomplete handler, call final-complete as necessary and disconnect instead of starting over at object list position 0; no longer any need for final-complete/disconnect outside of closing request handler

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17397 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/PermaCrud.js

index 6213c8f..834c6cd 100644 (file)
@@ -366,7 +366,9 @@ if(!dojo._hasResource["openils.PermaCrud"]) {
                 if (obj.ischanged()) method = 'update';
                 if (obj.isnew())     method = 'create';
                 if (obj.isdeleted()) method = 'delete';
-                if (!method) throw 'No action detected';
+                if (!method) {
+                    return _auto_CUD_recursive(obj_list, pos+1, final_complete, final_error);
+                }
 
                 var req_hash = {
                     method : 'open-ils.pcrud.' + method + '.' + obj.classname,
@@ -393,16 +395,15 @@ if(!dojo._hasResource["openils.PermaCrud"]) {
                             oncomplete : function (r) {
                                 var res = r.recv();
                                 if ( res && res.content() ) {
-                                    _auto_CUD_recursive( list, 0 );
+                                    if (r._final_complete) 
+                                        req._final_complete(req, _return_list);
+                                    _pcrud.disconnect();
                                 } else {
                                     _pcrud.disconnect();
                                     throw 'Transaction commit error';
                                 }
                             },
                         }).send();
-
-                        if (r._final_complete) r._final_complete(r);
-                        _pcrud.disconnect();
                     };
 
                     req.onerror = function (r) {