Skip to content

Commit

Permalink
Merge pull request #3241 from IgniteUI/sorting-strategy-optional
Browse files Browse the repository at this point in the history
feat(sorting): Making the strategy and ignoreCase optional again #2734
  • Loading branch information
kdinev authored Nov 30, 2018
2 parents 7fa6c56 + cfa4c3b commit 731e3bb
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 263 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes for each version of this project will be documented in this
- Updated package dependencies to Angular 7 ([#3000](https://github.com/IgniteUI/igniteui-angular/pull/3000))
- Themes: Add dark schemas and mixins (PR [#3025](https://github.com/IgniteUI/igniteui-angular/pull/3025))

## 6.2.3
- `ISortingEpression`:
- The `ignoreCase` and `strategy` properties are moved back to optional, and the `DefaultSortingStrategy` is now injected by the `IgxSorting`, instead of being mandatory to pass to expressions.

## 6.2.2
- `igx-checkbox`:
- Added a new input property - `disableTransitions`. It allows disabling all CSS transitions on the `igx-checkbox` component for performance optimization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export enum SortingDirection {
export interface ISortingExpression {
fieldName: string;
dir: SortingDirection;
ignoreCase: boolean;
strategy: ISortingStrategy;
ignoreCase?: boolean;
strategy?: ISortingStrategy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export class IgxSorting {
return data;
}
expr = expressions[expressionIndex];
if (!expr.strategy) {
expr.strategy = DefaultSortingStrategy.instance();
}
data = expr.strategy.sort(data, expr.fieldName, expr.dir, expr.ignoreCase, this.getFieldValue);
if (expressionIndex === exprsLen - 1) {
return data;
Expand Down
4 changes: 2 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ describe('IgxGrid - Cell component', () => {
UIInteractions.sendInput(editTemplate, 'Rick Gilmore');
await wait();

grid.sort({ fieldName: 'age', dir: SortingDirection.Desc, ignoreCase: false, strategy: DefaultSortingStrategy.instance() });
grid.sort({ fieldName: 'age', dir: SortingDirection.Desc, ignoreCase: false });
fixture.detectChanges();

expect(cell.gridAPI.get_cell_inEditMode(cell.gridID)).toBeNull();
}));

it('should update correct cell when sorting is applied', (async () => {
grid.sort( {fieldName: 'age', dir: SortingDirection.Desc, ignoreCase: false, strategy: DefaultSortingStrategy.instance()});
grid.sort( {fieldName: 'age', dir: SortingDirection.Desc, ignoreCase: false});
fixture.detectChanges();

const cell = grid.getCellByColumn(0, 'fullName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ describe('IgxGrid - multi-column headers', () => {
tick();
fixture.detectChanges();
// Sort column
grid.sort({fieldName: 'CompanyName', dir: SortingDirection.Asc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
grid.sort({fieldName: 'CompanyName', dir: SortingDirection.Asc, ignoreCase: true});
fixture.detectChanges();

// Verify columns and groups
Expand Down Expand Up @@ -1104,7 +1104,7 @@ describe('IgxGrid - multi-column headers', () => {
expect(grid.getCellByColumn(4, 'Country').value).toEqual('Sweden');

// sort column which is not in the view
grid.sort({fieldName: 'ContactName', dir: SortingDirection.Asc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
grid.sort({fieldName: 'ContactName', dir: SortingDirection.Asc, ignoreCase: true});
fixture.detectChanges();

// Verify columns and groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ describe('IgxGrid - Column Moving', () => {
fixture.detectChanges();

// step 1 - group a column
grid.groupBy({ fieldName: 'ID', dir: SortingDirection.Desc, ignoreCase: false, strategy: DefaultSortingStrategy.instance() });
grid.groupBy({ fieldName: 'ID', dir: SortingDirection.Desc, ignoreCase: false });
fixture.detectChanges();

// step 2 - move a column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ describe('IgxGrid - Row Selection', () => {
expect(secondRow.isSelected).toBeTruthy();
expect(grid.rowList.find((row) => row === firstRow)).toBeTruthy();

grid.sort({ fieldName: 'Column1', dir: SortingDirection.Desc, ignoreCase: true, strategy: DefaultSortingStrategy.instance() });
grid.sort({ fieldName: 'Column1', dir: SortingDirection.Desc, ignoreCase: true });
fix.detectChanges();

expect(firstRow.isSelected).toBeFalsy();
Expand Down Expand Up @@ -880,7 +880,7 @@ describe('IgxGrid - Row Selection', () => {
const oldCellID = oldCell.cellID;
oldCell.nativeElement.focus();
oldCell.nativeElement.click();
grid.sort({ fieldName: 'UnitsInStock', dir: SortingDirection.Asc, ignoreCase: true, strategy: DefaultSortingStrategy.instance() });
grid.sort({ fieldName: 'UnitsInStock', dir: SortingDirection.Asc, ignoreCase: true });
fixture.detectChanges();
expect(grid.selectedCells).toBeDefined();
expect(grid.selectedCells.length).toBe(1);
Expand Down
Loading

0 comments on commit 731e3bb

Please sign in to comment.