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

fix(progress): rename to avoid conflict #4255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/progressbar/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ <h3>Dynamic <button type="button" class="btn btn-sm btn-primary" ng-click="rando

<hr />
<h3>Stacked <button type="button" class="btn btn-sm btn-primary" ng-click="randomStacked()">Randomize</button></h3>
<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>
<ui-progress><ui-bar ng-repeat="bar in stacked track by $index" value="bar.value" type="{{bar.type}}"><span ng-hide="bar.value < 5">{{bar.value}}%</span></ui-bar></ui-progress>

</div>
6 changes: 3 additions & 3 deletions src/progressbar/docs/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
A progress bar directive that is focused on providing feedback on the progress of a workflow or action.

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

### Settings ###

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

### Stacked ###

Place multiple `<bars>` into the same `<progress>` element to stack them.
`<progress>` supports `max` and `animate` & `<bar>` supports `value` and `type` attributes.
Place multiple `<ui-bar>`s into the same `<ui-progress>` element to stack them.
`<ui-progress>` supports `max` and `animate` & `<ui-bar>` supports `value` and `type` attributes.
47 changes: 44 additions & 3 deletions src/progressbar/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ angular.module('ui.bootstrap.progressbar', [])
max: 100
})

.value('$progressSuppressWarning', false)

.controller('ProgressController', ['$scope', '$attrs', 'progressConfig', function($scope, $attrs, progressConfig) {
var self = this,
animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
Expand Down Expand Up @@ -55,7 +57,7 @@ angular.module('ui.bootstrap.progressbar', [])
});
}])

.directive('progress', function() {
.directive('uiProgress', function() {
return {
restrict: 'EA',
replace: true,
Expand All @@ -69,12 +71,31 @@ angular.module('ui.bootstrap.progressbar', [])
};
})

.directive('bar', function() {
.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
return {
restrict: 'EA',
replace: true,
transclude: true,
require: '^progress',
controller: 'ProgressController',
require: 'progress',
scope: {
max: '=?'
},
templateUrl: 'template/progressbar/progress.html',
link: function() {
if ($progressSuppressWarning) {
$log.warn('progress is now deprecated. Use ui-progress instead');
}
}
};
}])

.directive('uiBar', function() {
return {
restrict: 'EA',
replace: true,
transclude: true,
require: '^uiProgress',
scope: {
value: '=',
type: '@'
Expand All @@ -86,6 +107,26 @@ angular.module('ui.bootstrap.progressbar', [])
};
})

.directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
return {
restrict: 'EA',
replace: true,
transclude: true,
require: '^progress',
scope: {
value: '=',
type: '@'
},
templateUrl: 'template/progressbar/bar.html',
link: function(scope, element, attrs, progressCtrl) {
if ($progressSuppressWarning) {
$log.warn('bar is now deprecated. Use ui-bar instead');
}
progressCtrl.addBar(scope, element);
}
};
}])

.directive('progressbar', function() {
return {
restrict: 'EA',
Expand Down
49 changes: 47 additions & 2 deletions src/progressbar/test/progressbar.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
describe('progressbar directive', function() {
describe('$progressSuppressWarning', function() {
beforeEach(module('ui.bootstrap.progressbar'));
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html'));

it('should give warning', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

$rootScope.objects = [
{ value: 10, type: 'success' },
{ value: 50, type: 'warning' },
{ value: 20 }
];
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(0);
}));

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$progressSuppressWarning', true);
});

inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

$rootScope.objects = [
{ value: 10, type: 'success' },
{ value: 50, type: 'warning' },
{ value: 20 }
];
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 ui-progress instead']);
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use ui-bar instead']);
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use ui-bar instead']);
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use ui-bar instead']);
});
});
});
});

describe('progressbar directive', function() {
var $rootScope, $compile, element;
beforeEach(module('ui.bootstrap.progressbar'));
Expand Down Expand Up @@ -156,7 +201,7 @@ describe('progressbar directive', function() {
{ value: 50, type: 'warning' },
{ value: 20 }
];
element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
element = $compile('<ui-progress animate="false"><ui-bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</ui-bar></ui-progress>')($rootScope);
$rootScope.$digest();
}));

Expand Down Expand Up @@ -219,7 +264,7 @@ describe('progressbar directive', function() {
describe('"max" attribute', function() {
beforeEach(inject(function() {
$rootScope.max = 200;
element = $compile('<progress max="max" animate="false"><bar ng-repeat="o in objects" value="o.value">{{o.value}}/{{max}}</bar></progress>')($rootScope);
element = $compile('<ui-progress max="max" animate="false"><ui-bar ng-repeat="o in objects" value="o.value">{{o.value}}/{{max}}</ui-bar></ui-progress>')($rootScope);
$rootScope.$digest();
}));

Expand Down