Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(progressbar): re-expose ProgressController
Browse files Browse the repository at this point in the history
- Re-expose `ProgressController` with deprecation notice

Closes #4528
  • Loading branch information
wesleycho committed Oct 3, 2015
1 parent 92ab48e commit 5604e59
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
21 changes: 13 additions & 8 deletions src/progressbar/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ angular.module('ui.bootstrap.progressbar', [])

.directive('uibProgress', function() {
return {
restrict: 'EA',
replace: true,
transclude: true,
controller: 'UibProgressController',
Expand All @@ -72,7 +71,6 @@ angular.module('ui.bootstrap.progressbar', [])

.directive('uibBar', function() {
return {
restrict: 'EA',
replace: true,
transclude: true,
require: '^uibProgress',
Expand All @@ -89,7 +87,6 @@ angular.module('ui.bootstrap.progressbar', [])

.directive('uibProgressbar', function() {
return {
restrict: 'EA',
replace: true,
transclude: true,
controller: 'UibProgressController',
Expand All @@ -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: '=?',
Expand All @@ -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',
Expand All @@ -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: '=?',
Expand Down
12 changes: 7 additions & 5 deletions src/progressbar/test/progressbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,12 @@ describe('progressbar deprecation', function() {
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($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.']);
}));
});

Expand Down Expand Up @@ -389,8 +390,9 @@ describe('progressbar deprecation', function() {
var element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($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.']);
}));
});
});

0 comments on commit 5604e59

Please sign in to comment.