<!ENTITY staff.cat.popup.edit.record.window.key "">
<!ENTITY staff.cat.popup.edit_record.tab "Edit Record (Tab)">
<!ENTITY staff.cat.popup.edit_record.window "Edit Record (Window)">
+<!ENTITY staff.cat.record_buckets.merge_records.merge_lead "Merge these records? (Select the 'lead' record first)">
+<!ENTITY staff.cat.record_buckets.merge_records.button.label "Merge">
+<!ENTITY staff.cat.record_buckets.merge_records.button.accesskey "M">
+<!ENTITY staff.cat.record_buckets.merge_records.cancel_button.label "Cancel">
+<!ENTITY staff.cat.record_buckets.merge_records.cancel_button.accesskey "C">
+<!ENTITY staff.cat.record_buckets.merge_records.lead "Lead Record?">
+<!ENTITY staff.cat.record_buckets.merge_records.remove_from_consideration "Remove from consideration?">
<!ENTITY staff.cat.search_advanced "Advanced">
<!ENTITY staff.cat.search_advanced.key "V">
<!ENTITY staff.cat.search_all "Keyword">
'set_text',
'save_attributes',
'load_attributes',
+ 'find_descendants_by_name'
];
util.widgets.EXPORT_TAGS = { ':all' : util.widgets.EXPORT_OK };
e.setAttribute('properties', prop_class_string);
}
+util.widgets.find_descendants_by_name = function(top_node,name) {
+ top_node = util.widgets.get(top_node);
+ if (!top_node) { return []; }
+ return top_node.getElementsByAttribute('name',name);
+}
+
dump('exiting util/widgets.js\n');
--- /dev/null
+var error;
+var network;
+var record_ids;
+var lead_record;
+
+function my_init() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('/xul/server/');
+ JSAN.use('util.error'); error = new util.error();
+ error.sdump('D_TRACE','my_init() for bibs_abreast.xul');
+ JSAN.use('util.functional');
+ JSAN.use('util.widgets');
+ JSAN.use('cat.util');
+ JSAN.use('util.network');
+
+ network = new util.network();
+
+ record_ids = xul_param('record_ids') || [];
+ record_ids = util.functional.unique_list_values( record_ids );
+
+ // Merge UI
+ if (xul_param('merge')) {
+ var x = document.getElementById('merge_bar');
+ x.hidden = false;
+ var y = document.getElementById('merge_button');
+ y.addEventListener('command', merge_records, false);
+ var z = document.getElementById('cancel_button');
+ z.addEventListener('command', function() {
+ x.hidden = true;
+ y.disabled = true;
+ var merge_bars = util.widgets.find_descendants_by_name(document,'merge_bar');
+ for (var i = 0; i < merge_bars.length; i++) { merge_bars[i].hidden = true; }
+ }, false);
+ }
+
+ // Display the records
+ for (var i = 0; i < record_ids.length; i++) {
+ render_bib(record_ids[i]);
+ }
+
+ /*if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name('Test'); } catch(E) { alert(E); }
+ }*/
+
+ } catch(E) {
+ try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
+ }
+}
+
+function render_bib(record_id) {
+ var main = document.getElementById('main');
+ var template = main.firstChild;
+ var new_node = template.cloneNode(true);
+ main.appendChild(new_node);
+ new_node.hidden = false;
+
+ var splitter_template = template.nextSibling;
+ var splitter = splitter_template.cloneNode(true);
+ main.appendChild(splitter);
+ splitter.hidden = false;
+
+ render_bib_brief(new_node,record_id);
+
+ var xul_deck = util.widgets.find_descendants_by_name(new_node,'bib_deck')[0];
+ var deck = new util.deck(xul_deck);
+
+ // merge UI
+ if (xul_param('merge')) {
+ var merge_bar = util.widgets.find_descendants_by_name(new_node,'merge_bar')[0];
+ merge_bar.hidden = false;
+ var lead_button = util.widgets.find_descendants_by_name(new_node,'lead_button')[0];
+ lead_button.addEventListener('click', function() {
+ lead_record = record_id;
+ dump('record_id = ' + record_id + '\n');
+ document.getElementById('merge_button').disabled = false;
+ }, false);
+ }
+
+ // remove_me button
+ var remove_me = util.widgets.find_descendants_by_name(new_node,'remove_me')[0];
+ remove_me.addEventListener('command', function() {
+ if (lead_record == record_id) {
+ lead_record = undefined;
+ document.getElementById('merge_button').disabled = true;
+ }
+ record_ids = util.functional.filter_list( record_ids, function(o) { return o != record_id; } );
+ main.removeChild(new_node);
+ main.removeChild(splitter);
+ if (main.childNodes.length == 4) {
+ document.getElementById('merge_bar').hidden = true;
+ document.getElementById('merge_button').disabled = true;
+ var merge_bars = util.widgets.find_descendants_by_name(document,'merge_bar');
+ for (var i = 0; i < merge_bars.length; i++) { merge_bars[i].hidden = true; }
+ }
+ if (main.childNodes.length == 2) { xulG.close_tab(); }
+ }, false);
+
+ // radio buttons
+ var view_bib = util.widgets.find_descendants_by_name(new_node,'view_bib')[0];
+ var edit_bib = util.widgets.find_descendants_by_name(new_node,'edit_bib')[0];
+ var holdings = util.widgets.find_descendants_by_name(new_node,'holdings')[0];
+
+ view_bib.addEventListener('command', function() {
+ set_view_pane(deck,record_id);
+ }, false);
+
+ edit_bib.addEventListener('command', function() {
+ set_edit_pane(deck,record_id);
+ }, false);
+
+ holdings.addEventListener('command', function() {
+ set_item_pane(deck,record_id);
+ }, false);
+
+ set_view_pane(deck,record_id);
+
+}
+
+function render_bib_brief(new_node,record_id) {
+ // iframe
+ var bib_brief = util.widgets.find_descendants_by_name(new_node,'bib_brief')[0];
+ bib_brief.setAttribute('src', urls.XUL_BIB_BRIEF_VERTICAL);
+ get_contentWindow(bib_brief).xulG = { 'docid' : record_id };
+}
+
+function set_view_pane(deck,record_id) {
+ deck.set_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : record_id } );
+}
+
+function set_item_pane(deck,record_id) {
+ var my_xulG = { 'docid' : record_id }; for (var i in xulG) { my_xulG[i] = xulG[i]; }
+ deck.set_iframe( urls.XUL_COPY_VOLUME_BROWSE, {}, my_xulG );
+}
+
+function set_edit_pane(deck,record_id) {
+ var my_xulG = {
+ 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + record_id, "id": record_id, "rtype": "bre" },
+ 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
+ try {
+ return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
+ } catch(E) {
+ alert('Error in bibs_abreast.js, set_edit_pane, fast_item_add: ' + E);
+ }
+ },
+ 'save' : {
+ 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
+ 'func' : function (new_marcxml) {
+ try {
+ var r = network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), record_id, new_marcxml ]);
+ if (typeof r.ilsevent != 'undefined') {
+ throw(r);
+ } else {
+ return {
+ 'id' : r.id(),
+ 'oncomplete' : function() {}
+ };
+ }
+ } catch(E) {
+ alert('Error in bibs_abreast.js, set_edit_pane, save: ' + E);
+ }
+ }
+ }
+ };
+ for (var i in xulG) { my_xulG[i] = xulG[i]; }
+ deck.set_iframe( urls.XUL_MARC_EDIT, {}, my_xulG );
+}
+
+function merge_records() {
+ try {
+ var robj = network.simple_request('MERGE_RECORDS',
+ [
+ ses(),
+ lead_record,
+ util.functional.filter_list( record_ids,
+ function(o) {
+ return o != lead_record;
+ }
+ )
+ ]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ switch(robj.ilsevent) {
+ case 5000 /* PERM_FAILURE */: break;
+ default: throw(robj);
+ }
+ }
+ if (typeof xulG.on_merge == 'function') {
+ xulG.on_merge(robj);
+ }
+ var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + lead_record;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ xulG.set_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':'Retrieving title...'},
+ content_params
+ );
+ } catch(E) {
+ alert('Error in bibs_abreast.js, merge_records(): ' + E);
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Example Template for remote xul -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+ <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="main_bibs_abreast"
+ onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- BEHAVIOR -->
+ <script type="text/javascript">
+ var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;
+ </script>
+ <scripts id="openils_util_scripts"/>
+
+ <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+ <script type="text/javascript" src="bibs_abreast.js"/>
+
+ <hbox id="merge_bar" hidden="true">
+ <description>&staff.cat.record_buckets.merge_records.merge_lead;</description>
+ <button id="merge_button" disabled="true"
+ label="&staff.cat.record_buckets.merge_records.button.label;"
+ accesskey="&staff.cat.record_buckets.merge_records.button.accesskey;"
+ />
+ <button id="cancel_button"
+ label="&staff.cat.record_buckets.merge_records.cancel_button.label;"
+ accesskey="&staff.cat.record_buckets.merge_records.cancel_button.accesskey;"
+ />
+ </hbox>
+ <hbox id="main" class="my_overflow" flex="1">
+ <vbox name="template" hidden="true" flex="1">
+ <hbox name="merge_bar" hidden="true">
+ <input name="lead_button" type="radio" xmlns="http://www.w3.org/1999/xhtml"></input>
+ &staff.cat.record_buckets.merge_records.lead;
+ </hbox>
+ <iframe name="bib_brief" flex="1" />
+ <hbox>
+ <radiogroup flex="0" orient="horizontal">
+ <radio name="view_bib" label="View Bib" />
+ <radio name="edit_bib" label="Edit Bib" />
+ <radio name="holdings" label="Holdings" />
+ </radiogroup>
+ <spacer flex="1"/>
+ <button name="remove_me"
+ image="/xul/server/skin/media/images/icon_delete.gif"
+ label="&staff.cat.record_buckets.merge_records.remove_from_consideration;" />
+ </hbox>
+ <deck name="bib_deck" flex="3" />
+ </vbox>
+ <splitter name="template2" hidden="true"><grippy /></splitter>
+ </hbox>
+
+</window>
+
}
);
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
- top_xml += '<description>' + $("catStrings").getString('staff.cat.record_buckets.merge_records.merge_lead') + '</description>';
- top_xml += '<hbox>';
- top_xml += '<button id="lead" disabled="true" label="'
- + $("catStrings").getString('staff.cat.record_buckets.merge_records.button.label') + '" name="fancy_submit"/>';
- top_xml += '<button label="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.label') +'" accesskey="'
- + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.accesskey') +'" name="fancy_cancel"/></hbox></vbox>';
-
- var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
- xml += '<table><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td><input value="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.lead')
- xml += '" id="record_' + record_ids[i] + '" type="radio" name="lead"';
- xml += ' onclick="' + "try { var x = $('lead'); x.setAttribute('value',";
- xml += record_ids[i] + '); x.disabled = false; } catch(E) { alert(E); }">';
- xml += '</input>' + $("catStrings").getFormattedString('staff.cat.record_buckets.merge_records.lead_record_number',[record_ids[i]]) + '</td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
- xml += '?docid=' + record_ids[i] + '"/></td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
- }
- xml += '</tr></table></form>';
- //obj.data.temp_merge_top = top_xml; obj.data.stash('temp_merge_top');
- //obj.data.temp_merge_mid = xml; obj.data.stash('temp_merge_mid');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_merge_mid'
- //+ '&top_xml_in_stash=temp_merge_top'
- //+ '&title=' + window.escape('Record Merging'),
- 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
- {
- 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt_title')
+ xulG.new_tab(
+ '/xul/server/cat/bibs_abreast.xul',{
+ 'tab_name' : $("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt_title')
+ },{
+ 'merge' : true,
+ 'on_merge' : function() {
+ obj.render_pending_records(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ },
+ 'record_ids':record_ids
}
);
- //obj.data.stash_retrieve();
- if (typeof fancy_prompt_data.fancy_status == 'undefined' || fancy_prompt_data.fancy_status == 'incomplete') {
- alert($("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt.alert'));
- return;
- }
- var robj = obj.network.simple_request('MERGE_RECORDS',
- [
- ses(),
- fancy_prompt_data.lead,
- util.functional.filter_list( record_ids,
- function(o) {
- return o != fancy_prompt_data.lead;
- }
- )
- ]
- );
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- }
-
- obj.render_pending_records(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
} catch(E) {
obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.merge_records.catch.std_unex_error'),E);
}
staff.cat.record_buckets.new_bucket.bucket_prompt_title=Bucket Creation
staff.cat.record_buckets.new_bucket.same_name_alert=You already have a bucket with that name.
staff.cat.record_buckets.new_bucket.bucket_created=Bucket %1$s created.
-staff.cat.record_buckets.merge_records.merge_lead=Merge these records? (Select the "lead" record first)
-staff.cat.record_buckets.merge_records.button.label=Merge
-staff.cat.record_buckets.merge_records.cancel_button.label=Cancel
-staff.cat.record_buckets.merge_records.cancel_button.accesskey=C
-staff.cat.record_buckets.merge_records.lead_record_number=Lead Record? # %1$s
-staff.cat.record_buckets.merge_records.lead=Lead
-staff.cat.record_buckets.merge_records.fancy_prompt_title=Record Merging
-staff.cat.record_buckets.merge_records.fancy_prompt.alert=Merge Aborted
-staff.cat.record_buckets.merge_records.success=Records were successfully merged.
-staff.cat.record_buckets.merge_records.catch.std_unex_error=Records were not likely merged.
staff.cat.record_buckets.delete_records.xml1=Delete these records?
staff.cat.record_buckets.delete_records.button.label=Delete
staff.cat.record_buckets.delete_records.cancel_button.label=Cancel