From b365101bca38622624248f84aec075353778fe71 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Thu, 16 Jun 2011 12:23:09 -0400 Subject: [PATCH] batch menus for Volume Edit refactoring menu generators for CN classes and affixes description of Auto-Merge checkbox in Volume Edit Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + Open-ILS/xul/staff_client/server/cat/util.js | 202 +++++++++++++++- .../staff_client/server/cat/volume_copy_creator.js | 157 ++---------- .../xul/staff_client/server/cat/volume_editor.js | 268 +++++++++++++-------- .../xul/staff_client/server/cat/volume_editor.xul | 33 ++- 5 files changed, 415 insertions(+), 246 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 63e992714d..ffbce223ae 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2854,6 +2854,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index ea543b7722..64358a474b 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -9,7 +9,9 @@ cat.util.EXPORT_OK = [ 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', 'transfer_title_holds', 'mark_item_missing', 'mark_item_damaged', 'replace_barcode', 'fast_item_add', 'make_bookable', 'edit_new_brsrc', 'edit_new_bresv', 'batch_edit_volumes', 'render_fine_level', - 'render_loan_duration', 'mark_item_as_missing_pieces', 'transfer_specific_title_holds' + 'render_loan_duration', 'mark_item_as_missing_pieces', 'render_callnumbers_for_bib_menu', + 'render_cn_prefix_menuitems', 'render_cn_suffix_menuitems', 'render_cn_class_menu', + 'render_cn_prefix_menu', 'render_cn_suffix_menu', 'transfer_specific_title_holds' ]; cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK }; @@ -918,4 +920,202 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) { } } +cat.util.render_callnumbers_for_bib_menu = function(node, doc_id, label_class) { + try { + var cn_blob; + try { + cn_blob = g.network.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[doc_id, label_class]); + } catch(E) { + cn_blob = []; + } + var hbox = typeof node == 'string' ? document.getElementById(node) : node; + JSAN.use('util.widgets'); + JSAN.use('util.functional'); + var ml = util.widgets.make_menulist( + [ + [ '', '' ] + ].concat( + util.functional.map_list( + cn_blob, + function(o) { + for (var i in o) { + return [ o[i], i ]; + } + } + ) + ) + ); hbox.appendChild(ml); + ml.setAttribute('editable','true'); + ml.setAttribute('width', '200'); + ml.setAttribute('id', hbox.id + '_menulist'); + } catch(E) { + alert('Error in cat.util.render_callnumbers_for_bib_menu: ' + E); + } +} + +cat.util.render_cn_prefix_menuitems = function(menupopup,ou_id) { + try { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.stash_retrieve(); + JSAN.use('util.network'); + var network = new util.network(); + + if (typeof data.list['acnp_for_lib_'+ou_id] == 'undefined') { + data.list['acnp_for_lib_'+ou_id] = network.simple_request( + 'FM_ACNP_RETRIEVE_VIA_PCRUD', + [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acnp":"label_sortkey"}} ] + ); + data.stash('list'); + } + for (var i = 0; i < data.list['acnp_for_lib_'+ou_id].length; i++) { + var my_acnp = data.list['acnp_for_lib_'+ou_id][i]; + var menuitem = document.createElement('menuitem'); + menupopup.appendChild(menuitem); + menuitem.setAttribute( + 'label', + my_acnp.id() == -1 ? '' : + $('catStrings').getFormattedString( + 'staff.cat.volume_copy_creator.call_number_prefix.menuitem_label', + [ + my_acnp.label(), + data.hash.aou[ ou_id ].shortname() + ] + ) + ); + menuitem.setAttribute('value',my_acnp.id()); + } + } catch(E) { + alert('Error in cat.util.render_cn_prefix_menuitems: ' + E); + } +} + +cat.util.render_cn_suffix_menuitems = function(menupopup,ou_id) { + try { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.stash_retrieve(); + JSAN.use('util.network'); + var network = new util.network(); + + if (typeof data.list['acns_for_lib_'+ou_id] == 'undefined') { + data.list['acns_for_lib_'+ou_id] = network.simple_request( + 'FM_ACNS_RETRIEVE_VIA_PCRUD', + [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acns":"label_sortkey"}} ] + ); + data.stash('list'); + } + for (var i = 0; i < data.list['acns_for_lib_'+ou_id].length; i++) { + var my_acns = data.list['acns_for_lib_'+ou_id][i]; + var menuitem = document.createElement('menuitem'); + menupopup.appendChild(menuitem); + menuitem.setAttribute( + 'label', + my_acns.id() == -1 ? '' : + $('catStrings').getFormattedString( + 'staff.cat.volume_copy_creator.call_number_suffix.menuitem_label', + [ + my_acns.label(), + data.hash.aou[ ou_id ].shortname() + ] + ) + ); + menuitem.setAttribute('value',my_acns.id()); + } + } catch(E) { + alert('Error in cat.util.render_cn_suffix_menuitems: ' + E); + } +} + +cat.util.render_cn_class_menu = function(extra_menuitems,menu_default) { + try { + JSAN.use('util.widgets'); + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.stash_retrieve(); + + var menulist = util.widgets.make_menulist( + (extra_menuitems || []).concat( + util.functional.map_list( + data.list.acnc, + function(o) { + return [ o.name(), o.id() ]; + } + ) + ) + ); + + if (typeof menu_default != 'undefined') { + menulist.setAttribute('value',menu_default); + } + return menulist; + + } catch(E) { + alert('Error in cat.util.render_cn_class_menu: ' + E); + } +} + +cat.util.render_cn_prefix_menu = function(ou_ids,extra_menuitems,menu_default) { + try { + JSAN.use('util.widgets'); + var menulist = util.widgets.make_menulist(extra_menuitems||[],menu_default); + var menupopup = menulist.firstChild; + var org_list; + if (ou_ids.length == 1) { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.stash_retrieve(); + var org = data.hash.aou[ ou_ids[0] ]; + org_list = []; // order from top of consortium to owning lib + while(org) { + org_list.unshift(org.id()); + org = org.parent_ou(); + if (org && typeof org != 'object') { + org = data.hash.aou[ org ]; + } + } + } else { + org_list = ou_ids; + } + for (var i = 0; i < org_list.length; i++) { + cat.util.render_cn_prefix_menuitems(menupopup,org_list[i]); + } + if (typeof menu_default != 'undefined') { + menulist.setAttribute('value',menu_default); + } + return menulist; + } catch(E) { + alert('Error in cat.util.render_cn_prefix_menu('+ou_id+'): ' + E); + } +} + +cat.util.render_cn_suffix_menu = function(ou_ids,extra_menuitems,menu_default) { + try { + JSAN.use('util.widgets'); + var menulist = util.widgets.make_menulist(extra_menuitems||[],menu_default); + var menupopup = menulist.firstChild; + var org_list; + if (ou_ids.length == 1) { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.stash_retrieve(); + var org = data.hash.aou[ ou_ids[0] ]; + org_list = []; // order from top of consortium to owning lib + while(org) { + org_list.unshift(org.id()); + org = org.parent_ou(); + if (org && typeof org != 'object') { + org = data.hash.aou[ org ]; + } + } + } else { + org_list = ou_ids; + } + for (var i = 0; i < org_list.length; i++) { + cat.util.render_cn_suffix_menuitems(menupopup,org_list[i]); + } + if (typeof menu_default != 'undefined') { + menulist.setAttribute('value',menu_default); + } + return menulist; + } catch(E) { + alert('Error in cat.util.render_cn_suffix_menu('+ou_id+'): ' + E); + } +} + dump('exiting cat/util.js\n'); diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js index 111226a6e2..5e204c4bce 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js @@ -192,7 +192,8 @@ function my_init() { /* For the batch drop downs */ g.list_classes(); - g.list_callnumbers(g.doc_id, g.label_class); + JSAN.use('cat.util'); + cat.util.render_callnumbers_for_bib_menu('marc_cn',g.doc_id, g.label_class); g.render_batch_button(); /***********************************************************************************************************/ @@ -1252,14 +1253,7 @@ g.save_prefs = function () { } g.render_class_menu = function(call_number_tb) { - var ml = util.widgets.make_menulist( - util.functional.map_list( - g.data.list.acnc, - function(o) { - return [ o.name(), o.id() ]; - } - ) - ); + var ml = cat.util.render_cn_class_menu(); ml.setAttribute('rel_vert_pos',rel_vert_pos_call_number_classification); ml.addEventListener( 'command', @@ -1273,22 +1267,7 @@ g.render_class_menu = function(call_number_tb) { g.render_prefix_menu = function(call_number_tb) { var ou_id = call_number_tb.getAttribute('ou_id'); - var org = g.data.hash.aou[ ou_id ]; - var menulist = document.createElement('menulist'); - var menupopup = document.createElement('menupopup'); - menulist.appendChild(menupopup); - var org_list = []; // order from top of consortium to owning lib - while(org) { - org_list.unshift(org.id()); - org = org.parent_ou(); - if (org && typeof org != 'object') { - org = g.data.hash.aou[ org ]; - } - } - for (var i = 0; i < org_list.length; i++) { - g.render_prefix_menu_items(menupopup,org_list[i]); - } - + var menulist = cat.util.render_cn_prefix_menu([ou_id]); menulist.setAttribute('rel_vert_pos',rel_vert_pos_call_number_prefix); menulist.addEventListener( 'command', @@ -1300,51 +1279,9 @@ g.render_prefix_menu = function(call_number_tb) { return menulist; } -g.render_prefix_menu_items = function(menupopup,ou_id) { - if (typeof g.data.list['acnp_for_lib_'+ou_id] == 'undefined') { - g.data.list['acnp_for_lib_'+ou_id] = g.network.simple_request( - 'FM_ACNP_RETRIEVE_VIA_PCRUD', - [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acnp":"label_sortkey"}} ] - ); - g.data.stash('list'); - } - for (var i = 0; i < g.data.list['acnp_for_lib_'+ou_id].length; i++) { - var my_acnp = g.data.list['acnp_for_lib_'+ou_id][i]; - var menuitem = document.createElement('menuitem'); - menupopup.appendChild(menuitem); - menuitem.setAttribute( - 'label', - my_acnp.id() == -1 ? '' : - $('catStrings').getFormattedString( - 'staff.cat.volume_copy_creator.call_number_prefix.menuitem_label', - [ - my_acnp.label(), - g.data.hash.aou[ ou_id ].shortname() - ] - ) - ); - menuitem.setAttribute('value',my_acnp.id()); - } -} - g.render_suffix_menu = function(call_number_tb) { var ou_id = call_number_tb.getAttribute('ou_id'); - var org = g.data.hash.aou[ ou_id ]; - var menulist = document.createElement('menulist'); - var menupopup = document.createElement('menupopup'); - menulist.appendChild(menupopup); - var org_list = []; // order from top of consortium to owning lib - while(org) { - org_list.unshift(org.id()); - org = org.parent_ou(); - if (org && typeof org != 'object') { - org = g.data.hash.aou[ org ]; - } - } - for (var i = 0; i < org_list.length; i++) { - g.render_suffix_menu_items(menupopup,org_list[i]); - } - + var menulist = cat.util.render_cn_suffix_menu([ou_id]); menulist.setAttribute('rel_vert_pos',rel_vert_pos_call_number_suffix); menulist.addEventListener( 'command', @@ -1356,74 +1293,12 @@ g.render_suffix_menu = function(call_number_tb) { return menulist; } -g.render_suffix_menu_items = function(menupopup,ou_id) { - if (typeof g.data.list['acns_for_lib_'+ou_id] == 'undefined') { - g.data.list['acns_for_lib_'+ou_id] = g.network.simple_request( - 'FM_ACNS_RETRIEVE_VIA_PCRUD', - [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acns":"label_sortkey"}} ] - ); - g.data.stash('list'); - } - for (var i = 0; i < g.data.list['acns_for_lib_'+ou_id].length; i++) { - var my_acns = g.data.list['acns_for_lib_'+ou_id][i]; - var menuitem = document.createElement('menuitem'); - menupopup.appendChild(menuitem); - menuitem.setAttribute( - 'label', - my_acns.id() == -1 ? '' : - $('catStrings').getFormattedString( - 'staff.cat.volume_copy_creator.call_number_suffix.menuitem_label', - [ - my_acns.label(), - g.data.hash.aou[ ou_id ].shortname() - ] - ) - ); - menuitem.setAttribute('value',my_acns.id()); - } -} - - -g.list_callnumbers = function(doc_id, label_class) { - var cn_blob; - try { - cn_blob = g.network.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[g.doc_id, label_class]); - } catch(E) { - cn_blob = []; - } - var hbox = document.getElementById('marc_cn'); - var ml = util.widgets.make_menulist( - [ - [ '', '' ] - ].concat( - util.functional.map_list( - cn_blob, - function(o) { - for (var i in o) { - return [ o[i], i ]; - } - } - ) - ) - ); hbox.appendChild(ml); - ml.setAttribute('editable','true'); - ml.setAttribute('width', '200'); - ml.setAttribute('id', 'marc_cn_menulist'); -} - g.list_classes = function() { var hbox = $('batch_class'); - var ml = util.widgets.make_menulist( + var ml = cat.util.render_cn_class_menu( [ [ '', false ] - ].concat( - util.functional.map_list( - g.data.list.acnc, - function(o) { - return [ o.name(), o.id() ]; - } - ) - ) + ] ); hbox.appendChild(ml); ml.setAttribute('id','batch_class_menulist'); ml.addEventListener( @@ -1444,15 +1319,14 @@ g.list_classes = function() { g.list_prefixes = function() { var hbox = $('batch_prefix'); - var ml = util.widgets.make_menulist( + var ml = cat.util.render_cn_prefix_menu( + g.common_ancestor_ou_ids, [ [ '', false ] ] - ); hbox.appendChild(ml); - for (var i = 0; i < g.common_ancestor_ou_ids.length; i++) { - g.render_prefix_menu_items(ml.firstChild,g.common_ancestor_ou_ids[i]); - } + ); ml.setAttribute('id','batch_prefix_menulist'); + hbox.appendChild(ml); ml.addEventListener( 'command', function() { @@ -1471,15 +1345,14 @@ g.list_prefixes = function() { g.list_suffixes = function() { var hbox = $('batch_suffix'); - var ml = util.widgets.make_menulist( + var ml = cat.util.render_cn_suffix_menu( + g.common_ancestor_ou_ids, [ [ '', false ] ] - ); hbox.appendChild(ml); - for (var i = 0; i < g.common_ancestor_ou_ids.length; i++) { - g.render_suffix_menu_items(ml.firstChild,g.common_ancestor_ou_ids[i]); - } + ); ml.setAttribute('id','batch_suffix_menulist'); + hbox.appendChild(ml); ml.addEventListener( 'command', function() { diff --git a/Open-ILS/xul/staff_client/server/cat/volume_editor.js b/Open-ILS/xul/staff_client/server/cat/volume_editor.js index db6e1b85a5..d65bd43269 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_editor.js @@ -1,3 +1,8 @@ +const rel_vert_pos_call_number_classification = 1; +const rel_vert_pos_call_number_prefix = 2; +const rel_vert_pos_call_number = 3; +const rel_vert_pos_call_number_suffix = 4; + var xulG = {}; function my_init() { @@ -14,6 +19,8 @@ function my_init() { JSAN.use('util.functional'); + JSAN.use('cat.util'); + g.volumes = xul_param('volumes',{'stash_name':'volumes_temp','clear_xpcom':true,'modal_xulG':true}); //JSON2js( g.data.volumes_temp ); //g.data.volumes_temp = ''; g.data.stash('volumes_temp'); @@ -22,17 +29,24 @@ function my_init() { var first_tb; for (var i = 0; i < g.volumes.length; i++) { - var row = document.createElement('row'); rows.appendChild(row); - var lib_label = document.createElement('label'); row.appendChild(lib_label); + var row = document.createElement('row'); + rows.appendChild(row); + var lib_label = document.createElement('label'); + row.appendChild(lib_label); var class_ml = g.render_class_menu(i); class_ml.setAttribute('class','cn_class'); + class_ml.setAttribute('rel_vert_pos', rel_vert_pos_call_number_classification); row.appendChild(class_ml); var prefix_ml = g.render_prefix_menu(i); prefix_ml.setAttribute('class','cn_prefix'); + prefix_ml.setAttribute('rel_vert_pos', rel_vert_pos_call_number_prefix); row.appendChild(prefix_ml); - var label_tb = document.createElement('textbox'); row.appendChild(label_tb); + var label_tb = document.createElement('textbox'); + label_tb.setAttribute('rel_vert_pos', rel_vert_pos_call_number); + row.appendChild(label_tb); var suffix_ml = g.render_suffix_menu(i); suffix_ml.setAttribute('class','cn_suffix'); + suffix_ml.setAttribute('rel_vert_pos', rel_vert_pos_call_number_suffix); row.appendChild(suffix_ml); if (!first_tb) { first_tb = label_tb; } @@ -50,6 +64,51 @@ function my_init() { first_tb.select(); first_tb.focus(); + // The batch menus + if (g.volumes.length > 0) { + JSAN.use('cat.util'); + JSAN.use('util.fm_utils'); + + // Get the default callnumber classification scheme from OU settings + g.label_class = g.data.hash.aous['cat.default_classification_scheme']; + + // Assign a default value if none was returned + if (!g.label_class) { + g.label_class = g.data.list.acnc[0].id(); + } + + // Find the pertinent orgs + var ou_ids = []; + var seen_ou = {}; + for (var i = 0; i < g.volumes.length; i++) { + seen_ou[ g.volumes[i].owning_lib() ] = 1; + } + for (var i in seen_ou) { + ou_ids.push(i); + } + g.ou_ids = []; + for (var i = 0; i < ou_ids.length; i++) { + try { + var org = g.data.hash.aou[ ou_ids[i] ]; + if ( get_bool( g.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) { + g.ou_ids.push( ou_ids[i] ); + } + } catch(E) { + g.error.sdump('D_ERROR',E); + } + } + g.common_ancestor_ou_ids = util.fm_utils.find_common_aou_ancestors( g.ou_ids ).reverse(); + + // render the menus + g.list_classes(); + g.list_prefixes(); + cat.util.render_callnumbers_for_bib_menu('marc_cn',g.volumes[0].record(), g.label_class); + g.list_suffixes(); + + // render the button + g.render_batch_button(); + } + } catch(E) { var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/volume_editor.xul', E]); try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); } @@ -73,13 +132,8 @@ g.stash_and_close = function() { } g.render_class_menu = function(vol_idx) { - var ml = util.widgets.make_menulist( - util.functional.map_list( - g.data.list.acnc, - function(o) { - return [ o.name(), o.id() ]; - } - ), + var ml = cat.util.render_cn_class_menu( + [], typeof g.volumes[vol_idx].label_class() == 'object' ? g.volumes[vol_idx].label_class().id() : g.volumes[vol_idx].label_class() @@ -96,28 +150,18 @@ g.render_class_menu = function(vol_idx) { } g.render_prefix_menu = function(vol_idx) { + var org = typeof g.volumes[vol_idx].owning_lib() == 'object' ? g.volumes[vol_idx].owning_lib() : g.data.hash.aou[ g.volumes[vol_idx].owning_lib() ]; - var menulist = document.createElement('menulist'); - var menupopup = document.createElement('menupopup'); - menulist.appendChild(menupopup); - var org_list = []; // order from top of consortium to owning lib - while(org) { - org_list.unshift(org.id()); - org = org.parent_ou(); - if (org && typeof org != 'object') { - org = g.data.hash.aou[ org ]; - } - } - for (var i = 0; i < org_list.length; i++) { - g.render_prefix_menu_items(menupopup,org_list[i]); - } - menulist.setAttribute('value', - typeof g.volumes[vol_idx].prefix() == 'object' - ? g.volumes[vol_idx].prefix().id() - : g.volumes[vol_idx].prefix() - ); + + var menulist = cat.util.render_cn_prefix_menu( + [ org.id() ], + [], + typeof g.volumes[vol_idx].prefix() == 'object' + ? g.volumes[vol_idx].prefix().id() + : g.volumes[vol_idx].prefix() + ); menulist.addEventListener( 'command', @@ -130,57 +174,19 @@ g.render_prefix_menu = function(vol_idx) { return menulist; } -g.render_prefix_menu_items = function(menupopup,ou_id) { - if (typeof g.data.list['acnp_for_lib_'+ou_id] == 'undefined') { - g.data.list['acnp_for_lib_'+ou_id] = g.network.simple_request( - 'FM_ACNP_RETRIEVE_VIA_PCRUD', - [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acnp":"label_sortkey"}} ] - ); - g.data.stash('list'); - } - for (var i = 0; i < g.data.list['acnp_for_lib_'+ou_id].length; i++) { - var my_acnp = g.data.list['acnp_for_lib_'+ou_id][i]; - var menuitem = document.createElement('menuitem'); - menupopup.appendChild(menuitem); - menuitem.setAttribute( - 'label', - my_acnp.id() == -1 ? '' : - $('catStrings').getFormattedString( - 'staff.cat.volume_copy_creator.call_number_prefix.menuitem_label', - [ - my_acnp.label(), - g.data.hash.aou[ ou_id ].shortname() - ] - ) - ); - menuitem.setAttribute('value',my_acnp.id()); - } -} - - g.render_suffix_menu = function(vol_idx) { + var org = typeof g.volumes[vol_idx].owning_lib() == 'object' ? g.volumes[vol_idx].owning_lib() : g.data.hash.aou[ g.volumes[vol_idx].owning_lib() ]; - var menulist = document.createElement('menulist'); - var menupopup = document.createElement('menupopup'); - menulist.appendChild(menupopup); - var org_list = []; // order from top of consortium to owning lib - while(org) { - org_list.unshift(org.id()); - org = org.parent_ou(); - if (org && typeof org != 'object') { - org = g.data.hash.aou[ org ]; - } - } - for (var i = 0; i < org_list.length; i++) { - g.render_suffix_menu_items(menupopup,org_list[i]); - } - menulist.setAttribute('value', - typeof g.volumes[vol_idx].suffix() == 'object' - ? g.volumes[vol_idx].suffix().id() - : g.volumes[vol_idx].suffix() - ); + + var menulist = cat.util.render_cn_suffix_menu( + [ org.id() ], + [], + typeof g.volumes[vol_idx].suffix() == 'object' + ? g.volumes[vol_idx].suffix().id() + : g.volumes[vol_idx].suffix() + ); menulist.addEventListener( 'command', @@ -193,31 +199,91 @@ g.render_suffix_menu = function(vol_idx) { return menulist; } -g.render_suffix_menu_items = function(menupopup,ou_id) { - if (typeof g.data.list['acns_for_lib_'+ou_id] == 'undefined') { - g.data.list['acns_for_lib_'+ou_id] = g.network.simple_request( - 'FM_ACNS_RETRIEVE_VIA_PCRUD', - [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acns":"label_sortkey"}} ] - ); - g.data.stash('list'); - } - for (var i = 0; i < g.data.list['acns_for_lib_'+ou_id].length; i++) { - var my_acns = g.data.list['acns_for_lib_'+ou_id][i]; - var menuitem = document.createElement('menuitem'); - menupopup.appendChild(menuitem); - menuitem.setAttribute( - 'label', - my_acns.id() == -1 ? '' : - $('catStrings').getFormattedString( - 'staff.cat.volume_copy_creator.call_number_suffix.menuitem_label', - [ - my_acns.label(), - g.data.hash.aou[ ou_id ].shortname() - ] - ) - ); - menuitem.setAttribute('value',my_acns.id()); - } +g.list_classes = function() { + var hbox = $('batch_class'); + var ml = cat.util.render_cn_class_menu( + [ + [ '', false ] + ] + ); + ml.setAttribute('id','batch_class_menulist'); + hbox.appendChild(ml); } +g.list_prefixes = function() { + var hbox = $('batch_prefix'); + var ml = cat.util.render_cn_prefix_menu( + g.common_ancestor_ou_ids, + [ + [ '', false ] + ] + ); + ml.setAttribute('id','batch_prefix_menulist'); + hbox.appendChild(ml); +} +g.list_suffixes = function() { + var hbox = $('batch_suffix'); + var ml = cat.util.render_cn_suffix_menu( + g.common_ancestor_ou_ids, + [ + [ '', false ] + ] + ); + ml.setAttribute('id','batch_suffix_menulist'); + hbox.appendChild(ml); +} + +g.render_batch_button = function() { + var hbox = $('batch_button_box'); + var btn = document.createElement('button'); + btn.setAttribute('id','batch_button'); + btn.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.label')); + btn.setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.accesskey')); + btn.setAttribute('image','/xul/server/skin/media/images/down_arrow.gif'); + hbox.appendChild(btn); + btn.addEventListener( + 'command', + function() { + var nl = document.getElementsByTagName('textbox'); + for (var i = 0; i < nl.length; i++) { + /* label */ + if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number && !nl[i].disabled) { + var label = $('marc_cn').firstChild.value; + if (label != '') { + nl[i].value = label; + util.widgets.dispatch('change',nl[i]); + } + } + } + nl = document.getElementsByTagName('menulist'); + for (var i = 0; i < nl.length; i++) { + /* classification */ + if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_classification && !nl[i].disabled) { + var value = $('batch_class_menulist').value; + if (!isNaN( Number(value) )) { + nl[i].value = value; + util.widgets.dispatch('command',nl[i]); + } + } + /* prefix */ + if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_prefix && !nl[i].disabled) { + var value = $('batch_prefix_menulist').value; + if (!isNaN( Number(value) )) { + nl[i].value = value; + util.widgets.dispatch('command',nl[i]); + } + } + /* suffix */ + if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_suffix && !nl[i].disabled) { + var value = $('batch_suffix_menulist').value; + if (!isNaN( Number(value) )) { + nl[i].value = value; + util.widgets.dispatch('command',nl[i]); + } + } + } + }, + false + ); +} diff --git a/Open-ILS/xul/staff_client/server/cat/volume_editor.xul b/Open-ILS/xul/staff_client/server/cat/volume_editor.xul index b6e1d584fa..33d856c814 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_editor.xul +++ b/Open-ILS/xul/staff_client/server/cat/volume_editor.xul @@ -45,17 +45,46 @@ - + - + + + + + + + + + + + + + +