Skip to content

Commit

Permalink
Merge pull request angular-ui#753 from apexclearing/search_provider_n…
Browse files Browse the repository at this point in the history
…ested_objs

Update searchProvider to look for values in properties that come after the first object
  • Loading branch information
roblarsen committed Nov 19, 2013
2 parents 06275bd + b83ac05 commit 65d7eba
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/classes/searchProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
}
var pVal = item[prop];
if(typeof pVal === 'object'){
return searchEntireRow(condition, pVal, c);
result = searchEntireRow(condition, pVal, c);
if (result) {
return true;
}
} else {
var f = null,
s = null;
Expand Down
45 changes: 43 additions & 2 deletions test/unit/directivesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,49 @@ describe('directives', function () {
});
});
describe('searchProvider', function () {
it('should do something', function () {
//add work here
beforeEach(inject(function ($rootScope, $domUtilityService, $templateCache, $compile) {
$scope = $rootScope.$new();
$dUtils = $domUtilityService;
$linker = $compile;
$cache = $templateCache;

elm = angular.element(
'<div ng-grid="gridOptions" style="width: 1000px; height: 1000px"></div>'
);
scope = $rootScope;

scope.filterOptions = {
filterText: ''
};

scope.myData = [{name: "Moroni", obj1: {age: 50}, obj2: {grade: 'one'} },
{name: "Tiancum", obj1: {age: 43}, obj2: {grade: 'two'} },
{name: "Jacob", obj1: {age: 27}, obj2: {grade: 'three'} },
{name: "Nephi", obj1: {age: 29}, obj2: {grade: 'four'} },
{name: "Enos", obj1: {age: 34}, obj2: {grade: 'five'} }];

scope.gridOptions = {
data: 'myData',
filterOptions: scope.filterOptions,
showFooter: true,
columnDefs: [
{ field: 'name' },
{ field: 'obj1.age' },
{ field: 'obj2.grade' }
]
};

$compile(elm)(scope);
scope.$digest();
}));

it('should find values in properties that come after the first object', function() {
expect(elm.find('.ngFooterTotalItems').text()).toContain(5);

// Enter search text
scope.filterOptions.filterText = 'two';
scope.$digest();
expect(elm.find('.ngFooterTotalItems').text()).toContain('Showing Items: 1');
});
});
describe('selectionProvider', function () {
Expand Down

0 comments on commit 65d7eba

Please sign in to comment.