Skip to content

Commit

Permalink
fix(NgTableParams): filterDelay too high
Browse files Browse the repository at this point in the history
Trying to get a reasonable balance between responsiveness and not wasting calls to a server.

A better approach would be for a filter template to be able to specify a filter delay and this be used
in an ngModelOptions. That would allow a template like a select to not delay at all whilst a text
input to add a delay for typical typing speeds.
  • Loading branch information
ccrowhurstram committed Aug 29, 2015
1 parent 8010e07 commit 6a3692d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/scripts/ngTableParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
defaultFilterOptions = {
filterComparator: undefined, // look for a substring match in case insensitive way
filterDelay: 750,
filterDelay: 500,
filterDelayThreshold: 10000, // size of data array that will trigger the filterDelay being applied
filterFilterName: undefined, // when defined overrides ngTableDefaultGetDataProvider.filterFilterName
filterFn: undefined, // when defined overrides the filter function that ngTableDefaultGetData uses
Expand Down
8 changes: 4 additions & 4 deletions test/tableParamsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe('NgTableParams', function () {
sortingIndicator: 'span',
filterOptions: {
filterComparator: undefined,
filterDelay: 750,
filterDelay: 500,
filterDelayThreshold: 10000,
filterFilterName: undefined,
filterFn: undefined,
Expand Down Expand Up @@ -339,13 +339,13 @@ describe('NgTableParams', function () {
var tableParams = new NgTableParams({}, { data: [1,2], getData: function(){
// am I sync or async?
}});
expect(tableParams.settings().filterOptions.filterDelay).toBe(750);
expect(tableParams.settings().filterOptions.filterDelay).toBe(500);
});

it('should set filterDelay when data exceeds filterDelayThreshold', function(){
// given
var tableParams = new NgTableParams({}, { filterOptions: { filterDelayThreshold: 5 }, data: [,2,3,4,5,6] });
expect(tableParams.settings().filterOptions.filterDelay).toBe(750);
expect(tableParams.settings().filterOptions.filterDelay).toBe(500);
});

it('should allow filterDelay to be set explicitly', function(){
Expand Down Expand Up @@ -669,7 +669,7 @@ describe('NgTableParams', function () {
var settings = tp.settings();
expect(settings.counts.length).toEqual(0);
expect(settings.interceptors.length).toEqual(0);
expect(settings.filterOptions.filterDelay).toEqual(750);
expect(settings.filterOptions.filterDelay).toEqual(500);

ngTableDefaults.settings.interceptors = [ { response: angular.identity }];
tp = new NgTableParams();
Expand Down

0 comments on commit 6a3692d

Please sign in to comment.