From: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Date: Fri, 9 Mar 2012 17:10:20 +0000 (-0500)
Subject: Alt Serial Control interfaces and Batch Receive reload OPAC when possible
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f5838ec4eb32121fc8dc3ebaafd342f63f8bbd22;p=evergreen%2Fmasslnc.git

Alt Serial Control interfaces and Batch Receive reload OPAC when possible

Really, since the Alt Serial Control interfaces are built on AutoGrid,
all we have to do there is teach AutoGrid (and its constituent EditPane)
to try for reload_opac on write operations.

This may cause more reloads of the OPAC than are truly necessary, but
mainly in cases when nobody's looking because the OPAC is hidden away
in another tab.  That's preferable to the alternative of littering the
codebase with dozens of instances of
    try { xulG.reload_opac(); } catch (E) { }
which would just be ugly, bad and unmaintainable.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---

diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
index 9210b367b1..69df9a7494 100644
--- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
+++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
@@ -346,6 +346,12 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                         new openils.PermaCrud()['eliminate'](fmObject, {oncomplete : function(r) { self.store.deleteItem(item) }});
                     }
                 );
+
+                try {
+                    xulG.reload_opac();
+                } catch (E) {
+                    (dump ? dump : console.log)(E);
+                }
             },
 
             _formatRowSelectInput : function(rowIdx) {
diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js
index 1fd41adb75..7587251fba 100644
--- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js
+++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js
@@ -253,6 +253,14 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 } else {
                     (new openils.PermaCrud())[this.mode](this.fmObject, opts);
                 }
+
+                /* If we happen to have been spawned by something that
+                 * puts an reload_opac() function into our context, call it. */
+                try {
+                    xulG.reload_opac();
+                } catch(E) {
+                    (dump ? dump : console.log)(E);
+                }
             }
         }
     );
diff --git a/Open-ILS/web/js/ui/default/serial/subscription.js b/Open-ILS/web/js/ui/default/serial/subscription.js
index 24298363aa..d3e3d4b2ea 100644
--- a/Open-ILS/web/js/ui/default/serial/subscription.js
+++ b/Open-ILS/web/js/ui/default/serial/subscription.js
@@ -217,6 +217,10 @@ function _clone_subscription(bre_id) {
                     location.href =
                         oilsBasePath + "/serial/subscription?id=" + r;
                 }
+
+                /* cloning doesn't clone holdings, so nothing changes at
+                 * OPAC view just because of this, so no need to try
+                 * reload_opac().  */
             }
         }
     );
diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
index d1e0d02767..d0657a92cb 100644
--- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
+++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
@@ -355,7 +355,10 @@ function open_alt_serial_mgmt() {
             "authtime": ses("authtime"),
             "show_nav_buttons": true,
             "no_xulG": false,
-            "show_print_button": false
+            "show_print_button": false,
+            "passthru_content_params": {
+                "reload_opac": xulG.reload_opac
+            }
         };
 
         ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
diff --git a/Open-ILS/xul/staff_client/server/serial/batch_receive.js b/Open-ILS/xul/staff_client/server/serial/batch_receive.js
index 503a2ec770..433843cc8a 100644
--- a/Open-ILS/xul/staff_client/server/serial/batch_receive.js
+++ b/Open-ILS/xul/staff_client/server/serial/batch_receive.js
@@ -1063,6 +1063,11 @@ function BatchReceiver() {
                         alert(E);
                     }
                     busy(false);
+                    try {
+                        xulG.reload_opac();
+                    } catch(E) {
+                        (dump ? dump : console.log)(E);
+                    }
                 }
             }
         );