From e933a6244c473a6cdbb646aa5c61fbde59453165 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 7 Mar 2011 07:19:55 -0500 Subject: [PATCH] render cn classification menus, and rework internal data structure to accomodate class selections --- .../staff_client/server/cat/volume_copy_creator.js | 96 ++++++++++++++++++---- 1 file changed, 82 insertions(+), 14 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 76efb96824..e9d40c39d8 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 @@ -311,14 +311,10 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) { /**** CLASSIFICATION COLUMN ****/ var classification_column_box = document.createElement('vbox'); r.appendChild(classification_column_box); - var classification_column_menulist = document.createElement('menulist'); - classification_column_box.appendChild(classification_column_menulist); /**** PREFIX COLUMN ****/ var prefix_column_box = document.createElement('vbox'); r.appendChild(prefix_column_box); - var prefix_column_menulist = document.createElement('menulist'); - prefix_column_box.appendChild(prefix_column_menulist); /**** CALLNUMBER COLUMN ****/ var call_number_column_box = document.createElement('vbox'); @@ -347,6 +343,15 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) { call_number_column_textbox.addEventListener( 'change', g.gather_copies_soon, false); call_number_column_textbox.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); + /**** CLASSIFICATION COLUMN revisited ****/ + var classification_column_menulist = g.render_class_menu(call_number_column_textbox); + classification_column_menulist.addEventListener( 'change', g.gather_copies_soon, false); + classification_column_box.appendChild(classification_column_menulist); + + /**** PREFIX COLUMN revisited ****/ + var prefix_column_menulist = document.createElement('menulist'); + prefix_column_box.appendChild(prefix_column_menulist); + /**** SUFFIX COLUMN ****/ var suffix_column_box = document.createElement('vbox'); r.appendChild(suffix_column_box); @@ -641,6 +646,27 @@ g.gather_copies = function() { var nl = document.getElementsByTagName('textbox'); var volumes_hash = {}; + /* + volumes_hash = { + '#ou_id' : { + '#callnumber label' : { + 'call_number_data' : { + 'acnc_id' : '#classification_id', + 'acnp_id' : '#prefix_id', + 'acns_id' : '#suffix_id', + }, + 'barcode_data' : + [ + { + 'barcode' : '#barcode', + 'acp_id' : '#copy_id', + 'bmp_id' : '#part_id' + }, ... + ] + } + }, ... + } + */ var barcodes = []; @@ -648,9 +674,19 @@ g.gather_copies = function() { if ( nl[i].getAttribute('rel_vert_pos') == rel_vert_pos_barcode ) barcodes.push( nl[i] ); if ( nl[i].getAttribute('rel_vert_pos') == rel_vert_pos_call_number ) { var ou_id = nl[i].getAttribute('ou_id'); + var acnc_id = nl[i].getAttribute('acnc_id'); var callnumber = nl[i].value; - if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} } - if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] } + if (typeof volumes_hash[ou_id] == 'undefined') { + volumes_hash[ou_id] = {} + } + if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { + volumes_hash[ou_id][callnumber] = { + 'call_number_data' : { + 'acnc_id' : acnc_id + }, + 'barcode_data' : [] + } + } } }; @@ -661,11 +697,18 @@ g.gather_copies = function() { var barcode = barcodes[i].value; var bmp_id = barcodes[i].getAttribute('bmp_id'); - if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} } - if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] } + if (typeof volumes_hash[ou_id] == 'undefined') { + volumes_hash[ou_id] = {} + } + if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { + volumes_hash[ou_id][callnumber] = { + 'call_number_data' : {}, + 'barcode_data' : [] + } + } if (barcode != '') { - volumes_hash[ou_id][callnumber].push( + volumes_hash[ou_id][callnumber].barcode_data.push( { 'barcode' : barcode, 'acp_id' : acp_id, @@ -714,12 +757,18 @@ g.gather_copies = function() { continue; } - volume_labels[ acn_id ] = { 'label' : cn_label, 'owning_lib' : ou_id }; + volume_labels[ acn_id ] = { + 'label' : cn_label, + 'owning_lib' : ou_id + }; + for (var i in volumes_hash[ou_id][cn_label].call_number_data) { + volume_labels[ acn_id ][ i ] = volumes_hash[ou_id][cn_label].call_number_data[i]; + } - for (var i = 0; i < volumes_hash[ou_id][cn_label].length; i++) { - var barcode = volumes_hash[ou_id][cn_label][i].barcode; - var acp_id = volumes_hash[ou_id][cn_label][i].acp_id; - var bmp_id = volumes_hash[ou_id][cn_label][i].bmp_id; + for (var i = 0; i < volumes_hash[ou_id][cn_label].barcode_data.length; i++) { + var barcode = volumes_hash[ou_id][cn_label].barcode_data[i].barcode; + var acp_id = volumes_hash[ou_id][cn_label].barcode_data[i].acp_id; + var bmp_id = volumes_hash[ou_id][cn_label].barcode_data[i].bmp_id; var copy = g.id_copy_map[ acp_id ]; if (!copy) { copy = new_copy(acp_id,ou_id,acn_id,barcode); @@ -850,6 +899,25 @@ 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() ]; + } + ) + ); + ml.addEventListener( + 'command', + function() { + call_number_tb.setAttribute('acnc_id',ml.value); + }, + false + ); + return ml; +} + g.list_callnumbers = function(doc_id, label_class) { var cn_blob; try { -- 2.11.0