From fce93f7218c4cd7cea99e776c0e28cb3ecbf052c Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 9 Apr 2008 02:25:45 +0000 Subject: [PATCH] dojo-ized opensrf js git-svn-id: svn://svn.open-ils.org/ILS/branches/dojo-admin@9278 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/conify/global/actor/org_unit.html | 2 - .../web/conify/global/actor/org_unit_type.html | 2 - Open-ILS/web/conify/global/config/copy_status.html | 2 - .../web/conify/global/permission/grp_tree.html | 2 - .../web/conify/global/permission/perm_list.html | 2 - Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js | 44 ++++++++++++---------- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index cc58248875..28addd7b9c 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -32,8 +32,6 @@ - - diff --git a/Open-ILS/web/conify/global/actor/org_unit_type.html b/Open-ILS/web/conify/global/actor/org_unit_type.html index e3574ba373..2697c54801 100644 --- a/Open-ILS/web/conify/global/actor/org_unit_type.html +++ b/Open-ILS/web/conify/global/actor/org_unit_type.html @@ -32,8 +32,6 @@ - - diff --git a/Open-ILS/web/conify/global/config/copy_status.html b/Open-ILS/web/conify/global/config/copy_status.html index 7e0e79a78e..2e568aa4eb 100644 --- a/Open-ILS/web/conify/global/config/copy_status.html +++ b/Open-ILS/web/conify/global/config/copy_status.html @@ -35,8 +35,6 @@ - - diff --git a/Open-ILS/web/conify/global/permission/grp_tree.html b/Open-ILS/web/conify/global/permission/grp_tree.html index 6edf5a62a8..59fc8d5869 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.html +++ b/Open-ILS/web/conify/global/permission/grp_tree.html @@ -45,8 +45,6 @@ - - diff --git a/Open-ILS/web/conify/global/permission/perm_list.html b/Open-ILS/web/conify/global/permission/perm_list.html index 077c2653e0..e24eba89f0 100644 --- a/Open-ILS/web/conify/global/permission/perm_list.html +++ b/Open-ILS/web/conify/global/permission/perm_list.html @@ -35,8 +35,6 @@ - - diff --git a/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js b/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js index b218b2dbf2..57238233dd 100644 --- a/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js +++ b/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js @@ -1,4 +1,5 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ + /* generate fieldmapper javascript classes. This expects a global variable called 'fmclasses' to be fleshed with the classes we need to build */ @@ -8,7 +9,7 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ dojo._hasResource["fieldmapper.Fieldmapper"] = true; dojo.provide("fieldmapper.Fieldmapper"); - //dojo.require("opensrf.OpenSRF"); + dojo.require("OpenSRF"); dojo.declare( "fieldmapper.Fieldmapper", null, { @@ -56,19 +57,15 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ isnew : function(n) { if(arguments.length == 1) this.a[0] =n; return this.a[0]; }, ischanged : function(n) { if(arguments.length == 1) this.a[1] =n; return this.a[1]; }, - isdeleted : function(n) { if(arguments.length == 1) this.a[2] =n; return this.a[2]; } + isdeleted : function(n) { if(arguments.length == 1) this.a[2] =n; return this.a[2]; }, _request : function ( meth, staff, params ) { - var ses = fieldmapper.OpenSRF.session_cache[meth[0]]; - if (!ses) { - ses = fieldmapper.OpenSRF.session_cache[meth[0]] = new OpenSRF.ClientSession( meth[0] ); - } - + var ses = OpenSRF.CachedClientSession( meth[0] ); if (!ses) return null; var result = null; - var args = {}; + if (dojo.isObject(params)) { args = params; } else { @@ -80,11 +77,19 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ } args.timeout = 10; - args.error = function (r) { throw 'Error encountered! ' + r }; + } + + if (!args.onerror) { + args.error = function (r) { + throw 'Error encountered! ' + r; + } + } + + if (!args.oncomplete) { args.oncomplete = function (r) { var x = r.recv(); if (x) result = x.content(); - }; + } } args.method = meth[1]; @@ -101,8 +106,8 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ }); for( var cl in fmclasses ) { - dojo.provide( 'fieldmapper.' + cl ); - dojo.declare( 'fieldmapper.' + cl , fieldmapper.Fieldmapper, { + dojo.provide( cl ); + dojo.declare( cl , fieldmapper.Fieldmapper, { constructor : function () { if (!this.a) this.a = []; this.classname = this.declaredClass; @@ -114,18 +119,17 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){ } } }); - window[cl] = fieldmapper[cl]; // alias into place + fieldmapper[cl] = window[cl]; // alias into place } - fieldmapper.OpenSRF.session_cache = {}; + fieldmapper.OpenSRF = {}; + + /* Methods are defined as [ service, method, have_staff ] + An optional 3rd component is when a method is followed by true, such methods + have a staff counterpart and should have ".staff" appended to the method + before the method is called when in XUL mode */ fieldmapper.OpenSRF.methods = { - /* ---------------------------------------------------------------------------- */ - /* Methods are defined as [ service, method, have_staff ] - An optional 3rd component is when a method is followed by true, such methods - have a staff counterpart and should have ".staff" appended to the method - before the method is called when in XUL mode */ - SEARCH_MRS : ['open-ils.search','open-ils.search.metabib.multiclass',true], SEARCH_RS : ['open-ils.search','open-ils.search.biblio.multiclass',true], SEARCH_MRS_QUERY : ['open-ils.search','open-ils.search.metabib.multiclass.query',true], -- 2.11.0