webstaff: serials: improvements to updating address bar
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Apr 2017 21:36:56 +0000 (17:36 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Apr 2017 21:36:56 +0000 (17:36 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/serials/app.js

index 66e286d..e5eeb5a 100644 (file)
@@ -50,12 +50,20 @@ function($scope , $routeParams , $location , egSerialsCoreSvc) {
                 $location.path('/serials/' + $scope.bib_id + '/' + $scope.active_tab);
             }
         });
-        $scope.$watch('ssub.id', function(newVal, oldVal) {
-console.debug('changed?');
-            if (oldVal != newVal) {
-                $location.path('/serials/' + $scope.bib_id + '/' + $scope.active_tab +
-                               '/' + $scope.ssub.id);
-            }
-        });
     }
+    $scope.$watch('ssub.id', function(newVal, oldVal) {
+        if (oldVal != newVal) {
+            $location.path('/serials/' + $scope.bib_id + '/' + $scope.active_tab +
+                           '/' + $scope.ssub.id);
+        }
+    });
+    $scope.$watch('active_tab', function(newVal, oldVal) {
+        if (oldVal != newVal) {
+                var new_path = '/serials/' + $scope.bib_id + '/' + $scope.active_tab;
+                if ($scope.ssub.id && $scope.active_tab != 'manage-subscriptions') {
+                    new_path += '/' + $scope.ssub.id;
+                }
+                $location.path(new_path);
+        }
+    });
 }])