Patch from Lebbeous Fogle-Weekley to change the behavior of the "Show Item Details...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 13:33:31 +0000 (13:33 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 13:33:31 +0000 (13:33 +0000)
menu entry for patron items out, checkin, transit list, copy status, renewal, hold shelf.

Action now opens a new Item Status tab with the alternate (details) view focused by default.
Works with single or multiple copies.

TODO: no need to fetch copy details twice for the same copy

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14951 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/admin/transit_list.js
Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/renew.js
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/items.js

index 104c4c9..b04b4b8 100644 (file)
@@ -405,7 +405,16 @@ admin.transit_list.prototype = {
                     'sel_opac' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.show_in_opac(obj.selection_list); } ],
                     'sel_transit_abort' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.abort_transits(obj.selection_list); } ],
                     'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.selection_list); } ],
-                    'sel_copy_details' : [ ['command'], function() { JSAN.use('circ.util'); for (var i = 0; i < obj.selection_list.length; i++) { circ.util.show_copy_details( obj.selection_list[i].copy_id ); } } ],
+                    'sel_copy_details' : [ ['command'],
+                        function() {
+                            JSAN.use('circ.util');
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.selection_list,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
+                        } ],
                     'sel_bucket' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.add_copies_to_bucket(obj.selection_list); } ],
                     'cmd_print_list' : [ ['command'], function() { obj.print_list(0); } ],
                     'cmd_kick_off' : [ ['command'], function(ev) { ev.target.disabled = true; obj.kick_off(); } ],
