Skip to content

Commit caae675

Browse files
Merge pull request #455 from dtaylor113/listview
[4.0] Fixes #433 listview actionButton class not applied properly
2 parents 99bc57b + a6607e6 commit caae675

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Bug Fixes
1414

1515
Breaking Changes
1616
- pfInlineNotification - pfNotificationRemove function added which ties the click event of the close button to a user specified function. Previously, this used to be hardcoded to use the Notifications service, this is now optional.
17+
- pfListView - If defined, actionButton class will replace 'btn-default'. Previously it was appended. (Issue #434)

Diff for: src/views/listview/list-view.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<div class="list-view-pf-actions"
3030
ng-if="($ctrl.actionButtons && $ctrl.actionButtons.length > 0) || ($ctrl.menuActions && $ctrl.menuActions.length > 0)">
31-
<button class="btn btn-default {{actionButton.class}}" ng-repeat="actionButton in $ctrl.actionButtons"
31+
<button class="btn {{actionButton.class || 'btn-default'}}" ng-repeat="actionButton in $ctrl.actionButtons"
3232
title="{{actionButton.title}}"
3333
ng-class="{'disabled' : $ctrl.checkDisabled(item) || !$ctrl.enableButtonForItem(actionButton, item)}"
3434
ng-click="$ctrl.handleButtonAction(actionButton, item)">

Diff for: test/views/listview/list-view.spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ describe('Component: pfDataList', function () {
7676
name: 'Action 2',
7777
title: 'Do something else',
7878
actionFn: performAction
79+
},
80+
{
81+
name: 'Action 3',
82+
title: 'Dangerous Action',
83+
class: 'btn-danger',
84+
actionFn: performAction
7985
}
8086
];
8187
$scope.menuActions = [
@@ -314,6 +320,15 @@ describe('Component: pfDataList', function () {
314320
expect(buttons.length).toBe(items.length * 2);
315321
});
316322

323+
it('should have the proper button class applied', function() {
324+
var items = element.find('.list-group-item');
325+
var buttons = element.find('.list-view-pf-actions .btn-danger');
326+
expect(items.length).toBe(5);
327+
expect(buttons.hasClass('btn-default')).toBe(false);
328+
expect(buttons.hasClass('btn-danger')).toBe(true);
329+
expect(buttons.length).toBe(items.length * 1);
330+
});
331+
317332
it('should disable action buttons appropriately', function () {
318333
var items = element.find('.list-group-item');
319334
var buttons = element.find('.list-view-pf-actions .btn-default');
@@ -326,6 +341,7 @@ describe('Component: pfDataList', function () {
326341
it('should call the action function with the appropriate action when an action button is clicked', function () {
327342
var items = element.find('.list-group-item');
328343
var actionButtons = element.find('.list-view-pf-actions .btn-default');
344+
var dangerButton = element.find('.list-view-pf-actions .btn-danger');
329345

330346
expect(items.length).toBe(5);
331347
expect(actionButtons.length).toBe(items.length * 2);
@@ -339,6 +355,11 @@ describe('Component: pfDataList', function () {
339355
$scope.$digest();
340356

341357
expect(performedAction.name).toBe('Action 2');
358+
359+
eventFire(dangerButton[0], 'click');
360+
$scope.$digest();
361+
362+
expect(performedAction.name).toBe('Action 3');
342363
});
343364

344365
it('should not call the action function when a disabled action button is clicked', function () {

0 commit comments

Comments
 (0)