modify the class and affix menus for an existing call number the _first time_ it...
authorJason Etheridge <jason@esilibrary.com>
Tue, 8 Mar 2011 18:58:07 +0000 (13:58 -0500)
committerJason Etheridge <jason@esilibrary.com>
Tue, 8 Mar 2011 18:58:07 +0000 (13:58 -0500)
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js

index 3a550de..b823f89 100644 (file)
@@ -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) );