From d3eea8f92b4b44036688b1d68fc4c02b951d0b9e Mon Sep 17 00:00:00 2001 From: Zara Date: Sat, 23 Dec 2017 10:47:18 -0600 Subject: [PATCH] Update UI-Router This updates UI-Router to the most recent release. angular-ui-router for Angular v1 is now published as @uirouter/angularjs, so change the name to that. This commit also changes the obsolete stateChange* methods to transitions, so that the navbar will continue to work. Task: 3247 Change-Id: Ic800f437ca4412241bb3edb8a680f7e2e23beb9c --- package.json | 2 +- .../controller/application_controller.js | 4 ++-- src/app/util/directive/active_path.js | 9 +++++++-- src/index.html | 2 +- yarn.lock | 20 ++++++++++--------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 617d72b8..6e1ca9fc 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "selenium-standalone": "2.43.1-2.9.0-1" }, "dependencies": { + "@uirouter/angularjs": "^1.0.12", "angular": "1.5.8", "angular-cache": "https://github.com/jmdobry/angular-cache/archive/3.2.5.tar.gz", "angular-elastic": "https://github.com/monospaced/angular-elastic/archive/v2.4.2.tar.gz", @@ -73,7 +74,6 @@ "angular-sanitize": "1.5.8", "angular-scenario": "1.5.8", "angular-bootstrap": "0.12.2", - "angular-ui-router": "0.2.13", "angularjs-viewhead": "0.0.1", "bootstrap": "3.3.7", "font-awesome": "4.5.0", diff --git a/src/app/storyboard/controller/application_controller.js b/src/app/storyboard/controller/application_controller.js index 5e934c3d..deaad45a 100644 --- a/src/app/storyboard/controller/application_controller.js +++ b/src/app/storyboard/controller/application_controller.js @@ -19,7 +19,7 @@ * sets global scope variable accordingly. */ angular.module('storyboard').controller('ApplicationController', - function ($scope, $state, $rootScope) { + function ($scope, $state, $rootScope, $transitions) { 'use strict'; /** @@ -46,7 +46,7 @@ angular.module('storyboard').controller('ApplicationController', * Listen to changes in the state machine to trigger our submenu * scan. */ - $rootScope.$on('$stateChangeSuccess', + $transitions.onSuccess({}, function () { $scope.hasSubmenu = hasSubmenu($state.$current); }); diff --git a/src/app/util/directive/active_path.js b/src/app/util/directive/active_path.js index 9601bec5..eb576133 100644 --- a/src/app/util/directive/active_path.js +++ b/src/app/util/directive/active_path.js @@ -22,7 +22,7 @@ * @author Michael Krotscheck */ angular.module('sb.util').directive('activePath', - function ($location, $rootScope) { + function ($location, $rootScope, $transitions) { 'use strict'; return { @@ -40,7 +40,12 @@ angular.module('sb.util').directive('activePath', // binding will return a function that will disconnect // that binding. var disconnectBinding = - $rootScope.$on('$stateChangeSuccess', setActivePath); + $transitions.onSuccess({}, function setActivePath() { + var path = $location.path(); + var isMatchedPath = path.match(activePath) !== null; + + element.toggleClass('active', isMatchedPath); + }); $scope.$on('$destroy', disconnectBinding); // INIT diff --git a/src/index.html b/src/index.html index 9098836c..08ef2b71 100644 --- a/src/index.html +++ b/src/index.html @@ -31,7 +31,7 @@ - + diff --git a/yarn.lock b/yarn.lock index 13dbe5d3..8dabd394 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,16 @@ # yarn lockfile v1 +"@uirouter/angularjs@^1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@uirouter/angularjs/-/angularjs-1.0.12.tgz#b2275b7e33e0024a485f96568a18d350539880f3" + dependencies: + "@uirouter/core" "5.0.13" + +"@uirouter/core@5.0.13": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-5.0.13.tgz#e1b31626c393cbdd82651755ff1ce3fc55163fd0" + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -122,18 +132,10 @@ angular-scenario@1.5.8: version "0.12.0" resolved "https://github.com/angular-ui/bootstrap/archive/0.12.0.tar.gz#479e5c7d9ef75d6133f68143b96948f8e77136b2" -angular-ui-router@0.2.13: - version "0.2.13" - resolved "https://registry.yarnpkg.com/angular-ui-router/-/angular-ui-router-0.2.13.tgz#ab40c2f9fef9b8626ffdb29a793426c1fedd2f29" - -angular@1.5.8: +angular@1.5.8, angular@>=1.0.6: version "1.5.8" resolved "https://registry.yarnpkg.com/angular/-/angular-1.5.8.tgz#925a5392b8c212d09572dc446db7e01264e094cb" -angular@>=1.0.6: - version "1.6.7" - resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.7.tgz#0f89837dae1776b01ccb1fa2096db0d9373d9897" - angularjs-viewhead@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/angularjs-viewhead/-/angularjs-viewhead-0.0.1.tgz#31a3b0dd837eecf0bb5a7da22b6561431251c6df"