From 645bb564dd1458331d570b9b97d85e859542ff57 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Tue, 8 Mar 2011 13:58:07 -0500 Subject: [PATCH] modify the class and affix menus for an existing call number the _first time_ it is loaded in the interface. some other minor code cleanup --- .../staff_client/server/cat/volume_copy_creator.js | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) 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 3a550de2cb..b823f89899 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 @@ -142,7 +142,6 @@ function my_init() { var rows = document.getElementById('rows'); - var node_id = 0; for (var i = 0; i < ou_ids.length; i++) { try { var org = g.data.hash.aou[ ou_ids[i] ]; @@ -642,7 +641,7 @@ g.gather_copies_soon = function() { ); } -g.new_node_id = -1; +g.new_acp_id = -1; g.gather_copies = function() { try { @@ -686,8 +685,8 @@ g.gather_copies = function() { } if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = { + 'node' : nl[i], 'call_number_data' : { - 'node' : nl[i], 'acnc_id' : acnc_id, 'acnp_id' : acnp_id, 'acns_id' : acns_id @@ -699,7 +698,7 @@ g.gather_copies = function() { }; for (var i = 0; i < barcodes.length; i++) { - var acp_id = barcodes[i].getAttribute('acp_id') || g.new_node_id--; + var acp_id = barcodes[i].getAttribute('acp_id') || g.new_acp_id--; var ou_id = barcodes[i].getAttribute('ou_id'); var callnumber = barcodes[i].getAttribute('callnumber'); var barcode = barcodes[i].value; @@ -767,6 +766,7 @@ g.gather_copies = function() { continue; } + var existed_and_first_load = acn_blob.existed; var acn_id = acn_blob.acn_id; var my_acn; @@ -780,33 +780,45 @@ g.gather_copies = function() { continue; } g.acn_map[ acn_id ] = my_acn; + } else { + existed_and_first_load = false; } my_acn = g.acn_map[ acn_id ]; volume_data[ acn_id ] = { 'label' : cn_label, - 'owning_lib' : ou_id, - 'existed' : acn_blob.existed + 'owning_lib' : ou_id }; for (var i in volumes_hash[ou_id][cn_label].call_number_data) { volume_data[ acn_id ][ i ] = volumes_hash[ou_id][cn_label].call_number_data[i]; } - if (volume_data[ acn_id ][ 'acnc_id' ]) { + var node = volumes_hash[ou_id][cn_label].node; + var class_menulist = node.parentNode.previousSibling.previousSibling.firstChild; + var prefix_menulist = node.parentNode.previousSibling.firstChild; + var suffix_menulist = node.parentNode.nextSibling.firstChild; + + if (existed_and_first_load) { + class_menulist.value = my_acn.label_class(); + } else if (volume_data[ acn_id ][ 'acnc_id' ]) { var new_value = volume_data[ acn_id ][ 'acnc_id' ]; if (Number(my_acn.label_class()) != Number(new_value)) { my_acn.label_class( Number(new_value) ); my_acn.ischanged( get_db_true() ); } } - if (volume_data[ acn_id ][ 'ancp_id' ]) { - var new_value = volume_data[ acn_id ][ 'ancp_id' ]; + if (existed_and_first_load) { + prefix_menulist.value = my_acn.prefix(); + } else if (volume_data[ acn_id ][ 'acnp_id' ]) { + var new_value = volume_data[ acn_id ][ 'acnp_id' ]; if (Number(my_acn.prefix()) != Number(new_value)) { my_acn.prefix( Number(new_value) ); my_acn.ischanged( get_db_true() ); } } - if (volume_data[ acn_id ][ 'acns_id' ]) { + if (existed_and_first_load) { + suffix_menulist.value = my_acn.suffix(); + } else if (volume_data[ acn_id ][ 'acns_id' ]) { var new_value = volume_data[ acn_id ][ 'acns_id' ]; if (Number(my_acn.suffix()) != Number(new_value)) { my_acn.suffix( Number(new_value) ); -- 2.11.0