[open-ils-commits] r17708 - trunk/Open-ILS/xul/staff_client/server/cat (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 15 16:09:40 EDT 2010


Author: phasefx
Date: 2010-09-15 16:09:34 -0400 (Wed, 15 Sep 2010)
New Revision: 17708

Modified:
   trunk/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
Log:
In r15732, the Volume/Copy Creator was modified to serve double-duty as a batch interface for re-barcoding existing items.  This extends that incarnation further and allows for changing the volumes for existing items as well.  In Holdings Maintenance, the entry-point for this is Actions -> Replace Barcodes.  However, it's Acquisitions that is prompting this development, and the entry point there is on the Line Item, under Actions -> Update Barcodes

Modified: trunk/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js	2010-09-15 20:09:32 UTC (rev 17707)
+++ trunk/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js	2010-09-15 20:09:34 UTC (rev 17708)
@@ -106,7 +106,7 @@
         /***********************************************************************************************************/
         /* For the call number drop down */
 
-        if (!g.copy_shortcut) {
+        if (g.existing_copies.length > 0 || !g.copy_shortcut) {
             g.list_callnumbers(g.doc_id, label_class);
         }
 
@@ -214,14 +214,16 @@
             return;
         }
 
-        //if (call_number_column_textbox.disabled || number_of_copies_column_textbox.disabled) return;
+        while (barcode_column_box.childNodes.length > Number(number_of_copies_column_textbox.value)) {
+            barcode_column_box.removeChild( barcode_column_box.lastChild );
+        }
+        g.render_barcode_entry(
+            barcode_column_box,
+            call_number_column_textbox.value,
+            Number(number_of_copies_column_textbox.value),
+            ou_id
+        );
 
-        //call_number_column_textbox.disabled = true;
-        //number_of_copies_column_textbox.disabled = true;
-
-        util.widgets.remove_children(barcode_column_box);
-
-        g.render_barcode_entry(barcode_column_box,call_number_column_textbox.value,Number(number_of_copies_column_textbox.value),ou_id);
         document.getElementById("EditThenCreate").disabled = false;
         document.getElementById("CreateWithDefaults").disabled = false;
     }
@@ -292,7 +294,9 @@
                             }
                             call_number_column_textbox.value = label; 
                             handle_change_call_number_column_textbox({'target':call_number_column_textbox});
-                            call_number_column_textbox.disabled = true;
+                            if (g.existing_copies.length < 1) {
+                                call_number_column_textbox.disabled = true;
+                            }
                         }
                     } catch(E) {
                         alert(E);
@@ -315,32 +319,40 @@
         JSAN.use('util.barcode'); 
 
         for (var i = 0; i < count; i++) {
-            var tb = document.createElement('textbox'); node.appendChild(tb);
+            var tb; var set_handlers = false;
+            if (typeof node.childNodes[i] == 'undefined') {
+                tb = document.createElement('textbox'); node.appendChild(tb);
+                set_handlers = true;
+            } else {
+                tb = node.childNodes[i];
+            }
             tb.setAttribute('ou_id',ou_id);
             tb.setAttribute('callnumber',callnumber);
             tb.setAttribute('rel_vert_pos','4');
-            if (g.org_label_existing_copy_map[ ou_id ]) {
+            if (!tb.value && g.org_label_existing_copy_map[ ou_id ]) {
                 tb.value = g.org_label_existing_copy_map[ ou_id ][ callnumber ][i].barcode();
                 tb.setAttribute('acp_id', g.org_label_existing_copy_map[ ou_id ][ callnumber ][i].id());
                 tb.select();
                 if (! g.first_focus) { g.first_focus = tb; }
             }
-            util.widgets.apply_vertical_tab_on_enter_handler( 
-                tb, 
-                function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
-            );
-            tb.addEventListener('change', function(ev) {
-                var barcode = String( ev.target.value ).replace(/\s/g,'');
-                if (barcode != ev.target.value) ev.target.value = barcode;
-                if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
-                    g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
-                        $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
-                        $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
-                        $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
-                    setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
-                }
-            }, false);
-            tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+            if (set_handlers) {
+                util.widgets.apply_vertical_tab_on_enter_handler( 
+                    tb, 
+                    function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
+                );
+                tb.addEventListener('change', function(ev) {
+                    var barcode = String( ev.target.value ).replace(/\s/g,'');
+                    if (barcode != ev.target.value) ev.target.value = barcode;
+                    if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
+                        g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
+                            $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
+                            $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
+                            $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
+                        setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
+                    }
+                }, false);
+                tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+            }
         }
         
         setTimeout( function() { if (g.first_focus) { g.first_focus.focus(); } }, 0 ); 
@@ -466,7 +478,7 @@
                     } else {
                         copy = g.id_copy_map[ acp_id ];
                         copy.barcode( barcode );
-                        copy.call_number( copy.call_number().id() );
+                        copy.call_number( acn_id );
                         copy.ischanged('1');
                     }
                     copies.push( copy );
@@ -598,7 +610,11 @@
             var nl = document.getElementsByTagName('textbox');
             for (var i = 0; i < nl.length; i++) {
                 if (nl[i].getAttribute('rel_vert_pos')==2 
-                    && !nl[i].disabled) nl[i].value = ml.value;
+                    && !nl[i].disabled) 
+                {
+                    nl[i].value = ml.value;
+                    util.widgets.dispatch('change',nl[i]);
+                }
             }
             if (g.last_focus) setTimeout( function() { g.last_focus.focus(); }, 0 );
         }, 



More information about the open-ils-commits mailing list