Do not change the tab on iframe changes when using the summary bar buttons
authorMike Rylander <mrylander@gmail.com>
Thu, 12 Mar 2015 14:39:08 +0000 (10:39 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 8 Jul 2015 18:12:02 +0000 (14:12 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 64d4efd..0648d75 100644 (file)
@@ -130,9 +130,11 @@ function($scope , $routeParams , $location , $q , egCore , egHolds,
 
     // will hold a ref to the opac iframe
     $scope.opac_iframe = null;
+    $scope.in_opac_call = false;
     $scope.opac_call = function (opac_frame_function, force_opac_tab) {
         if ($scope.opac_iframe) {
             if (force_opac_tab) $scope.record_tab = 'catalog';
+            $scope.in_opac_call = true;
             $scope.opac_iframe.contentWindow[opac_frame_function]();
         }
     }
@@ -166,21 +168,24 @@ function($scope , $routeParams , $location , $q , egCore , egHolds,
         if (match) {
             $scope.record_id = match[1];
             egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
-
-            // force the record_id to show up in the page.  
-            // not sure why a $digest isn't occuring here.
-            try { $scope.$apply() } catch(E) {}
         } else {
             delete $scope.record_id;
         }
 
-        if ($scope.record_id) {
-            var default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
-            tab = $routeParams.record_tab || default_tab || 'catalog';
+        // child scope is executing this function, so our digest doesn't fire ... thus,
+        $scope.$apply();
+
+        if (!$scope.in_opac_call) {
+            if ($scope.record_id) {
+                var default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
+                tab = $routeParams.record_tab || default_tab || 'catalog';
+            } else {
+                tab = $routeParams.record_tab || 'catalog';
+            }
+            $scope.set_record_tab(tab);
         } else {
-            tab = $routeParams.record_tab || 'catalog';
+            $scope.in_opac_call = false;
         }
-        $scope.set_record_tab(tab);
     }
 
     // xulG catalog handlers