From 1ae62cde052b6d22c97e4a678df6b803f1622c85 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 4 Jul 2017 16:17:33 -0700 Subject: [PATCH] [Browse] Don't klobber params when preventing default When browse controller is hijacking a browser navigation event, it calls preventDefault on the route change. This has the effect of preventing all changes in the location (including search changes). This change checks if other changes were made in the route change and re-applies them after the navigation has completed. Fixes a bug where navigating via a link that contained additional search paramterers would have the effect of navigating but not keeping the parameters in tact. Discovered in the course of fixing #1636 --- .../commonUI/browse/src/BrowseController.js | 24 +++++++++++++++---- src/adapter/runs/TimeSettingsURLHandler.js | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index ee7df5719a..4a81197266 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -25,8 +25,8 @@ * @namespace platform/commonUI/browse */ define( - [], - function () { + ['lodash'], + function (_) { /** * The BrowseController is used to populate the initial scope in Browse @@ -157,12 +157,28 @@ define( // (e.g. bookmarks to pages in OpenMCT) and prevent them. Instead, // navigate to the path ourselves, which results in it being // properly set. - $scope.$on('$routeChangeStart', function (event, route) { + $scope.$on('$routeChangeStart', function (event, route, oldRoute) { if (route.$$route === $route.current.$$route) { if (route.pathParams.ids && route.pathParams.ids !== $route.current.pathParams.ids) { + + var otherParams = _.omit(route.params, 'ids'); + var oldOtherParams = _.omit(oldRoute.params, 'ids'); + var deletedParams = _.omit(oldOtherParams, _.keys(otherParams)); + event.preventDefault(); - navigateToPath(route.pathParams.ids.split('/')); + + navigateToPath(route.pathParams.ids.split('/')) + .then(function () { + if (!_.isEqual(otherParams, oldOtherParams)) { + _.forEach(otherParams, function (v, k) { + $location.search(k, v); + }); + _.forEach(deletedParams, function (k) { + $location.search(k, null); + }); + } + }); } else { navigateToPath([]); } diff --git a/src/adapter/runs/TimeSettingsURLHandler.js b/src/adapter/runs/TimeSettingsURLHandler.js index f97165ff1e..b50807866e 100644 --- a/src/adapter/runs/TimeSettingsURLHandler.js +++ b/src/adapter/runs/TimeSettingsURLHandler.js @@ -107,7 +107,7 @@ define([ } this.last = params; - if (params.bounds) { + if (params.clock === 'fixed' && params.bounds) { if (!this.time.timeSystem() || this.time.timeSystem().key !== params.timeSystem) {