From 998b85e3191180e04a854296e223b21e6eb0e523 Mon Sep 17 00:00:00 2001 From: VDyulgerov Date: Fri, 17 Sep 2021 17:52:40 +0300 Subject: [PATCH 1/8] fix(grid): use formattter function for boolean columns #8978 --- .../src/lib/data-operations/data-util.spec.ts | 6 +++--- .../src/lib/grids/cell.component.html | 4 ++-- .../src/lib/grids/grid/column.spec.ts | 13 +++++++++---- .../src/lib/test-utils/grid-samples.spec.ts | 8 ++++++++ .../src/lib/test-utils/sample-test-data.spec.ts | 8 ++++---- .../src/lib/test-utils/template-strings.spec.ts | 1 + 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts b/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts index c8c5ef41dab..82f447d114f 100644 --- a/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts +++ b/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts @@ -490,9 +490,9 @@ function testMerging() { describe('Test merging', () => { it('Should merge add transactions correctly', () => { const data = SampleTestData.personIDNameData(); - const addRow4 = { ID: 4, Name: 'Peter' }; - const addRow5 = { ID: 5, Name: 'Mimi' }; - const addRow6 = { ID: 6, Name: 'Pedro' }; + const addRow4 = { ID: 4, IsDev: true, Name: 'Peter' }; + const addRow5 = { ID: 5, IsDev: true, Name: 'Mimi' }; + const addRow6 = { ID: 6, IsDev: false, Name: 'Pedro' }; const transactions: Transaction[] = [ { id: addRow4.ID, newValue: addRow4, type: TransactionType.ADD }, { id: addRow5.ID, newValue: addRow5, type: TransactionType.ADD }, diff --git a/projects/igniteui-angular/src/lib/grids/cell.component.html b/projects/igniteui-angular/src/lib/grids/cell.component.html index 1a7503b817c..fbf4dfcd2ea 100644 --- a/projects/igniteui-angular/src/lib/grids/cell.component.html +++ b/projects/igniteui-angular/src/lib/grids/cell.component.html @@ -8,7 +8,7 @@ > -
{{ value ? "check" : "close" }} diff --git a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts index 3a1bd8e5839..b6c881a6456 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts @@ -114,11 +114,16 @@ describe('IgxGrid - Column properties #grid', () => { const grid = fix.componentInstance.grid; const formatter = fix.componentInstance.multiplier; + const boolFormatter = fix.componentInstance.boolFormatter; + expect(grid.columnList.first.formatter).toBeDefined(); for (let i = 0; i < 3; i++) { const cell = grid.getCellByColumn(i, 'ID'); expect(cell.nativeElement.textContent).toMatch(formatter(cell.value)); + + const cellBool = grid.gridAPI.get_cell_by_index(i, 'IsDev'); + expect(cellBool.nativeElement.textContent).toMatch(boolFormatter(cellBool.value)); } }); @@ -134,18 +139,18 @@ describe('IgxGrid - Column properties #grid', () => { headers = fix.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS)); expect(headers[0].nativeElement.textContent).toMatch('ID'); - expect(headers[1].nativeElement.textContent).toMatch('Name'); + expect(headers[2].nativeElement.textContent).toMatch('Name'); // Swap columns grid.moveColumn(grid.columnList.first, grid.columnList.last); fix.detectChanges(); - expect(grid.columnList.first.field).toMatch('Name'); + expect(grid.columnList.first.field).toMatch('IsDev'); expect(grid.columnList.last.field).toMatch('ID'); headers = fix.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS)); - expect(headers[0].nativeElement.textContent).toMatch('Name'); - expect(headers[1].nativeElement.textContent).toMatch('ID'); + expect(headers[0].nativeElement.textContent).toMatch('IsDev'); + expect(headers[1].nativeElement.textContent).toMatch('Name'); }); it('should support adding and removing columns through a declared iterable', fakeAsync(/** columnList.changes rAF */() => { diff --git a/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts b/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts index 1ee4c3194b4..485197a35eb 100644 --- a/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts @@ -159,6 +159,14 @@ export class ColumnCellFormatterComponent extends BasicGridComponent { public multiplier(value: number): string { return `${value * value}`; } + + public containsY(_: number, data: { ID: number; Name: string }) { + return data.Name.includes('y') ? 'true' : 'false'; + } + + public boolFormatter(value: boolean): string { + return value ? 'true' : 'false'; + } } @Component({ diff --git a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts index ac9d3931c10..2d3857aa259 100644 --- a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts @@ -141,10 +141,10 @@ export class SampleTestData { /* Data fields: ID: number, Name: string; 3 items. */ public static personIDNameData = () => ([ - { ID: 1, Name: "Johny" }, - { ID: 2, Name: "Sally" }, - { ID: 3, Name: "Tim" } - ]) + { ID: 1, IsDev: true, Name: 'Johny' }, + { ID: 2, IsDev: true, Name: 'Sally' }, + { ID: 3, IsDev: false, Name: 'Tim' }, + ]); /* Data fields: FirstName: string, LastName: string, age:number; 3 items. */ public static personNameAgeData = () => ([ diff --git a/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts b/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts index 8df4fdeb785..558b22ba1a6 100644 --- a/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts @@ -216,6 +216,7 @@ export class ColumnDefinitions { public static idNameFormatter = ` + `; From 37f2955061f460b648a36dca0b03b79d94b12594 Mon Sep 17 00:00:00 2001 From: VDyulgerov Date: Mon, 20 Sep 2021 10:17:56 +0300 Subject: [PATCH 2/8] test(grid): Change variable name #8978 --- .../src/lib/data-operations/data-util.spec.ts | 6 +++--- projects/igniteui-angular/src/lib/grids/grid/column.spec.ts | 6 +++--- .../src/lib/test-utils/sample-test-data.spec.ts | 6 +++--- .../src/lib/test-utils/template-strings.spec.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts b/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts index 82f447d114f..f011f559dc1 100644 --- a/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts +++ b/projects/igniteui-angular/src/lib/data-operations/data-util.spec.ts @@ -490,9 +490,9 @@ function testMerging() { describe('Test merging', () => { it('Should merge add transactions correctly', () => { const data = SampleTestData.personIDNameData(); - const addRow4 = { ID: 4, IsDev: true, Name: 'Peter' }; - const addRow5 = { ID: 5, IsDev: true, Name: 'Mimi' }; - const addRow6 = { ID: 6, IsDev: false, Name: 'Pedro' }; + const addRow4 = { ID: 4, IsEmployed: true, Name: 'Peter' }; + const addRow5 = { ID: 5, IsEmployed: true, Name: 'Mimi' }; + const addRow6 = { ID: 6, IsEmployed: false, Name: 'Pedro' }; const transactions: Transaction[] = [ { id: addRow4.ID, newValue: addRow4, type: TransactionType.ADD }, { id: addRow5.ID, newValue: addRow5, type: TransactionType.ADD }, diff --git a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts index b6c881a6456..ed1c15edad9 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts @@ -122,7 +122,7 @@ describe('IgxGrid - Column properties #grid', () => { const cell = grid.getCellByColumn(i, 'ID'); expect(cell.nativeElement.textContent).toMatch(formatter(cell.value)); - const cellBool = grid.gridAPI.get_cell_by_index(i, 'IsDev'); + const cellBool = grid.gridAPI.get_cell_by_index(i, 'IsEmployed'); expect(cellBool.nativeElement.textContent).toMatch(boolFormatter(cellBool.value)); } }); @@ -145,11 +145,11 @@ describe('IgxGrid - Column properties #grid', () => { grid.moveColumn(grid.columnList.first, grid.columnList.last); fix.detectChanges(); - expect(grid.columnList.first.field).toMatch('IsDev'); + expect(grid.columnList.first.field).toMatch('IsEmployed'); expect(grid.columnList.last.field).toMatch('ID'); headers = fix.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS)); - expect(headers[0].nativeElement.textContent).toMatch('IsDev'); + expect(headers[0].nativeElement.textContent).toMatch('IsEmployed'); expect(headers[1].nativeElement.textContent).toMatch('Name'); }); diff --git a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts index 2d3857aa259..b24e869146f 100644 --- a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts @@ -141,9 +141,9 @@ export class SampleTestData { /* Data fields: ID: number, Name: string; 3 items. */ public static personIDNameData = () => ([ - { ID: 1, IsDev: true, Name: 'Johny' }, - { ID: 2, IsDev: true, Name: 'Sally' }, - { ID: 3, IsDev: false, Name: 'Tim' }, + { ID: 1, IsEmployed: true, Name: 'Johny' }, + { ID: 2, IsEmployed: true, Name: 'Sally' }, + { ID: 3, IsEmployed: false, Name: 'Tim' }, ]); /* Data fields: FirstName: string, LastName: string, age:number; 3 items. */ diff --git a/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts b/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts index 558b22ba1a6..8d24c37e0f9 100644 --- a/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/template-strings.spec.ts @@ -216,7 +216,7 @@ export class ColumnDefinitions { public static idNameFormatter = ` - + `; From 2b647d4d35f483be1a14ed7858e7d12fb9d71bf8 Mon Sep 17 00:00:00 2001 From: VDyulgerov Date: Tue, 21 Sep 2021 09:13:54 +0300 Subject: [PATCH 3/8] chore(*): Remove unnecessary semicolon --- .../src/lib/test-utils/sample-test-data.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts index b24e869146f..212aa82d728 100644 --- a/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts @@ -144,7 +144,7 @@ export class SampleTestData { { ID: 1, IsEmployed: true, Name: 'Johny' }, { ID: 2, IsEmployed: true, Name: 'Sally' }, { ID: 3, IsEmployed: false, Name: 'Tim' }, - ]); + ]) /* Data fields: FirstName: string, LastName: string, age:number; 3 items. */ public static personNameAgeData = () => ([ From 2846996b501f260e6cc31be8649f5595ce1bcaf3 Mon Sep 17 00:00:00 2001 From: VDyulgerov Date: Thu, 23 Sep 2021 11:45:12 +0300 Subject: [PATCH 4/8] fix(grid): when formatter is missing display icon only #8978 --- .../src/lib/grids/tree-grid/tree-cell.component.html | 2 +- .../igniteui-angular/src/lib/test-utils/grid-samples.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html index 7dd24796eee..8569c656624 100644 --- a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html +++ b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html @@ -38,7 +38,7 @@ : value }}
{{ value ? "check" : "close" }} diff --git a/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts b/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts index 485197a35eb..e837ceab023 100644 --- a/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts @@ -165,7 +165,7 @@ export class ColumnCellFormatterComponent extends BasicGridComponent { } public boolFormatter(value: boolean): string { - return value ? 'true' : 'false'; + return value ? 'check' : 'close'; } } From 1aa83dc1a94a30890174a78d68eea7e8fe542e67 Mon Sep 17 00:00:00 2001 From: VDyulgerov Date: Fri, 24 Sep 2021 09:27:02 +0300 Subject: [PATCH 5/8] fix(grid): fix "This condition will always return 'false' [...]" #8978 --- .../src/lib/grids/tree-grid/tree-cell.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html index 8569c656624..2e1620b7104 100644 --- a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html +++ b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html @@ -8,7 +8,7 @@ >
-
Date: Mon, 27 Sep 2021 11:51:06 +0300 Subject: [PATCH 6/8] fix(grid): fix unnecessary empty div #8978 --- projects/igniteui-angular/src/lib/grids/cell.component.html | 5 +++-- .../src/lib/grids/grid/expandable-cell.component.html | 6 ++++-- .../src/lib/grids/tree-grid/tree-cell.component.html | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/cell.component.html b/projects/igniteui-angular/src/lib/grids/cell.component.html index fbf4dfcd2ea..50c09f00c13 100644 --- a/projects/igniteui-angular/src/lib/grids/cell.component.html +++ b/projects/igniteui-angular/src/lib/grids/cell.component.html @@ -8,7 +8,7 @@ > -
-
{{ grid.resourceStrings.igx_grid_pinned_row_indicator }} -
{{ formatter ? (value | columnFormatter:formatter) : column.dataType === 'number' ? (value | number:column.pipeArgs.digitsInfo:grid.locale) : column.dataType === 'date' ? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale) : value }}
-
-
-
Date: Tue, 28 Sep 2021 09:25:08 +0300 Subject: [PATCH 7/8] chore(*): fix test when get cell by index --- projects/igniteui-angular/src/lib/grids/grid/column.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts index ed1c15edad9..e0d692f6bd5 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/column.spec.ts @@ -122,7 +122,7 @@ describe('IgxGrid - Column properties #grid', () => { const cell = grid.getCellByColumn(i, 'ID'); expect(cell.nativeElement.textContent).toMatch(formatter(cell.value)); - const cellBool = grid.gridAPI.get_cell_by_index(i, 'IsEmployed'); + const cellBool = grid.gridAPI.get_cell_by_index(i, 1); expect(cellBool.nativeElement.textContent).toMatch(boolFormatter(cellBool.value)); } }); From aa049dec841f13d64f5df93a7aabfcd5ba8c0c8e Mon Sep 17 00:00:00 2001 From: Hristo Anastasov Date: Tue, 28 Sep 2021 10:55:53 +0300 Subject: [PATCH 8/8] fix(grid): add igx-icon template for boolean expandable cell --- .../lib/grids/grid/expandable-cell.component.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid/expandable-cell.component.html b/projects/igniteui-angular/src/lib/grids/grid/expandable-cell.component.html index 954f4b2a73e..dd616d5d4ae 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/expandable-cell.component.html +++ b/projects/igniteui-angular/src/lib/grids/grid/expandable-cell.component.html @@ -11,7 +11,20 @@ [row]="rowData" [column]="this.column.field" [containerClass]="'igx-grid__td-text'" - [metadata]="searchMetadata">{{ formatter ? (value | columnFormatter:formatter) : column.dataType === 'number' ? (value | number:column.pipeArgs.digitsInfo:grid.locale) : column.dataType === 'date' ? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale) : value }}
+ [metadata]="searchMetadata" + >{{ formatter + ? (value | columnFormatter:formatter) + : column.dataType === 'number' + ? (value | number:column.pipeArgs.digitsInfo:grid.locale) + : column.dataType === 'date' + ? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale) + : value + }}
+ {{ value ? "check" : "close" }}