Alt Serial Control interfaces and Batch Receive reload OPAC when possible
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 9 Mar 2012 17:10:20 +0000 (12:10 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 23 Mar 2012 20:30:29 +0000 (16:30 -0400)
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>

Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js
Open-ILS/web/js/ui/default/serial/subscription.js
Open-ILS/xul/staff_client/chrome/content/cat/opac.js
Open-ILS/xul/staff_client/server/serial/batch_receive.js

index 9210b36..69df9a7 100644 (file)
@@ -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) {
index 1fd41ad..7587251 100644 (file)
@@ -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);
+                }
             }
         }
     );
index 2429836..d3e3d4b 100644 (file)
@@ -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().  */
             }
         }
     );
index d1e0d02..d0657a9 100644 (file)
@@ -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",
index 503a2ec..433843c 100644 (file)
@@ -1063,6 +1063,11 @@ function BatchReceiver() {
                         alert(E);
                     }
                     busy(false);
+                    try {
+                        xulG.reload_opac();
+                    } catch(E) {
+                        (dump ? dump : console.log)(E);
+                    }
                 }
             }
         );