diff --git a/packages/common/src/filters/__tests__/sliderRangeFilter.spec.ts b/packages/common/src/filters/__tests__/sliderRangeFilter.spec.ts index 43671f3c5..d4a843cd6 100644 --- a/packages/common/src/filters/__tests__/sliderRangeFilter.spec.ts +++ b/packages/common/src/filters/__tests__/sliderRangeFilter.spec.ts @@ -117,7 +117,7 @@ describe('SliderRangeFilter', () => { filter.init(filterArguments); filter.setValues(['2..80']); - expect(spyCallback).toHaveBeenLastCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'RangeExclusive', searchTerms: [2, 80], shouldTriggerQuery: true }); + expect(spyCallback).toHaveBeenLastCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'RangeInclusive', searchTerms: [2, 80], shouldTriggerQuery: true }); }); it('should call "setValues" and expect that value to be in the callback when triggered', () => { @@ -126,7 +126,7 @@ describe('SliderRangeFilter', () => { filter.init(filterArguments); filter.setValues([3, 84]); - expect(spyCallback).toHaveBeenLastCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'RangeExclusive', searchTerms: [3, 84], shouldTriggerQuery: true }); + expect(spyCallback).toHaveBeenLastCalledWith(expect.anything(), { columnDef: mockColumn, operator: 'RangeInclusive', searchTerms: [3, 84], shouldTriggerQuery: true }); }); it('should create the input filter with default search terms range when passed as a filter argument', () => { diff --git a/packages/common/src/filters/dateRangeFilter.ts b/packages/common/src/filters/dateRangeFilter.ts index 53d799853..c8aca2573 100644 --- a/packages/common/src/filters/dateRangeFilter.ts +++ b/packages/common/src/filters/dateRangeFilter.ts @@ -55,7 +55,7 @@ export class DateRangeFilter implements Filter { /** Getter to know what would be the default operator when none is specified */ get defaultOperator(): OperatorType | OperatorString { - return this.gridOptions.defaultFilterRangeOperator || OperatorType.rangeExclusive; + return this.gridOptions.defaultFilterRangeOperator || OperatorType.rangeInclusive; } /** Getter for the Flatpickr Options */ diff --git a/packages/common/src/filters/sliderRangeFilter.ts b/packages/common/src/filters/sliderRangeFilter.ts index 62cbd47aa..a99950bfd 100644 --- a/packages/common/src/filters/sliderRangeFilter.ts +++ b/packages/common/src/filters/sliderRangeFilter.ts @@ -52,7 +52,7 @@ export class SliderRangeFilter implements Filter { /** Getter to know what would be the default operator when none is specified */ get defaultOperator(): OperatorType | OperatorString { - return this.gridOptions.defaultFilterRangeOperator || OperatorType.rangeExclusive; + return this.gridOptions.defaultFilterRangeOperator || OperatorType.rangeInclusive; } /** Getter for the Grid Options pulled through the Grid Object */ diff --git a/packages/common/src/global-grid-options.ts b/packages/common/src/global-grid-options.ts index 98ef472b4..7a8953ee5 100644 --- a/packages/common/src/global-grid-options.ts +++ b/packages/common/src/global-grid-options.ts @@ -91,7 +91,7 @@ export const GlobalGridOptions: GridOption = { defaultFilter: Filters.input, enableFilterTrimWhiteSpace: false, // do we want to trim white spaces on all Filters? defaultFilterPlaceholder: '🔍', - defaultFilterRangeOperator: OperatorType.rangeExclusive, + defaultFilterRangeOperator: OperatorType.rangeInclusive, defaultColumnSortFieldId: 'id', defaultComponentEventPrefix: '', defaultSlickgridEventPrefix: '', diff --git a/packages/common/src/interfaces/gridOption.interface.ts b/packages/common/src/interfaces/gridOption.interface.ts index d0488b784..1e27612d3 100644 --- a/packages/common/src/interfaces/gridOption.interface.ts +++ b/packages/common/src/interfaces/gridOption.interface.ts @@ -156,7 +156,7 @@ export interface GridOption { /** Default placeholder to use in Filters that support placeholder (autocomplete, input, flatpickr, select, ...) */ defaultFilterPlaceholder?: string; - /** Defaults to 'RangeExclusive', allows to change the default filter range operator */ + /** Defaults to 'RangeInclusive', allows to change the default filter range operator */ defaultFilterRangeOperator?: OperatorString | OperatorType; /** Default prefix for SlickGrid Event names (events created in the SlickGrid and/or DataView objects) */ diff --git a/packages/graphql/src/services/__tests__/graphql.service.spec.ts b/packages/graphql/src/services/__tests__/graphql.service.spec.ts index a7c327d71..693631c63 100644 --- a/packages/graphql/src/services/__tests__/graphql.service.spec.ts +++ b/packages/graphql/src/services/__tests__/graphql.service.spec.ts @@ -852,7 +852,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive numbers when the search value contains 2 (..) to represent a range of numbers', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GT, value:"2"}, {field:duration, operator:LT, value:"33"}]) { totalCount,nodes{ id,company,gender,name } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GE, value:"2"}, {field:duration, operator:LE, value:"33"}]) { totalCount,nodes{ id,company,gender,name } }}`; const mockColumn = { id: 'duration', field: 'duration' } as Column; const mockColumnFilters = { duration: { columnId: 'duration', columnDef: mockColumn, searchTerms: ['2..33'] }, @@ -880,7 +880,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive dates when the search value contains 2 (..) to represent a range of dates', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GT, value:"2001-01-01"}, {field:startDate, operator:LT, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,name } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GE, value:"2001-01-01"}, {field:startDate, operator:LE, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,name } }}`; const mockColumn = { id: 'startDate', field: 'startDate' } as Column; const mockColumnFilters = { startDate: { columnId: 'startDate', columnDef: mockColumn, searchTerms: ['2001-01-01..2001-01-31'] }, @@ -1062,7 +1062,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive numbers when the search value contains 2 (..) to represent a range of numbers', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GT, value:"2"}, {field:duration, operator:LT, value:"33"}]) { + const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GE, value:"2"}, {field:duration, operator:LE, value:"33"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; const presetFilters = [ { columnId: 'duration', searchTerms: ['2..33'] }, @@ -1078,7 +1078,7 @@ describe('GraphqlService', () => { }); it('should return a query with a filter with range of numbers with decimals when the preset is a filter range with 3 dots (..) separator', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GT, value:"0.5"}, {field:duration, operator:LT, value:".88"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GE, value:"0.5"}, {field:duration, operator:LE, value:".88"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; const presetFilters = [ { columnId: 'duration', searchTerms: ['0.5...88'] }, ] as CurrentFilter[]; @@ -1108,7 +1108,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive numbers when 2 searchTerms numbers are provided without any operator', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GT, value:2}, {field:duration, operator:LT, value:33}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:duration, operator:GE, value:2}, {field:duration, operator:LE, value:33}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; const presetFilters = [ { columnId: 'duration', searchTerms: [2, 33] }, ] as CurrentFilter[]; @@ -1123,7 +1123,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive dates when the search value contains 2 (..) to represent a range of dates', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GT, value:"2001-01-01"}, {field:startDate, operator:LT, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GE, value:"2001-01-01"}, {field:startDate, operator:LE, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; const presetFilters = [ { columnId: 'startDate', searchTerms: ['2001-01-01..2001-01-31'] }, ] as CurrentFilter[]; @@ -1153,7 +1153,7 @@ describe('GraphqlService', () => { }); it('should return a query with search having a range of exclusive dates when 2 searchTerms dates are provided without any operator', () => { - const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GT, value:"2001-01-01"}, {field:startDate, operator:LT, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; + const expectation = `query{users(first:10, offset:0, filterBy:[{field:startDate, operator:GE, value:"2001-01-01"}, {field:startDate, operator:LE, value:"2001-01-31"}]) { totalCount,nodes{ id,company,gender,duration,startDate } }}`; const presetFilters = [ { columnId: 'startDate', searchTerms: ['2001-01-01', '2001-01-31'] }, ] as CurrentFilter[]; diff --git a/packages/graphql/src/services/graphql.service.ts b/packages/graphql/src/services/graphql.service.ts index bcd806eba..16cdab9f0 100644 --- a/packages/graphql/src/services/graphql.service.ts +++ b/packages/graphql/src/services/graphql.service.ts @@ -416,7 +416,7 @@ export class GraphqlService implements BackendService { if (Array.isArray(searchTerms) && searchTerms.length === 1 && typeof searchTerms[0] === 'string' && searchTerms[0].indexOf('..') > 0) { searchTerms = searchTerms[0].split('..'); if (!operator) { - operator = OperatorType.rangeExclusive; + operator = OperatorType.rangeInclusive; } } @@ -439,7 +439,7 @@ export class GraphqlService implements BackendService { searchValue = searchTerms.join(','); } else if (searchTerms && searchTerms.length === 2 && (!operator || operator === OperatorType.rangeExclusive || operator === OperatorType.rangeInclusive)) { if (!operator) { - operator = OperatorType.rangeExclusive; + operator = OperatorType.rangeInclusive; } searchByArray.push({ field: fieldName, operator: (operator === OperatorType.rangeInclusive ? 'GE' : 'GT'), value: searchTerms[0] }); searchByArray.push({ field: fieldName, operator: (operator === OperatorType.rangeInclusive ? 'LE' : 'LT'), value: searchTerms[1] }); diff --git a/packages/odata/src/services/__tests__/grid-odata.service.spec.ts b/packages/odata/src/services/__tests__/grid-odata.service.spec.ts index 4f203010e..5c34f9347 100644 --- a/packages/odata/src/services/__tests__/grid-odata.service.spec.ts +++ b/packages/odata/src/services/__tests__/grid-odata.service.spec.ts @@ -1418,7 +1418,7 @@ describe('GridOdataService', () => { it('should return a query with a filter with range of numbers when the preset is a filter range with 2 dots (..) separator', () => { const columns = [{ id: 'company', field: 'company' }, { id: 'gender', field: 'gender' }, { id: 'duration', field: 'duration', type: FieldType.number }]; jest.spyOn(gridStub, 'getColumns').mockReturnValue(columns); - const expectation = `$top=10&$filter=(Duration gt 4 and Duration lt 88)`; + const expectation = `$top=10&$filter=(Duration ge 4 and Duration le 88)`; const presetFilters = [ { columnId: 'duration', searchTerms: ['4..88'] }, ] as CurrentFilter[]; @@ -1435,7 +1435,7 @@ describe('GridOdataService', () => { it('should return a query with a filter with range of numbers with decimals when the preset is a filter range with 3 dots (...) separator', () => { const columns = [{ id: 'company', field: 'company' }, { id: 'gender', field: 'gender' }, { id: 'duration', field: 'duration', type: FieldType.number }]; jest.spyOn(gridStub, 'getColumns').mockReturnValue(columns); - const expectation = `$top=10&$filter=(Duration gt 0.5 and Duration lt .88)`; + const expectation = `$top=10&$filter=(Duration ge 0.5 and Duration le .88)`; const presetFilters = [ { columnId: 'duration', searchTerms: ['0.5...88'] }, ] as CurrentFilter[]; @@ -1469,7 +1469,7 @@ describe('GridOdataService', () => { it('should return a query with a filter with range of dates when the preset is a filter range with 2 dots (..) separator', () => { const columns = [{ id: 'company', field: 'company' }, { id: 'gender', field: 'gender' }, { id: 'finish', field: 'finish', type: FieldType.date }]; jest.spyOn(gridStub, 'getColumns').mockReturnValue(columns); - const expectation = `$top=10&$filter=(Finish gt DateTime'2001-01-01T00:00:00Z' and Finish lt DateTime'2001-01-31T00:00:00Z')`; + const expectation = `$top=10&$filter=(Finish ge DateTime'2001-01-01T00:00:00Z' and Finish le DateTime'2001-01-31T00:00:00Z')`; const presetFilters = [ { columnId: 'finish', searchTerms: ['2001-01-01..2001-01-31'] }, ] as CurrentFilter[]; @@ -1541,7 +1541,7 @@ describe('GridOdataService', () => { it('should return a query with a filter with range of numbers when the preset is a filter range with 2 dots (..) separator but without pagination when "enablePagination" is set to False', () => { const columns = [{ id: 'company', field: 'company' }, { id: 'gender', field: 'gender' }, { id: 'duration', field: 'duration', type: FieldType.number }]; jest.spyOn(gridStub, 'getColumns').mockReturnValue(columns); - const expectation = `$filter=(Duration gt 4 and Duration lt 88)`; + const expectation = `$filter=(Duration ge 4 and Duration le 88)`; const presetFilters = [ { columnId: 'duration', searchTerms: ['4..88'] }, ] as CurrentFilter[]; diff --git a/packages/odata/src/services/grid-odata.service.ts b/packages/odata/src/services/grid-odata.service.ts index 1f118e194..dd6d112a2 100644 --- a/packages/odata/src/services/grid-odata.service.ts +++ b/packages/odata/src/services/grid-odata.service.ts @@ -287,7 +287,7 @@ export class GridOdataService implements BackendService { if (Array.isArray(searchTerms) && searchTerms.length === 1 && typeof searchTerms[0] === 'string' && searchTerms[0].indexOf('..') > 0) { searchTerms = searchTerms[0].split('..'); if (!operator) { - operator = OperatorType.rangeExclusive; + operator = OperatorType.rangeInclusive; } }