From 0ddb53dd61deeca8cf8078c90437622ddf0256e1 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Sat, 3 Oct 2015 09:45:42 -0700 Subject: [PATCH] fix(progressbar): re-expose ProgressController - Re-expose `ProgressController` with deprecation notice --- src/progressbar/progressbar.js | 21 +++++++++++++-------- src/progressbar/test/progressbar.spec.js | 12 +++++++----- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 06fcdf5326..b8a9f563e6 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -58,7 +58,6 @@ angular.module('ui.bootstrap.progressbar', []) .directive('uibProgress', function() { return { - restrict: 'EA', replace: true, transclude: true, controller: 'UibProgressController', @@ -72,7 +71,6 @@ angular.module('ui.bootstrap.progressbar', []) .directive('uibBar', function() { return { - restrict: 'EA', replace: true, transclude: true, require: '^uibProgress', @@ -89,7 +87,6 @@ angular.module('ui.bootstrap.progressbar', []) .directive('uibProgressbar', function() { return { - restrict: 'EA', replace: true, transclude: true, controller: 'UibProgressController', @@ -111,12 +108,22 @@ angular.module('ui.bootstrap.progressbar') .value('$progressSuppressWarning', false) +.controller('ProgressController', ['$scope', '$attrs', '$controller', '$log', '$progressSuppressWarning', function($scope, $attrs, $controller, $log, $progressSuppressWarning) { + if (!$progressSuppressWarning) { + $log.warn('ProgressController is now deprecated. Use UibProgressController instead.'); + } + + angular.extend(this, $controller('UibProgressController', { + $scope: $scope, + $attrs: $attrs + })); +}]) + .directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { return { - restrict: 'EA', replace: true, transclude: true, - controller: 'UibProgressController', + controller: 'ProgressController', require: 'progress', scope: { max: '=?', @@ -133,7 +140,6 @@ angular.module('ui.bootstrap.progressbar') .directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { return { - restrict: 'EA', replace: true, transclude: true, require: '^progress', @@ -153,10 +159,9 @@ angular.module('ui.bootstrap.progressbar') .directive('progressbar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { return { - restrict: 'EA', replace: true, transclude: true, - controller: 'UibProgressController', + controller: 'ProgressController', scope: { value: '=', max: '=?', diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index 2cc88c0cc8..1ad71a92c1 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -357,11 +357,12 @@ describe('progressbar deprecation', function() { var element = $compile('{{o.value}}')($rootScope); $rootScope.$digest(); - expect($log.warn.calls.count()).toBe(4); - expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead.']); + expect($log.warn.calls.count()).toBe(5); + expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']); + expect($log.warn.calls.argsFor(1)).toEqual(['progress is now deprecated. Use uib-progress instead.']); expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead.']); expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead.']); + expect($log.warn.calls.argsFor(4)).toEqual(['bar is now deprecated. Use uib-bar instead.']); })); }); @@ -389,8 +390,9 @@ describe('progressbar deprecation', function() { var element = $compile('{{value}} %')($rootScope); $rootScope.$digest(); - expect($log.warn.calls.count()).toBe(1); - expect($log.warn.calls.argsFor(0)).toEqual(['progressbar is now deprecated. Use uib-progressbar instead.']); + expect($log.warn.calls.count()).toBe(2); + expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']); + expect($log.warn.calls.argsFor(1)).toEqual(['progressbar is now deprecated. Use uib-progressbar instead.']); })); }); });