have volume/copy creator refresh item attribute editor in unified interface
authorJason Etheridge <jason@esilibrary.com>
Wed, 23 Feb 2011 06:01:59 +0000 (01:01 -0500)
committerJason Etheridge <jason@esilibrary.com>
Wed, 2 Mar 2011 15:20:57 +0000 (10:20 -0500)
Open-ILS/xul/staff_client/server/cat/copy_editor.js
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js

index e0edef1..e36fac4 100644 (file)
@@ -2,8 +2,6 @@
 var g = {};
 g.map_acn = {};
 
-var xulG = {};
-
 function $(id) { return document.getElementById(id); }
 
 function my_init() {
@@ -166,6 +164,21 @@ function my_init() {
         g.render();
         g.check_for_unmet_required_fields();
 
+        if (xulG.unified_interface) {
+            xulG.refresh_copy_editor = function() {
+                try {
+                    g.copies = xulG.copies;
+                    g.original_copies = js2JSON( g.copies );
+                    g.summarize( g.copies );
+                    g.render();
+                    g.check_for_unmet_required_fields();
+                    document.getElementById(caption.id).focus();
+                } catch(E) {
+                    alert('Error in copy_editor.js, xulG.refresh_copy_editor(): ' + E);
+                }
+            }
+        }
+
     } catch(E) {
         var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/copy_editor.js', E]);
         try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
index 0f5a40e..07398b2 100644 (file)
@@ -358,6 +358,14 @@ g.render_barcode_entry = function(node,callnumber,count,ou_id) {
                             $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
                         setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
                     }
+                    if (xulG.unified_interface) {
+                        g.gather_copies();
+                        try {
+                            xulG.refresh_copy_editor();
+                        } catch(E) {
+                            alert('Error in volume_copy_editor.js trying to call xulG.refresh_copy_editor(): ' + E);
+                        }
+                    }
                 }, false);
                 tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
             }
@@ -404,10 +412,8 @@ g.generate_barcodes = function() {
 
 g.new_node_id = -1;
 
-g.stash_and_close = function(param) {
-
+g.gather_copies = function() {
     try {
-
         var nl = document.getElementsByTagName('textbox');
 
         var volumes_hash = {};
@@ -480,20 +486,34 @@ g.stash_and_close = function(param) {
                 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 copy;
-                    if (acp_id < 0) {
+                    var copy = g.id_copy_map[ acp_id ];
+                    if (!copy) {
                         copy = new_copy(acp_id,ou_id,acn_id,barcode);
+                        g.id_copy_map[ acp_id ] = copy;
                     } else {
-                        copy = g.id_copy_map[ acp_id ];
-                        copy.barcode( barcode );
-                        copy.call_number( acn_id );
                         copy.ischanged('1');
                     }
+                    copy.barcode( barcode );
+                    copy.call_number( acn_id );
                     copies.push( copy );
                 }
             }
         }
 
+        xulG.copies = copies;
+        return copies;
+
+    } catch(E) {
+        g.error.standard_unexpected_error_alert('Error in volume_copy_creator.js, g.gather_copies():',E);
+    }
+}
+
+g.stash_and_close = function(param) {
+
+    try {
+
+        var copies = g.gather_copies();
+
         var dont_close = false;
         JSAN.use('util.window'); var win = new util.window();
         if (copies.length > 0) {