Skip to content

Commit b828a11

Browse files
Merge pull request #481 from AllenBW/bug/480-incorrectly-showing-filter-selected-results
Hides selected filter results unless selected&totalCount !== undefined
2 parents 70c5028 + 110caab commit b828a11

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/filters/filter-results-component.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ angular.module('patternfly.filters').component('pfFilterResults', {
6363
if (ctrl.config.resultsCount === undefined) {
6464
ctrl.config.resultsCount = 0;
6565
}
66-
if (ctrl.config.selectedCount === undefined) {
67-
ctrl.config.selectedCount = 0;
68-
}
69-
if (ctrl.config.totalCount === undefined) {
70-
ctrl.config.totalCount = 0;
71-
}
7266
}
7367

7468
function clearFilter (item) {

src/filters/filter-results.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h5>{{$ctrl.config.resultsCount}} Results</h5>
1212
</li>
1313
</ul>
1414
<p><a class="clear-filters" ng-click="$ctrl.clearAllFilters()" ng-if="$ctrl.config.appliedFilters.length > 0">Clear All Filters</a></p>
15-
<div ng-if="$ctrl.config.totalCount !== 0" class="pf-table-view-selected-label">
15+
<div ng-if="$ctrl.config.selectedCount !== undefined && $ctrl.config.totalCount !== undefined" class="pf-table-view-selected-label">
1616
<strong>{{$ctrl.config.selectedCount}}</strong> of <strong>{{$ctrl.config.totalCount}}</strong> selected
1717
</div>
1818
</div><!-- /col -->

test/filters/filter.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,20 @@ describe('Directive: pfFilter', function () {
159159
expect(activeFilters.length).toBe(0);
160160
expect(clearButtons.length).toBe(0);
161161
});
162-
})
162+
163+
it('should not show selected results when selectedCount and totalCount are undefined', function() {
164+
$scope.filterConfig.selectedCount = undefined;
165+
$scope.filterConfig.totalCount = undefined;
166+
$scope.$digest();
167+
168+
expect(element.find('.pf-table-view-selected-label').length).toBe(0);
169+
});
170+
171+
it('should show selected results and totalCount are defined', function() {
172+
$scope.filterConfig.selectedCount = 0;
173+
$scope.filterConfig.totalCount = 10;
174+
$scope.$digest();
175+
176+
expect(element.find('.pf-table-view-selected-label').text()).toContain('0 of 10 selected');
177+
});
178+
});

0 commit comments

Comments
 (0)