From ed7c7df322502b1b5903e5e89f0aba50f48cebd1 Mon Sep 17 00:00:00 2001 From: MonikaKirkova Date: Wed, 26 Oct 2022 15:59:14 +0300 Subject: [PATCH 1/3] feat(grid): show correct number of changes for new row --- .../src/lib/grids/grid-base.directive.ts | 3 +++ .../src/lib/grids/grid/grid-add-row.spec.ts | 22 +++++++++++++++++-- .../src/lib/test-utils/grid-samples.spec.ts | 12 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts index 13a67fa79a9..005aa4f05e3 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts @@ -3165,6 +3165,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements Object.keys(obj).forEach(key => isObject(obj[key]) ? changes += f(obj[key]) : changes++); return changes; }; + if (this.transactions.getState(this.crudService.row.id)?.type === TransactionType.ADD) { + return this.columns.filter(c => c.field).length; + } const rowChanges = this.transactions.getAggregatedValue(this.crudService.row.id, false); return rowChanges ? f(rowChanges) : 0; } diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts index dbd2450d6b6..365896b8c41 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/grid-add-row.spec.ts @@ -5,7 +5,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite'; import { DebugElement } from '@angular/core'; import { GridFunctions, GridSummaryFunctions } from '../../test-utils/grid-functions.spec'; import { - IgxAddRowComponent, IgxGridRowEditingTransactionComponent + IgxAddRowComponent, IgxGridRowEditingDefinedColumnsComponent, IgxGridRowEditingTransactionComponent } from '../../test-utils/grid-samples.spec'; import { By } from '@angular/platform-browser'; @@ -45,7 +45,8 @@ describe('IgxGrid - Row Adding #grid', () => { IgxAddRowComponent, ColumnLayoutTestComponent, DefaultGridMasterDetailComponent, - IgxGridRowEditingTransactionComponent + IgxGridRowEditingTransactionComponent, + IgxGridRowEditingDefinedColumnsComponent ], imports: [ NoopAnimationsModule, @@ -1082,5 +1083,22 @@ describe('IgxGrid - Row Adding #grid', () => { expect(states[0].type).toEqual(TransactionType.ADD); expect(states[0].newValue['ProductName']).toEqual('aaa'); }); + + it('Should display number of defined columns for rowChangesCount', () => { + fixture = TestBed.createComponent(IgxGridRowEditingDefinedColumnsComponent); + fixture.detectChanges(); + grid = fixture.componentInstance.grid; + + const row = grid.rowList.first; + row.beginAddRow(); + fixture.detectChanges(); + endTransition(); + + let cellElem = grid.gridAPI.get_cell_by_index(10, 'ProductName'); + UIInteractions.simulateDoubleClickAndSelectEvent(cellElem); + fixture.detectChanges(); + + expect(grid.rowChangesCount).toEqual(3); + }); }); }); 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 6b270a0f616..e30b3520246 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 @@ -2550,3 +2550,15 @@ export class ObjectCloneStrategy implements IDataCloneStrategy { return clonedData; } } + +@Component({ + template: ` + + + + + ` +}) +export class IgxGridRowEditingDefinedColumnsComponent extends BasicGridComponent { + public data = SampleTestData.foodProductData(); +} From 66a90e33895656a8494da34968ae71a019108fdf Mon Sep 17 00:00:00 2001 From: MonikaKirkova Date: Thu, 27 Oct 2022 16:38:09 +0300 Subject: [PATCH 2/3] chore(grid): add feature to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e4cfdd9a52..fe39ef793ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ All notable changes for each version of this project will be documented in this - `dragIndicatorIconTemplate` - Gets/Sets the custom template used for row drag indicator. - `detailTemplate` - Gets/Sets the master-detail template. + - **Behavioral Change** - When adding new row in grid with enabled batch editing, `rowChangesCount` displays the number of the defined columns. + ## 14.2.0 ### New Features From 3790ab52524aeed2ab07a70a7c6c1539136e1222 Mon Sep 17 00:00:00 2001 From: MonikaKirkova Date: Fri, 28 Oct 2022 13:10:43 +0300 Subject: [PATCH 3/3] refactor(grid): use private property --- projects/igniteui-angular/src/lib/grids/grid-base.directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts index fda321f2150..50655adf853 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts @@ -3220,7 +3220,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements return changes; }; if (this.transactions.getState(this.crudService.row.id)?.type === TransactionType.ADD) { - return this.columns.filter(c => c.field).length; + return this._columns.filter(c => c.field).length; } const rowChanges = this.transactions.getAggregatedValue(this.crudService.row.id, false); return rowChanges ? f(rowChanges) : 0;