From 0687d223cc3d77b9c29168cfb5c3caacc8786651 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 7 Oct 2009 15:56:12 +0000 Subject: [PATCH] Toward a new look for XUL Record Summary. bib_brief.xul modified for existing instances of Record Summary, but the alternate Item Details interface is doing it differently. The old Record Summary is a dedicated XUL file that typically lives in an iframe. It would fetch its own data if fed some ID's either via xulG or URL parameters. The new way (which is really an old way that was tried before and is used with bill summaries) involves a XUL overlay, and a render function matching the overlay name. A caller can feed it already fetched objects or have it fetch its own objects given ID's. To do this, Include these in your XUL file: This pulls in the overlay, which merges with the in your XUL and loads bib_brief_overlay.js. In your javascript, call bib_brief_overlay(): bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } ); Different options include mvr, mvr_id, bre, bre_id, and acp. This will render values into the grid. Since this is an overlay, you can mix-in your own elements. The new Item Details is doing this: This is adding a custom/local row to the bottom of the Record Summary grid. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14292 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 28 +-- Open-ILS/xul/staff_client/server/cat/bib_brief.js | 117 ++++++++++++ Open-ILS/xul/staff_client/server/cat/bib_brief.xul | 212 +-------------------- .../staff_client/server/cat/bib_brief_overlay.js | 90 +++++++++ .../staff_client/server/cat/bib_brief_overlay.xul | 44 +++++ .../server/circ/alternate_copy_summary.js | 36 ++-- .../server/circ/alternate_copy_summary.xul | 44 ++--- .../server/locale/en-US/circ.properties | 3 + 8 files changed, 306 insertions(+), 268 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/cat/bib_brief.js create mode 100644 Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js create mode 100644 Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.xul diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 12b052068b..3a43f96267 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2002,16 +2002,24 @@ - + + - - - + + + + + + - - - - + + + + + + + + @@ -2879,16 +2887,13 @@ - - - @@ -2912,7 +2917,6 @@ - diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief.js b/Open-ILS/xul/staff_client/server/cat/bib_brief.js new file mode 100644 index 0000000000..b4e283e58c --- /dev/null +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief.js @@ -0,0 +1,117 @@ +var docid; + +function my_init() { + 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'); var data = new OpenILS.data(); data.init({'via':'stash'}); + + docid = xul_param('docid'); + + var key = location.pathname + location.search + location.hash; + if (!docid && typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { + var xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ]; + if (typeof xulG == 'object') { + docid = xulG.docid; + } + } + + 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])); + + if (docid > -1) { + + data.last_record = docid; data.stash('last_record'); + + g.network.simple_request( + '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;'); + } + 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); + } + } + ); + } + ); + + } else { + var t = document.getElementById('caption').getAttribute('label'); + 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); + } + + } catch(E) { + var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['cat/bib_brief.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); } + alert(err_msg); + } +} + +function view_marc() { + try { + JSAN.use('util.window'); var win = new util.window(); + if (docid < 0) { + alert(document.getElementById("catStrings").getString('staff.cat.bib_brief.noncat.alert')); + } else { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + //win.open( urls.XUL_MARC_VIEW + '?noprint=1&docid=' + docid, 'marc_view', 'chrome,resizable,modal,width=400,height=400'); + win.open( urls.XUL_MARC_VIEW, 'marc_view', 'chrome,resizable,modal,width=400,height=400',{'noprint':1,'docid':docid}); + } + } catch(E) { + g.error.standard_unexpected_error_alert('spawning marc display',E); + } +} + +function spawn_patron(span) { + try { + if (typeof window.xulG == 'object' && typeof window.xulG.set_patron_tab == 'function') { + window.xulG.set_patron_tab( {}, { 'id' : span.getAttribute('au_id') } ); + } else { + copy_to_clipboard( span.textContent ); + } + } catch(E) { + g.error.standard_unexpected_error_alert('spawning patron display',E); + } +} + + diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief.xul b/Open-ILS/xul/staff_client/server/cat/bib_brief.xul index 8a7ce64520..33264ebfd1 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief.xul +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief.xul @@ -19,10 +19,10 @@ vim: noet:sw=4:ts=4: + @@ -33,214 +33,14 @@ vim: noet:sw=4:ts=4: +