From: miker Date: Thu, 4 Mar 2010 20:05:51 +0000 (+0000) Subject: MORE: convert from permacrud to pcrud -- not as big as it looks -- and move some... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c965d146d85fbc7729b8991775e242204cdc42b2;p=evergreen%2Ftadl.git 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) git-svn-id: svn://svn.open-ils.org/ILS/trunk@15699 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 1df6d02d64..dfc79c703a 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -63,69 +63,61 @@ - + - if (dirtyStore.length > 0) { - var confirmation = confirm( - ccs_strings.CONFIRM_EXIT_CCS - ); + - if (confirmation) { - for (var i in window.dirtyStore) { - window.current_status = window.dirtyStore[i]; - save_status(true); - } - } - } + - }); - } - }).send(); -]]> - +
&conify.copy_status.new_status.label; @@ -142,30 +134,20 @@ }); var err = false; - pCRUD.request({ - method : 'open-ils.permacrud.create.ccs', - timeout : 10, - params : [ ses, new_fm_obj ], + pCRUD.create(new_fm_obj, { onerror : function (r) { highlighter.red.play(); status_update( ccs_strings.ERROR_CALLING_METHOD_CCS ); err = true; }, - oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { - var new_item_hash = res.content().toHash(); - status_store.newItem( new_item_hash ); - status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) ); - status_grid.model.sort(-2); - highlighter.green.play(); - } else { - highlighter.red.play(); - status_update( ccs_strings.ERROR_CREATING_STATUS ); - err = true; - } + oncomplete : function (r, list) { + var new_item_hash = list[0].toHash(); + status_store.newItem( new_item_hash ); + status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) ); + status_grid.model.sort(-2); + highlighter.green.play(); } - }).send(); + }); ]]> @@ -272,36 +254,26 @@ var modified_ccs = new ccs().fromStoreItem( current_status ); modified_ccs.isdeleted( 1 ); - pCRUD.request({ - method : 'open-ils.permacrud.delete.ccs', - timeout : 10, - params : [ ses, modified_ccs ], + pCRUD.eliminate(modified_ccs, { onerror : function (r) { highlighter.red.play(); status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) ); }, oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { - - var old_name = status_store.getValue( current_status, 'name' ); + var old_name = status_store.getValue( current_status, 'name' ); - status_store.fetch({ - query : { id : status_store.getValue( current_status, 'id' ) }, - onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, - scope : status_store - }); + status_store.fetch({ + query : { id : status_store.getValue( current_status, 'id' ) }, + onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, + scope : status_store + }); - current_status = null; + current_status = null; - highlighter.green.play(); - status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) ); - } else { - highlighter.red.play(); - status_update( dojo.string.substitute(ccs_strings.ERROR_DELETING, [old_name]) ); - } + highlighter.green.play(); + status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) ); } - }).send(); + }); } } diff --git a/Open-ILS/web/conify/global/config/copy_status.js b/Open-ILS/web/conify/global/config/copy_status.js index 4b50a96ca9..a934f1a670 100644 --- a/Open-ILS/web/conify/global/config/copy_status.js +++ b/Open-ILS/web/conify/global/config/copy_status.js @@ -18,6 +18,7 @@ dojo.require('fieldmapper.AutoIDL'); dojo.require('fieldmapper.dojoData'); dojo.require('openils.widget.TranslatorPopup'); +dojo.require('openils.PermaCrud'); dojo.require('dojo.parser'); dojo.require('dojo.string'); dojo.require('dojo.data.ItemFileWriteStore'); @@ -36,7 +37,7 @@ dojo.requireLocalization("openils.conify", "conify"); var cgi = new CGI(); var cookieManager = new HTTP.Cookies(); var ses = cookieManager.read('ses') || cgi.param('ses'); -var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud'); +var pCRUD = new openils.PermaCrud({authtoken:ses}); var current_status; var virgin_out_id = -1; @@ -54,26 +55,17 @@ function save_status () { var modified_ccs = new ccs().fromStoreItem( current_status ); modified_ccs.ischanged( 1 ); - pCRUD.request({ - method : 'open-ils.permacrud.update.ccs', - timeout : 10, - params : [ ses, modified_ccs ], + pCRUD.update(modified_ccs, { onerror : function (r) { highlighter.red.play(); status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) ); }, oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { - status_store.setValue( current_status, 'ischanged', 0 ); - highlighter.green.play(); - status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) ); - } else { - highlighter.red.play(); - status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) ); - } - }, - }).send(); + status_store.setValue( current_status, 'ischanged', 0 ); + highlighter.green.play(); + status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) ); + } + }); } function save_them_all (event) {