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

Commit 07a938d

Browse files
committed
fix(progress): rename to avoid conflict
- Rename to `ui-progress` and `ui-bar` Closes #4255
1 parent 7d3ba1e commit 07a938d

File tree

4 files changed

+96
-10
lines changed

4 files changed

+96
-10
lines changed

src/progressbar/docs/demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ <h3>Dynamic <button type="button" class="btn btn-sm btn-primary" ng-click="rando
1919

2020
<hr />
2121
<h3>Stacked <button type="button" class="btn btn-sm btn-primary" ng-click="randomStacked()">Randomize</button></h3>
22-
<progress><bar ng-repeat="bar in stacked track by $index" value="bar.value" type="{{bar.type}}"><span ng-hide="bar.value < 5">{{bar.value}}%</span></bar></progress>
22+
<uib-progress><uib-bar ng-repeat="bar in stacked track by $index" value="bar.value" type="{{bar.type}}"><span ng-hide="bar.value < 5">{{bar.value}}%</span></uib-bar></uib-progress>
2323

2424
</div>

src/progressbar/docs/readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
A progress bar directive that is focused on providing feedback on the progress of a workflow or action.
22

3-
It supports multiple (stacked) bars into the same `<progress>` element or a single `<progressbar>` elemtnt with optional `max` attribute and transition animations.
3+
It supports multiple (stacked) bars into the same `<ui-progress>` element or a single `<progressbar>` elemtnt with optional `max` attribute and transition animations.
44

55
### Settings ###
66

@@ -25,5 +25,5 @@ It supports multiple (stacked) bars into the same `<progress>` element or a sing
2525

2626
### Stacked ###
2727

28-
Place multiple `<bars>` into the same `<progress>` element to stack them.
29-
`<progress>` supports `max` and `animate` & `<bar>` supports `value` and `type` attributes.
28+
Place multiple `<uib-bar>`s into the same `<uib-progress>` element to stack them.
29+
`<uib-progress>` supports `max` and `animate` & `<uib-bar>` supports `value` and `type` attributes.

src/progressbar/progressbar.js

+45-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ angular.module('ui.bootstrap.progressbar', [])
55
max: 100
66
})
77

8+
.value('$progressSuppressWarning', false)
9+
810
.controller('ProgressController', ['$scope', '$attrs', 'progressConfig', function($scope, $attrs, progressConfig) {
911
var self = this,
1012
animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
@@ -55,26 +57,45 @@ angular.module('ui.bootstrap.progressbar', [])
5557
});
5658
}])
5759

58-
.directive('progress', function() {
60+
.directive('uibProgress', function() {
5961
return {
6062
restrict: 'EA',
6163
replace: true,
6264
transclude: true,
6365
controller: 'ProgressController',
64-
require: 'progress',
66+
require: 'uibProgress',
6567
scope: {
6668
max: '=?'
6769
},
6870
templateUrl: 'template/progressbar/progress.html'
6971
};
7072
})
7173

72-
.directive('bar', function() {
74+
.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
7375
return {
7476
restrict: 'EA',
7577
replace: true,
7678
transclude: true,
77-
require: '^progress',
79+
controller: 'ProgressController',
80+
require: 'progress',
81+
scope: {
82+
max: '=?'
83+
},
84+
templateUrl: 'template/progressbar/progress.html',
85+
link: function() {
86+
if ($progressSuppressWarning) {
87+
$log.warn('progress is now deprecated. Use uib-progress instead');
88+
}
89+
}
90+
};
91+
}])
92+
93+
.directive('uibBar', function() {
94+
return {
95+
restrict: 'EA',
96+
replace: true,
97+
transclude: true,
98+
require: '^uibProgress',
7899
scope: {
79100
value: '=',
80101
type: '@'
@@ -86,6 +107,26 @@ angular.module('ui.bootstrap.progressbar', [])
86107
};
87108
})
88109

110+
.directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
111+
return {
112+
restrict: 'EA',
113+
replace: true,
114+
transclude: true,
115+
require: '^progress',
116+
scope: {
117+
value: '=',
118+
type: '@'
119+
},
120+
templateUrl: 'template/progressbar/bar.html',
121+
link: function(scope, element, attrs, progressCtrl) {
122+
if ($progressSuppressWarning) {
123+
$log.warn('bar is now deprecated. Use uib-bar instead');
124+
}
125+
progressCtrl.addBar(scope, element);
126+
}
127+
};
128+
}])
129+
89130
.directive('progressbar', function() {
90131
return {
91132
restrict: 'EA',

src/progressbar/test/progressbar.spec.js

+47-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
describe('progressbar directive', function() {
2+
describe('$progressSuppressWarning', function() {
3+
beforeEach(module('ui.bootstrap.progressbar'));
4+
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html'));
5+
6+
it('should give warning', inject(function($compile, $log, $rootScope) {
7+
spyOn($log, 'warn');
8+
9+
$rootScope.objects = [
10+
{ value: 10, type: 'success' },
11+
{ value: 50, type: 'warning' },
12+
{ value: 20 }
13+
];
14+
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
15+
$rootScope.$digest();
16+
17+
expect($log.warn.calls.count()).toBe(0);
18+
}));
19+
20+
it('should suppress warning', function() {
21+
module(function($provide) {
22+
$provide.value('$progressSuppressWarning', true);
23+
});
24+
25+
inject(function($compile, $log, $rootScope) {
26+
spyOn($log, 'warn');
27+
28+
$rootScope.objects = [
29+
{ value: 10, type: 'success' },
30+
{ value: 50, type: 'warning' },
31+
{ value: 20 }
32+
];
33+
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
34+
$rootScope.$digest();
35+
36+
expect($log.warn.calls.count()).toBe(4);
37+
expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead']);
38+
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead']);
39+
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead']);
40+
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead']);
41+
});
42+
});
43+
});
44+
});
45+
146
describe('progressbar directive', function() {
247
var $rootScope, $compile, element;
348
beforeEach(module('ui.bootstrap.progressbar'));
@@ -156,7 +201,7 @@ describe('progressbar directive', function() {
156201
{ value: 50, type: 'warning' },
157202
{ value: 20 }
158203
];
159-
element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
204+
element = $compile('<uib-progress animate="false"><uib-bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</uib-bar></uib-progress>')($rootScope);
160205
$rootScope.$digest();
161206
}));
162207

@@ -219,7 +264,7 @@ describe('progressbar directive', function() {
219264
describe('"max" attribute', function() {
220265
beforeEach(inject(function() {
221266
$rootScope.max = 200;
222-
element = $compile('<progress max="max" animate="false"><bar ng-repeat="o in objects" value="o.value">{{o.value}}/{{max}}</bar></progress>')($rootScope);
267+
element = $compile('<uib-progress max="max" animate="false"><uib-bar ng-repeat="o in objects" value="o.value">{{o.value}}/{{max}}</uib-bar></uib-progress>')($rootScope);
223268
$rootScope.$digest();
224269
}));
225270

0 commit comments

Comments
 (0)