From 161dab2660c16c1ca3fff387c1166ecde9f84c82 Mon Sep 17 00:00:00 2001 From: pines Date: Sun, 13 May 2007 16:31:25 +0000 Subject: [PATCH] xul_param and modal xulG conversion git-svn-id: svn://svn.open-ils.org/ILS/trunk@7296 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/patron/ue.js | 22 +- .../staff_client/server/patron/ue_config.js | 5 +- .../chrome/content/OpenILS/global_util.js | 104 +++++++++ .../chrome/content/main/simple_auth.xul | 35 ++- .../chrome/content/util/browser.xul | 24 +- .../staff_client/chrome/content/util/error.js | 34 +-- .../chrome/content/util/fancy_prompt.xul | 61 +++-- .../chrome/content/util/network.js | 82 ++++--- .../chrome/content/util/rbrowser.xul | 24 +- .../chrome/content/util/window.js | 33 ++- .../server/admin/hold_pull_list.xul | 10 +- .../server/admin/offline_manage_xacts.js | 31 ++- .../server/admin/offline_manage_xacts.xul | 2 - .../staff_client/server/admin/upload_xacts.js | 14 +- .../server/admin/upload_xacts.xhtml | 1 + .../xul/staff_client/server/cat/bib_brief.xul | 30 ++- .../staff_client/server/cat/copy_browser.js | 49 ++-- .../staff_client/server/cat/copy_browser.xul | 4 +- .../staff_client/server/cat/copy_buckets.js | 16 +- .../staff_client/server/cat/copy_buckets.xul | 18 +- .../server/cat/copy_buckets_quick.xul | 18 +- .../staff_client/server/cat/copy_editor.js | 78 +++---- .../staff_client/server/cat/copy_notes.xul | 31 +-- .../staff_client/server/cat/copy_summary.xul | 13 +- .../xul/staff_client/server/cat/marc_view.xul | 16 +- Open-ILS/xul/staff_client/server/cat/opac.xul | 115 +++++----- .../staff_client/server/cat/record_buckets.js | 26 ++- .../server/cat/record_buckets.xul | 19 +- .../server/cat/record_buckets_quick.xul | 18 +- .../staff_client/server/cat/spine_labels.js | 32 ++- Open-ILS/xul/staff_client/server/cat/util.js | 50 +++-- .../server/cat/volume_copy_creator.js | 47 ++-- .../staff_client/server/cat/volume_editor.xul | 24 +- Open-ILS/xul/staff_client/server/cat/z3950.js | 24 +- .../xul/staff_client/server/cat/z3950.xul | 2 - .../xul/staff_client/server/circ/checkin.xul | 4 +- .../xul/staff_client/server/circ/checkout.xul | 4 +- .../staff_client/server/circ/circ_brief.xul | 16 +- .../staff_client/server/circ/circ_summary.xul | 52 +++-- .../staff_client/server/circ/copy_details.xul | 28 ++- .../staff_client/server/circ/copy_status.js | 63 +++--- .../staff_client/server/circ/copy_status.xul | 19 +- .../staff_client/server/circ/hold_capture.xul | 2 - .../staff_client/server/circ/in_house_use.xul | 2 - .../circ/print_list_template_editor.xul | 2 - Open-ILS/xul/staff_client/server/circ/util.js | 39 ++-- .../xul/staff_client/server/main/data.xul | 210 +++++++++--------- .../server/patron/adv_barcode_entry.xul | 6 +- .../server/patron/barcode_entry.xul | 6 +- .../server/patron/bill_details.xul | 10 +- .../server/patron/bill_history.xul | 45 ++-- .../server/patron/bill_wizard.xul | 10 +- .../xul/staff_client/server/patron/bills.js | 90 ++++---- .../xul/staff_client/server/patron/bills.xul | 4 +- .../xul/staff_client/server/patron/display.js | 167 +++++++------- .../staff_client/server/patron/display.xul | 10 +- .../server/patron/hold_notices.xul | 31 +-- .../xul/staff_client/server/patron/holds.js | 104 ++++----- .../xul/staff_client/server/patron/holds.xul | 10 +- .../xul/staff_client/server/patron/info.xul | 21 +- .../staff_client/server/patron/info_group.xul | 63 +++--- .../staff_client/server/patron/info_notes.xul | 30 +-- .../server/patron/info_stat_cats.xul | 3 +- .../server/patron/info_surveys.xul | 3 +- .../xul/staff_client/server/patron/items.js | 14 +- .../xul/staff_client/server/patron/items.xul | 4 +- .../server/patron/search_result.xul | 5 + .../staff_client/server/patron/summary.xul | 10 +- Open-ILS/xul/staff_client/server/patron/ue.js | 22 +- .../staff_client/server/patron/ue_config.js | 7 +- .../staff_client/server/patron/user_edit.js | 17 +- .../staff_client/server/patron/user_editor.js | 3 +- 72 files changed, 1298 insertions(+), 950 deletions(-) diff --git a/Evergreen/xul/staff_client/server/patron/ue.js b/Evergreen/xul/staff_client/server/patron/ue.js index ddc7f6a1f2..e2cb510491 100644 --- a/Evergreen/xul/staff_client/server/patron/ue.js +++ b/Evergreen/xul/staff_client/server/patron/ue.js @@ -18,8 +18,12 @@ function uEditInit() { _debug('uEditInit(): ' + location.search); cgi = new CGI(); - session = cgi.param('ses'); - clone = cgi.param('clone'); + session = cgi.param('ses'); + if (xulG) if (xulG.ses) session = xulG.ses; + if (xulG) if (xulG.params) if (xulG.params.ses) session = xulG.params.ses; + clone = cgi.param('clone'); + if (xulG) if (xulG.clone) clone = xulG.clone; + if (xulG) if (xulG.params) if (xulG.params.clone) clone = xulG.params.clone; if(!session) throw "User session is not defined"; fetchUser(session); @@ -107,7 +111,10 @@ function uEditBuild() { fetchHighestPermOrgs( SESSION, USER.id(), myPerms ); uEditBuildLibSelector(); - patron = fetchFleshedUser(cgi.param('usr')); + var usr = cgi.param('usr'); + if (xulG) if (xulG.usr) usr = xulG.usr; + if (xulG) if (xulG.params) if (xulG.params.usr) usr = xulG.params.usr; + patron = fetchFleshedUser(usr); if(!patron) patron = uEditNewPatron(); uEditDraw( @@ -554,7 +561,10 @@ function uEditSaveUser(cloneme) { !patron.isnew() ) { _debug("xulG clone spawning new interface..."); - window.xulG.spawn_editor({ses:cgi.param('ses'),clone:cloneme}); + var ses = cgi.param('ses'); + if (xulG) if (xulG.ses) ses = xulG.ses; + if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses; + window.xulG.spawn_editor({ses:ses,clone:cloneme}); uEditRefresh(); } else { @@ -591,7 +601,9 @@ function uEditCancel() { var href = location.href; href = href.replace(/\&?usr=\d+/, ''); href = href.replace(/\&?clone=\d+/, ''); - var id = cgi.param('usr') + var id = cgi.param('usr'); + if (xulG) if (xulG.usr) id = xulG.usr; + if (xulG) if (xulG.params) if (xulG.params.usr) id = xulG.params.usr; /* reload the current user if available */ if( id ) href += "&usr=" + id; location.href = href; diff --git a/Evergreen/xul/staff_client/server/patron/ue_config.js b/Evergreen/xul/staff_client/server/patron/ue_config.js index 6b6449ab5b..6417e4f99e 100644 --- a/Evergreen/xul/staff_client/server/patron/ue_config.js +++ b/Evergreen/xul/staff_client/server/patron/ue_config.js @@ -999,8 +999,11 @@ function uEditCheckSharedAddr(patron, address, tbody, row) { } else { + var ses = cgi.param('ses'); + if (xulG) if (xulG.ses) ses = xulG.ses; + if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses; link.onclick = - function() { window.xulG.spawn_editor({ses:cgi.param('ses'),usr:id}) }; + function() { window.xulG.spawn_editor({ses:ses,usr:id}) }; if( userCache[id] ) { var usr = userCache[id]; diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index ae380521ba..290764daf8 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -29,6 +29,110 @@ } } + function update_modal_xulG(v) { + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + var key = location.pathname + location.search + location.hash; + if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { + data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v; + data.stash('modal_xulG_stack'); + } + } catch(E) { + alert('FIXME: update_modal_xulG => ' + E); + } + } + + function xul_param(param_name,_params) { + /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */ + try { + dump('xul_param('+param_name+','+js2JSON(_params)+')\n'); + var value = undefined; if (!_params) _params = {}; + if (typeof _params.no_cgi == 'undefined') { + var cgi = new CGI(); + if (cgi.param(param_name)) { + var x = cgi.param(param_name); + dump('\tfound via location.href = ' + x + '\n'); + if (typeof _params.JSON2js_if_cgi != 'undefined') { + x = JSON2js( x ); + dump('\tJSON2js = ' + x + '\n'); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + if (typeof _params.no_xulG == 'undefined') { + if (typeof _params.modal_xulG != 'undefined') { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + var key = location.pathname + location.search + location.hash; + dump('xul_param, considering modal key = ' + key + '\n'); + if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { + xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ]; + } + } + if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') { + var x = xulG[ param_name ]; + dump('\tfound via xulG = ' + x + '\n'); + if (typeof _params.JSON2js_if_xulG != 'undefined') { + x = JSON2js( x ); + dump('\tJSON2js = ' + x + '\n'); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + if (typeof _params.no_xpcom == 'undefined') { + /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */ + if (typeof _params.stash_name != 'undefined') { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + if (typeof data[ _params.stash_name ] != 'undefined') { + var x = data[ _params.stash_name ]; + dump('\tfound via xpcom = ' + x + '\n'); + if (typeof _params.JSON2js_if_xpcom != 'undefined') { + x = JSON2js( x ); + dump('\tJSON2js = ' + x + '\n'); + } + if (_params.clear_xpcom) { + data[ _params.stash_name ] = undefined; data.stash( _params.stash_name ); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + } + //alert(param_name + ' value = ' + value); + return value; + } catch(E) { + dump('xul_param error: ' + E + '\n'); + } + } + function get_bool(a) { // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false // So false includes 'f', '', 0, null, and undefined diff --git a/Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul b/Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul index e4890c04d5..5114692d96 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul @@ -46,16 +46,15 @@ $('server').value = g.data.server_unadorned; - g.cgi = new CGI(); - addCSSClass(document.documentElement,g.cgi.param('login_type')) + addCSSClass(document.documentElement,xul_param('login_type',{'modal_xulG':true})) - if (g.cgi.param('desc_brief')) { + if (xul_param('desc_brief',{'modal_xulG':true})) { $('desc').hidden = false; - $('desc_brief').appendChild( document.createTextNode( g.cgi.param('desc_brief') ) ); + $('desc_brief').appendChild( document.createTextNode( xul_param('desc_brief',{'modal_xulG':true}) ) ); } - if (g.cgi.param('desc_full')) { + if (xul_param('desc_full',{'modal_xulG':true})) { $('desc').hidden = false; - $('desc_full').appendChild( document.createTextNode( g.cgi.param('desc_full') ) ); + $('desc_full').appendChild( document.createTextNode( xul_param('desc_full',{'modal_xulG':true}) ) ); } $('username').focus(); @@ -91,14 +90,26 @@ 'password_prompt' : $('password'), 'server_prompt' : $('server'), }, - g.cgi.param('login_type') || 'temp' + xul_param('login_type',{'modal_xulG':true}) || 'temp' ); g.session.on_init = function() { - JSAN.use('util.network'); var n = new util.network(); - var staff = n.simple_request('FM_AU_RETRIEVE_VIA_SESSION',[ g.session.key ]); - g.data.temporary_session = { 'key' : g.session.key, 'authtime' : g.session.authtime, 'usr' : js2JSON(staff) }; - g.data.stash('temporary_session'); - window.close(); + try { + JSAN.use('util.network'); var n = new util.network(); + var staff = n.simple_request('FM_AU_RETRIEVE_VIA_SESSION',[ g.session.key ]); + g.data.temporary_session = { // old way because of local chrome still out there + 'key' : g.session.key, + 'authtime' : g.session.authtime, + 'usr' : js2JSON(staff) + } + g.data.stash('temporary_session'); + var my_xulG = { // new way, to minimize the use of global spaces + 'temporary_session' : g.data.temporary_session + }; + update_modal_xulG(my_xulG); + window.close(); + } catch(E) { + g.error.standard_unexpected_error_alert('simple_auth.session.on_init',E); + } } g.session.on_init_error = function() { $('password').value = ''; diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul index 3f6deff0a8..47ea663cfb 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul @@ -42,23 +42,17 @@ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); XML_HTTP_SERVER = data.server_unadorned; - g.cgi = new CGI(); - var name = g.cgi.param('tab_name') || g.cgi.param('name') || null; - if (!name) { - if (typeof window.xulG == 'object') { - name = window.xulG.name || window.xulG.tab_name || null; - } - } - var url; try { url = g.cgi.param('url') || xulG.url } catch(E) { dump(E + '\n'); }; + var name = xul_param('tab_name') || xul_param('name') || null; + var url; try { url = xul_param('url'); } catch(E) { dump(E + '\n'); }; if (!url) url = urls.browser; JSAN.use('util.browser'); g.browser = new util.browser(); var push_xulG = true; - if (g.cgi.param('no_xulG') || (typeof xulG == 'object' ? xulG.no_xulG : false)) push_xulG = false; + if (xul_param('no_xulG')) push_xulG = false; var alt_print = false; - if (g.cgi.param('alternate_print') || (typeof xulG == 'object' ? xulG.alternate_print : false)) alt_print = true; + if (xul_param('alternate_print')) alt_print = true; var p = { 'url' : url, @@ -78,17 +72,17 @@ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') { if (name) try { window.xulG.set_tab_name(name); } catch(E) { alert(E); } } - if (g.cgi.param('show_nav_buttons')||(typeof window.xulG == 'object' && window.xulG.show_nav_buttons)) { + if (xul_param('show_nav_buttons')) { document.getElementById('back').hidden = false; document.getElementById('forward').hidden = false; } - if (g.cgi.param('show_print_button')||(typeof window.xulG == 'object' && window.xulG.show_print_button)) { + if (xul_param('show_print_button')) { document.getElementById('browser_print').hidden = false; } - if (g.cgi.param('title')) { - try { document.title = g.cgi.param('title'); } catch(E) {} - try { window.title = g.cgi.param('title'); } catch(E) {} + if (xul_param('title')) { + try { document.title = xul_param('title'); } catch(E) {} + try { window.title = xul_param('title'); } catch(E) {} } } catch(E) { diff --git a/Open-ILS/xul/staff_client/chrome/content/util/error.js b/Open-ILS/xul/staff_client/chrome/content/util/error.js index 6820f7abbe..cd5b612c9b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/error.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/error.js @@ -106,7 +106,7 @@ util.error.prototype = { 'D_SPAWN' : false, 'D_STRING' : false, 'D_UTIL' : false, - 'D_WIN' : false, + 'D_WIN' : { 'dump' : true }, 'D_WIDGETS' : false }, @@ -347,16 +347,16 @@ util.error.prototype = { if (b3) xml += '