From c5a678949021a70feac6f65ee14fbd67cadf8014 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 6 Jul 2011 02:32:01 -0400 Subject: [PATCH] some refactoring in prep for dynamic Record Summary layout Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson --- Open-ILS/xul/staff_client/server/cat/bib_brief.js | 130 +++++++++++++-------- .../staff_client/server/cat/bib_brief_overlay.xul | 4 +- .../staff_client/server/cat/bib_brief_vertical.xul | 2 +- 3 files changed, 87 insertions(+), 49 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief.js b/Open-ILS/xul/staff_client/server/cat/bib_brief.js index 44bc145409..930e68c7c0 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief.js +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief.js @@ -1,21 +1,24 @@ var docid; -function my_init() { +function my_init(orientation) { try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - if (typeof JSAN == 'undefined') { throw( document.getElementById("commonStrings").getString('common.jsan.missing') ); } - JSAN.errorLevel = "die"; // none, warn, or die - JSAN.addRepository('/xul/server/'); - JSAN.use('util.error'); g.error = new util.error(); - g.error.sdump('D_TRACE','my_init() for cat_bib_brief.xul'); - JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); + ui_init(); // JSAN, etc. + + JSAN.use('OpenILS.data'); + g.data = new OpenILS.data(); + g.data.stash_retrieve(); docid = xul_param('docid'); + // hackery if modal and invoked with util.window var key = location.pathname + location.search + location.hash; - if (!docid && typeof g.data.modal_xulG_stack != 'undefined' && typeof g.data.modal_xulG_stack[key] != 'undefined') { - var xulG = g.data.modal_xulG_stack[key][ g.data.modal_xulG_stack[key].length - 1 ]; + if (!docid + && typeof g.data.modal_xulG_stack != 'undefined' + && typeof g.data.modal_xulG_stack[key] != 'undefined' + ) { + var xulG = g.data.modal_xulG_stack[key][ + g.data.modal_xulG_stack[key].length - 1 ]; if (typeof xulG == 'object') { docid = xulG.docid; } @@ -24,7 +27,12 @@ function my_init() { JSAN.use('util.network'); g.network = new util.network(); JSAN.use('util.date'); - document.getElementById('caption').setAttribute('tooltiptext',document.getElementById('catStrings').getFormattedString('staff.cat.bib_brief.record_id', [docid])); + document.getElementById('caption').setAttribute( + 'tooltiptext', + document.getElementById('catStrings').getFormattedString( + 'staff.cat.bib_brief.record_id', [docid] + ) + ); if (docid > -1) { @@ -34,48 +42,36 @@ function my_init() { 'MODS_SLIM_RECORD_RETRIEVE.authoritative', [ docid ], function (req) { - var mods = req.getResultObject(); - - if (window.xulG && typeof window.xulG.set_tab_name == 'function') { - try { - window.xulG.set_tab_name(mods.tcn()); - } catch(E) { - g.error.sdump('D_ERROR','bib_brief.xul, set_tab: ' + E); - } - } - - g.network.simple_request( - 'FM_BRE_RETRIEVE_VIA_ID.authoritative', - [ ses(), [ docid ] ], - function (req) { - try { - var meta = req.getResultObject(); - if (typeof meta.ilsevent != 'undefined') throw(meta); - meta = meta[0]; - var t = document.getElementById('caption').getAttribute('label'); - if (get_bool( meta.deleted() )) { - t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.deleted') + ' '; - document.getElementById('caption').setAttribute('style','background: red; color: white;'); + try { + g.mods = req.getResultObject(); + set_tab_name(); + g.network.simple_request( + 'FM_BRE_RETRIEVE_VIA_ID.authoritative', + [ ses(), [ docid ] ], + function (req2) { + try { + g.meta = req2.getResultObject()[0]; + set_caption(); + bib_brief_overlay({ + 'mvr' : g.mods, + 'bre' : g.meta + }); + } catch(E) { + alert('Error in bib_brief.js, ' + + 'req handler 2: ' + E + '\n'); } - if ( ! get_bool( meta.active() ) ) { - t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.inactive') + ' '; - document.getElementById('caption').setAttribute('style','background: red; color: white;'); - } - document.getElementById('caption').setAttribute('label',t); - - bib_brief_overlay( { 'mvr' : mods, 'bre' : meta } ); - - } catch(E) { - g.error.standard_unexpected_error_alert('meta retrieve',E); } - } - ); + ); + } catch(E) { + alert('Error in bib_brief.js, req handler 1: ' + + E + '\n'); + } } ); } else { var t = document.getElementById('caption').getAttribute('label'); - t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.noncat') + ' '; + t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.noncat') + ' '; document.getElementById('caption').setAttribute('style','background: red; color: white;'); document.getElementById('caption').setAttribute('label',t); } @@ -87,6 +83,32 @@ function my_init() { } } +function set_tab_name() { + try { + window.xulG.set_tab_name(g.mods.tcn()); + } catch(E) { + dump('Error in bib_brief.js, set_tab_name(): ' + E + '\n'); + } +} + +function set_caption() { + try { + var t = document.getElementById('caption').getAttribute('label'); + if (get_bool( g.meta.deleted() )) { + t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.deleted') + ' '; + document.getElementById('caption').setAttribute('style','background: red; color: white;'); + } + if ( ! get_bool( g.meta.active() ) ) { + t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.inactive') + ' '; + document.getElementById('caption').setAttribute('style','background: red; color: white;'); + } + document.getElementById('caption').setAttribute('label',t); + + } catch(E) { + dump('Error in bib_brief.js, set_caption(): ' + E + '\n'); + } +} + function unhide_add_volumes_button() { if (xulG && typeof xulG == 'object' && typeof xulG['new_tab'] == 'function') { document.getElementById('add_volumes').hidden = false; @@ -164,3 +186,19 @@ function add_volumes() { alert('Error in server/cat/bib_brief.js, add_volumes(): ' + E); } } + +function ui_init() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (typeof JSAN == 'undefined') { + throw( + document.getElementById("commonStrings").getString( + 'common.jsan.missing' + ) + ); + } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); g.error = new util.error(); + g.error.sdump('D_TRACE','my_init() for cat_bib_brief.xul'); +} + diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.xul b/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.xul index 7d89b691ca..f2a193902c 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.xul +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.xul @@ -8,7 +8,7 @@