Skip to content

Commit 6cb03b9

Browse files
Use _.where when searching for existing filters
1 parent 23eea7b commit 6cb03b9

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

dist/angular-patternfly.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,13 +1730,8 @@ angular.module('patternfly.filters').directive('pfSimpleFilter',
17301730
templateUrl: 'filters/simple-filter.html',
17311731
controller: ["$scope", function ($scope) {
17321732
$scope.filterExists = function (filter) {
1733-
var found = false;
1734-
$scope.config.appliedFilters.forEach(function (nextFilter) {
1735-
if (nextFilter.title === filter.title && nextFilter.value === filter.value) {
1736-
found = true;
1737-
}
1738-
});
1739-
return found;
1733+
var foundFilter = _.findWhere($scope.config.appliedFilters, {title: filter.title, value: filter.value});
1734+
return foundFilter !== undefined;
17401735
};
17411736

17421737
$scope.addFilter = function (field, value) {
@@ -4031,13 +4026,8 @@ angular.module('patternfly.views').directive('pfDataToolbar',
40314026
};
40324027

40334028
$scope.filterExists = function (filter) {
4034-
var found = false;
4035-
$scope.config.filterConfig.appliedFilters.forEach(function (nextFilter) {
4036-
if (nextFilter.title === filter.title && nextFilter.value === filter.value) {
4037-
found = true;
4038-
}
4039-
});
4040-
return found;
4029+
var foundFilter = _.findWhere($scope.config.filterConfig.appliedFilters, {title: filter.title, value: filter.value});
4030+
return foundFilter !== undefined;
40414031
};
40424032

40434033
$scope.addFilter = function (field, value) {

dist/angular-patternfly.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/filters/simple-filter-directive.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,8 @@ angular.module('patternfly.filters').directive('pfSimpleFilter',
180180
templateUrl: 'filters/simple-filter.html',
181181
controller: function ($scope) {
182182
$scope.filterExists = function (filter) {
183-
var found = false;
184-
$scope.config.appliedFilters.forEach(function (nextFilter) {
185-
if (nextFilter.title === filter.title && nextFilter.value === filter.value) {
186-
found = true;
187-
}
188-
});
189-
return found;
183+
var foundFilter = _.findWhere($scope.config.appliedFilters, {title: filter.title, value: filter.value});
184+
return foundFilter !== undefined;
190185
};
191186

192187
$scope.addFilter = function (field, value) {

src/views/toolbar/data-toolbar-directive.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,8 @@ angular.module('patternfly.views').directive('pfDataToolbar',
233233
};
234234

235235
$scope.filterExists = function (filter) {
236-
var found = false;
237-
$scope.config.filterConfig.appliedFilters.forEach(function (nextFilter) {
238-
if (nextFilter.title === filter.title && nextFilter.value === filter.value) {
239-
found = true;
240-
}
241-
});
242-
return found;
236+
var foundFilter = _.findWhere($scope.config.filterConfig.appliedFilters, {title: filter.title, value: filter.value});
237+
return foundFilter !== undefined;
243238
};
244239

245240
$scope.addFilter = function (field, value) {

0 commit comments

Comments
 (0)