LP#838311 acn_id = undefined error in vol/copy ui
authorJason Etheridge <jason@esilibrary.com>
Wed, 31 Aug 2011 19:07:52 +0000 (15:07 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 7 Sep 2011 20:23:20 +0000 (16:23 -0400)
Fixes race condition between multiple event listeners on drop-down menus.  Bug
happened most often when batch applying values across multiple volumes and then
hitting save/create/update.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js

index aecfe20..68af8b0 100644 (file)
@@ -421,6 +421,7 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) {
         dump('\tcomposite_key = ' + callnumber_composite_key + '\n');
 
         _call_number_column_textbox.setAttribute('callkey',callnumber_composite_key);
+        //_call_number_column_textbox.setAttribute('tooltiptext',callnumber_composite_key);
         _call_number_column_textbox.setAttribute('acnc_id',acnc_id);
         _call_number_column_textbox.setAttribute('acnp_id',acnp_id);
         _call_number_column_textbox.setAttribute('acns_id',acns_id);
@@ -489,25 +490,17 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) {
                     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(
-                        'command',
-                        function() {
-                            handle_change_to_callnumber_data({'target':call_number_column_textbox});
-                        }
-                        ,false
+                    var classification_column_menulist = g.render_class_menu(
+                        call_number_column_textbox,
+                        handle_change_to_callnumber_data
                     );
                     classification_column_box.appendChild(classification_column_menulist);
                     classification_column_menulist.value = g.label_class;
 
                     /**** PREFIX COLUMN revisited ****/
-                    var prefix_column_menulist = g.render_prefix_menu(call_number_column_textbox);
-                    prefix_column_menulist.addEventListener(
-                        'command',
-                        function() {
-                            handle_change_to_callnumber_data({'target':call_number_column_textbox});
-                        }
-                        ,false
+                    var prefix_column_menulist = g.render_prefix_menu(
+                        call_number_column_textbox,
+                        handle_change_to_callnumber_data
                     );
 
                     prefix_column_box.appendChild(prefix_column_menulist);
@@ -517,13 +510,9 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) {
             suffix_column_box.setAttribute('class','cn_suffix');
             r.appendChild(suffix_column_box);
             suffix_column_box.width = $('batch_suffix').parentNode.boxObject.width;
-                var suffix_column_menulist = g.render_suffix_menu(call_number_column_textbox);
-                suffix_column_menulist.addEventListener(
-                    'command',
-                    function() {
-                        handle_change_to_callnumber_data({'target':call_number_column_textbox});
-                    }
-                    ,false
+                var suffix_column_menulist = g.render_suffix_menu(
+                    call_number_column_textbox,
+                    handle_change_to_callnumber_data
                 );
                 suffix_column_box.appendChild(suffix_column_menulist);
 
@@ -728,6 +717,7 @@ g.render_barcode_entry = function(node,callnumber_composite_key,count,ou_id) {
             }
             tb.setAttribute('ou_id',ou_id);
             tb.setAttribute('callkey',callnumber_composite_key);
+            //tb.setAttribute('tooltiptext',callnumber_composite_key);
             tb.setAttribute('rel_vert_pos',rel_vert_pos_barcode);
             part_menu.firstChild.setAttribute('rel_vert_pos',rel_vert_pos_part);
             if (!tb.value && g.org_label_existing_copy_map[ ou_id ]) {
@@ -1264,20 +1254,21 @@ g.save_prefs = function () {
     }
 }
 
-g.render_class_menu = function(call_number_tb) {
+g.render_class_menu = function(call_number_tb,update_func) {
     var ml = cat.util.render_cn_class_menu();
     ml.setAttribute('rel_vert_pos',rel_vert_pos_call_number_classification);
     ml.addEventListener(
         'command',
         function() {
             call_number_tb.setAttribute('acnc_id',ml.value);
+            update_func({'target':call_number_tb});
         },
         false
     );
     return ml;
 }
 
-g.render_prefix_menu = function(call_number_tb) {
+g.render_prefix_menu = function(call_number_tb,update_func) {
     var ou_id = call_number_tb.getAttribute('ou_id');
     var menulist = cat.util.render_cn_prefix_menu([ou_id]);
     menulist.setAttribute('rel_vert_pos',rel_vert_pos_call_number_prefix);
@@ -1285,13 +1276,14 @@ g.render_prefix_menu = function(call_number_tb) {
         'command',
         function() {
             call_number_tb.setAttribute('acnp_id',menulist.value);
+            update_func({'target':call_number_tb});
         },
         false
     );
     return menulist;
 }
 
-g.render_suffix_menu = function(call_number_tb) {
+g.render_suffix_menu = function(call_number_tb,update_func) {
     var ou_id = call_number_tb.getAttribute('ou_id');
     var menulist = cat.util.render_cn_suffix_menu([ou_id]);
     menulist.setAttribute('rel_vert_pos',rel_vert_pos_call_number_suffix);
@@ -1299,6 +1291,7 @@ g.render_suffix_menu = function(call_number_tb) {
         'command',
         function() {
             call_number_tb.setAttribute('acns_id',menulist.value);
+            update_func({'target':call_number_tb});
         },
         false
     );