[open-ils-commits] r15701 - trunk/Open-ILS/web/conify/global/config (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 4 15:12:04 EST 2010


Author: miker
Date: 2010-03-04 15:11:59 -0500 (Thu, 04 Mar 2010)
New Revision: 15701

Modified:
   trunk/Open-ILS/web/conify/global/config/marc_code_maps.js
Log:
MORE: convert from permacrud to pcrud -- not as big as it looks -- and move some startup logic to the top (even though yslow will hate me)

Modified: trunk/Open-ILS/web/conify/global/config/marc_code_maps.js
===================================================================
--- trunk/Open-ILS/web/conify/global/config/marc_code_maps.js	2010-03-04 20:07:40 UTC (rev 15700)
+++ trunk/Open-ILS/web/conify/global/config/marc_code_maps.js	2010-03-04 20:11:59 UTC (rev 15701)
@@ -18,6 +18,7 @@
 dojo.require('fieldmapper.AutoIDL');
 dojo.require('fieldmapper.dojoData');
 dojo.require('openils.widget.TranslatorPopup');
+dojo.require('openils.PermaCrud');
 dojo.require('dojo.cookie');
 dojo.require('dojo.parser');
 dojo.require('dojo.string');
@@ -40,7 +41,7 @@
 // some handy globals
 var cgi = new CGI();
 var ses = dojo.cookie('ses') || cgi.param('ses');
-var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
+var pCRUD = new openils.PermaCrudopenils.PermaCrud({authtoken:ses});
 
 console.log('initialized pcrud session');
 
@@ -77,26 +78,16 @@
 	if(classname == 'cam' || classname == 'clfm')
 		obj.description( dojo.string.trim( obj.description() ) );
 
-	pCRUD.request({
-		method : 'open-ils.permacrud.update.' + classname,
-		timeout : 10,
-		params : [ ses, modified_ppl ],
+	pCRUD.update(obj, {
 		onerror : function (r) {
 			//highlighter.red.play();
 			status_update( dojo.string.substitute(cam_strings.ERROR_SAVING_DATA_CAM, [classname, obj.code()]) );
 		},
 		oncomplete : function (r) {
-			var res = r.recv();
-			if ( res && res.content() ) {
-				stores[classname].setValue( current_item, 'ischanged', 0 );
-				//highlighter.green.play();
-				status_update( dojo.string.substitute(cam_strings.SUCCESS_SAVE, stores[classname].getValue( item, 'code' )) );
-			} else {
-				//highlighter.red.play();
-				status_update( dojo.string.substitute( cam_strings.ERROR_SAVING_DATA_CAM, [classname, stores[classname].getValue( item, 'code' )] ) );
-			}
-		},
-	}).send();
+			stores[classname].setValue( current_item, 'ischanged', 0 );
+			status_update( dojo.string.substitute(cam_strings.SUCCESS_SAVE, stores[classname].getValue( item, 'code' )) );
+		}
+	});
 }
 
 function save_them_all (event) {
@@ -153,33 +144,21 @@
             var obj = new fieldmapper[classname]().fromStoreItem( item );
             obj.isdeleted( 1 );
             
-            pCRUD.request({
-                method : 'open-ils.permacrud.delete.' + classname,
-                timeout : 10,
-                params : [ ses, obj ],
+            pCRUD.eliminate(obj, {
                 onerror : function (r) {
                     //highlighter.red.play();
                     status_update( dojo.string.substitute( cam_strings.ERROR_DELETING, [grid.model.store.getValue( item, 'value' )] ) );
                 },
                 oncomplete : function (r) {
-                    var res = r.recv();
-                    var old_name = grid.model.store.getValue( item, 'value' );
-                    if ( res && res.content() ) {
-
-                        grid.model.store.fetch({
-                            query : { code : grid.model.store.getValue( item, 'code' ) },
-                            onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
-                            scope : grid.model.store
-                        });
+                    grid.model.store.fetch({
+                        query : { code : grid.model.store.getValue( item, 'code' ) },
+                        onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+                        scope : grid.model.store
+                    });
             
-                        //highlighter.green.play();
-                        status_update( dojo.string.substitute( cam_strings.STATUS_DELETED, [old_name] ) );
-                    } else {
-                        //highlighter.red.play();
-                        status_update( dojo.string.substitute( cam_strings.ERROR_DELETING, [old_name] ) );
-                    }
+                    status_update( dojo.string.substitute( cam_strings.STATUS_DELETED, [old_name] ) );
                 }
-            }).send();
+            });
         
         }
     }
@@ -202,29 +181,19 @@
     new_fm_obj.isnew(1);
 
     var err = false;
-    pCRUD.request({
-        method : 'open-ils.permacrud.create.' + cl,
-        timeout : 10,
-        params : [ ses, new_fm_obj ],
+    pCRUD.create(new_fm_obj, {
         onerror : function (r) {
             //highlighter.red.play();
             status_update( dojo.string.substitute( cam_strings.ERROR_CALLING_METHOD_CAM, [cl] ) );
             err = true;
         },
-        oncomplete : function (r) {
-            var res = r.recv();
-            if ( res && res.content() ) {
-                var new_item_hash = res.content().toHash();
-                stores[cl].newItem( new_item_hash );
-                status_update( dojo.string.substitute( cam_strings.SUCCESS_CREATING_CODE, [new_item_hash.code, cl] ) );
-                //highlighter.green.play();
-            } else {
-                //highlighter.red.play();
-                status_update( cam_strings.ERROR_CREATING_PERMISSION );
-                err = true;
-            }
+        oncomplete : function (r, list) {
+            var new_item_hash = list[0].toHash();
+            stores[cl].newItem( new_item_hash );
+            status_update( dojo.string.substitute( cam_strings.SUCCESS_CREATING_CODE, [new_item_hash.code, cl] ) );
+            //highlighter.green.play();
         }
-    }).send();
+    });
 
 	return false;
 }



More information about the open-ils-commits mailing list