index d41fe98..c895f0c 100644 (file)
@@ -161,9 +161,12 @@ circ.checkin.prototype = {
                         ['command'],
                         function() {
                             JSAN.use('circ.util');
-                            for (var i = 0; i < obj.selection_list.length; i++) {
-                                circ.util.show_copy_details( obj.selection_list[i].copy_id );
-                            }
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.selection_list,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
                         }
                     ],
                     'sel_backdate' : [
index caed154..c89dc73 100644 (file)
@@ -276,9 +276,12 @@ circ.copy_status.prototype = {
                         ['command'],
                         function() {
                             JSAN.use('circ.util');
-                            for (var i = 0; i < obj.selection_list.length; i++) {
-                                circ.util.show_copy_details( obj.selection_list[i].copy_id );
-                            }
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.selection_list,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
                         }
                     ],
                     'sel_renew' : [
@@ -1148,8 +1151,14 @@ circ.copy_status.prototype = {
                 var f = obj.browser.get_content();
                 xulG.barcode = result.copy.barcode(); // FIXME: We could pass the already-fetched data, but need to figure out how to manage that and honor Trim List, the whole point of which is to limit memory consumption
                 if (f) {
-                    f.xulG = xulG;
-                    f.load_item();
+                    if (!xulG.from_item_details_new) {
+                        /* We don't want to call load_item() in this case
+                         * because we're going to call copy_status() later
+                         * (which gets action menus populated, unlike
+                         * load_item()). */
+                        f.xulG = xulG;
+                        f.load_item();
+                    }
                 } else {
                     alert('hrmm');
                 }
index de1ccc2..4303211 100644 (file)
                     }
                 }
 
-                JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
-
-                g.barcodes = xul_param(
-                    'barcodes',{
-                        'concat' : true,
-                        'JSON2js_if_cgi' : true,
-                        'stash_name':'temp_barcodes_for_copy_status',
-                        'clear_xpcom' : true,
+                JSAN.use('OpenILS.data');
+                g.data = new OpenILS.data();
+                g.data.stash_retrieve();
+
+                if (window.xulG.barcodes && window.xulG.barcodes.length) {
+                    if (window.xulG.from_item_details_new) {
+                        // Switch item status display to "alternate view"
+                        g.copy_status.controller.control_map.cmd_alt_view[1](0);
+
+                        // This property's truthiness should not persist any
+                        // longer. Otherwise, user's won't get results if they
+                        // enter a different barcode into the Alternate View.
+                        window.xulG.from_item_details_new = false;
                     }
-                ) || [];
-                
-                if (g.barcodes.length > 0) {
+
+                    // This timeout is needed to populate the
+                    // "Actions for (Catalogers|Selected Items)" menus.
+                    // Without this, the other fields still get populated
+                    // with data about the item referred to by barcode, but
+                    // for some reason those menus don't start working.
                     JSAN.use('util.exec'); var exec = new util.exec();
                     var funcs = [];
-                    for (var i = 0; i < g.barcodes.length; i++) {
+                    for (var i = 0; i < window.xulG.barcodes.length; i++) {
                         funcs.push(
                             function(b){
                                 return function() {
                                     g.copy_status.copy_status(b);
                                 }
-                            }(g.barcodes[i])
+                            }(window.xulG.barcodes[i])
                         );
                     }
-                    exec.chain( funcs );
+                    setTimeout(function() { exec.chain(funcs); }, 1000);
+                } else {
+                    g.barcodes = xul_param(
+                        'barcodes',{
+                            'concat' : true,
+                            'JSON2js_if_cgi' : true,
+                            'stash_name':'temp_barcodes_for_copy_status',
+                            'clear_xpcom' : true,
+                        }
+                    ) || [];
+
+                    if (g.barcodes.length > 0) {
+                        JSAN.use('util.exec'); var exec = new util.exec();
+                        var funcs = [];
+                        for (var i = 0; i < g.barcodes.length; i++) {
+                            funcs.push(
+                                function(b){
+                                    return function() {
+                                        g.copy_status.copy_status(b);
+                                    }
+                                }(g.barcodes[i])
+                            );
+                        }
+                        if (window.xulG.from_item_details_new) {
+                            g.copy_status.controller.control_map.cmd_alt_view[1](0);
+                            window.xulG.from_item_details_new = false;
+                        }
+                        setTimeout(function() { exec.chain(funcs); }, 1000);
+                    }
                 }
-    
             } catch(E) {
                 var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['circ.copy_status.xul', E]);
                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
index 8410980..52b43d6 100644 (file)
@@ -158,9 +158,12 @@ circ.renew.prototype = {
                         ['command'],
                         function() {
                             JSAN.use('circ.util');
-                            for (var i = 0; i < obj.selection_list.length; i++) {
-                                circ.util.show_copy_details( obj.selection_list[i].copy_id );
-                            }
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.selection_list,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
                         }
                     ],
                     'sel_mark_items_damaged' : [
index 2a108cd..b38b2b0 100644 (file)
@@ -84,6 +84,19 @@ circ.util.show_copy_details = function(copy_id) {
     }
 };
 
+circ.util.item_details_new = function(barcodes) {
+    try {
+        var content_params = {
+            'from_item_details_new': true,
+            'barcodes': barcodes
+        };
+        xulG.new_tab(urls.XUL_COPY_STATUS, {}, content_params);
+    } catch(E) {
+        JSAN.use('util.error');
+        (new util.error()).standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
+    }
+};
+
 circ.util.backdate_post_checkin = function(circ_ids) {
     var obj = {};
     JSAN.use('util.error'); obj.error = new util.error();
index 427c197..c6fa875 100644 (file)
@@ -275,9 +275,12 @@ patron.holds.prototype = {
                         ['command'],
                         function() {
                             JSAN.use('circ.util');
-                            for (var i = 0; i < obj.retrieve_ids.length; i++) {
-                                if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id );
-                            }
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.retrieve_ids,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
                         }
                     ],
 
index dad4b09..6b5d633 100644 (file)
@@ -120,7 +120,12 @@ patron.items.prototype = {
                     'sel_copy_details' : [ ['command'],
                         function() {
                             JSAN.use('circ.util');
-                            for (var i = 0; i < obj.retrieve_ids.length; i++) { circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); }
+                            circ.util.item_details_new(
+                                util.functional.map_list(
+                                    obj.retrieve_ids,
+                                    function(o) { return o.barcode; }
+                                )
+                            );
                         }
                     ],
                     'sel_patron2' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids2); } ],