Skip to content

Commit f8bf9a9

Browse files
ddinchevahanastasovChronosSFkdinevdamyanpetev
authored
Deprecate rowID and primaryKey in grid interfaces (#13427)
* refactor(Grid): deprecate rowID and rowData props from the grid eventArgs #10617 * chore(*): address review comment for editDoneArgs * chore(*): update the tests according new API changes * chore(*): fix tests accordinly newly addressed API changes * chore(*): fix rowEditDone event args * fix(*): do not clear summaries when row edit is not complete #10617 * chore(*): fix linting errors * chore(grid): separate grid and cell event interfaces, events reorganization * chore(*): add proper description for interfaces * chore(*): fix the description of the deprecated properties * feat(*): expose new event arguments for grid rowAdd and rowDelete #10617 * chore(*): add key and deprecate primaryKey event args * chore(*): address the issues in the test due to changes in the event arguments * chore(*): fix some linting errors * chore(*): fix failing test * chore(*): fix failing tests * chore(*): change the version for the deprecation of rowId and rowData props * chore(*): describe in the changelog the deprecated props rowID and rowData * chore(*): remove some leftover comment * chore(*): apply some of the review comments * Update CHANGELOG.md Co-authored-by: Konstantin Dinev <[email protected]> * chore(*): address some more comments * feat(*): reintroduce primaryKey prop and introduce rowKey instead key #10617 * test(Grid): fix the test with reintroduced props primaryKey and rowKey #10617 * feat(*): remove the deprecation of rowData prop and remove data prop #10617 * chore(*): drop the new interfaces entirely * test(Grid): address the latest changes in the gridEdit events #10617 * chore(*): remove cellID and and column from IRowDataCancelableEventArgs * chore(*): deprecate data and introduce rowData in IBaseRowDataEventArgs * chore(*): deprecate key, introduce rowKey * chore(*): remove unnecessary added key prop in IRowDataEventArgs * chore(*): unify rowKey prop for the rest of the interfaces * chore(*): update the changelog * chore(*): remove unused interface * chore(*): update changelog for pivot * chore(*): update changelog for pivot * Apply suggestions minor formatting and redundant comments * chore(*): add wrongfully removed comments * chore(*): should not use deprecated props internally * chore(*): fix indentation * feat(*): IRowDataCancelableEventArgs to extend IGridEditEventArgs #10617 * chore(*): update the deprecation version and the changelog description * chore(*): changelog enhcaements * chore(*): fix typo in interace name * Update projects/igniteui-angular/src/lib/grids/summaries/grid-summary.service.ts * Update projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts * Update projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-crud.spec.ts * Update projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-crud.spec.ts * Update projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-editing-actions.component.spec.ts * chore(*): fix incorrect work usage * chore(grid): cleanup redundant comments * chore(grid): row data cancelable spelling; consistent w/ base interface * docs(grid): update events changelog * docs(changelog): grid event arg deprecations separate section --------- Co-authored-by: Hristo Anastasov <[email protected]> Co-authored-by: Stamen Stoychev <[email protected]> Co-authored-by: Konstantin Dinev <[email protected]> Co-authored-by: Damyan Petev <[email protected]>
1 parent c0b34e0 commit f8bf9a9

26 files changed

+395
-201
lines changed

CHANGELOG.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All notable changes for each version of this project will be documented in this
99
- `IgxTree`
1010
- Added new property `toggleNodeOnClick` that determines whether clicking over a node will change its expanded state or not. Set to `false` by default.
1111
- `IgxPivotGrid`
12-
- `IPivotDimension` interface now exposes a property called `displayName` similar to the one in the `IPivotValue` interface. This property is optional and will be displayed inside the chips for rows and columns in the `IgxPivotGrid`. If the `displayName` proeprty is not set, `memberName` will be used as a fallback.
12+
- `IPivotDimension` interface now exposes a property called `displayName` similar to the one in the `IPivotValue` interface. This property is optional and will be displayed inside the chips for rows and columns in the `IgxPivotGrid`. If the `displayName` property is not set, `memberName` will be used as a fallback.
1313
- New directive - `igxIconButton` directive that provides a way to use an icon as a fully functional button has been added. The new `igxIconButton` comes in three types - flat, outlined and contained (default). All `igxButton`'s with type `icon` will be automatically migrated to the new `igxIconButton`'s with `ng update`.
1414
- `IgxButton`
1515
- **Behavioral Change** `buttonSelected` event is now emitted not only when a button gets selected, but also when it gets deselected. However, the event is no longer being emitted on initialization. If this event was used in a scenario where it is assumed that the button gets selected, it's a good idea the logic to be branched now based on `eventArgs.selected` condition.
@@ -20,7 +20,16 @@ All notable changes for each version of this project will be documented in this
2020
- The `igxButtonColor` and `igxButtonBackground` input properties have been deprecated and will be removed in a future version.
2121
- `IgxForOf`
2222
- Unified logic for vertical and horizontal virtualization such as - caching, updating, max browser size exceeding.
23-
- Addded new method - `addScroll` that can shift the scroll thumb by the specified amount in pixels (negative number to scroll to previous, positive to scroll next). Similar to `addScrollTop` but works for both vertical and horizontal virtualization.
23+
- Added new method - `addScroll` that can shift the scroll thumb by the specified amount in pixels (negative number to scroll to previous, positive to scroll next). Similar to `addScrollTop` but works for both vertical and horizontal virtualization.
24+
25+
26+
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
27+
- **Breaking Changes**
28+
- `rowAdd` and `rowDelete` events now emit event argument of type `IRowDataCancelableEventArgs` instead of `IGridEditEventArgs`. The two interfaces are still compatible, however redundant for these events properties `cellID`, `newValue`, `oldValue`, `isAddRow` are deprecated in `IRowDataCancelableEventArgs` and will be removed in a future version. Switching to the correct new interfaces should reveal any deprecated use that can be safely removed.
29+
- **Deprecations**
30+
- `rowID` property has been deprecated in the following interfaces: `IGridEditDoneEventArgs`, `IPathSegment`, `IRowToggleEventArgs`, `IPinRowEventArgs`, `IgxAddRowParent` and will be removed in a future version. Use `rowKey` instead.
31+
- `primaryKey` property has been deprecated in the following interfaces: `IRowDataEventArgs`, `IGridEditDoneEventArgs`. Use `rowKey` instead.
32+
- `data` property has been deprecated in the following interfaces: `IRowDataEventArgs`. Use `rowData` instead.
2433

2534
## 17.0.0
2635
### General
@@ -33,14 +42,14 @@ All notable changes for each version of this project will be documented in this
3342
- `igniteui-angular-i18n` is now tree-shakeable
3443
- `igniteui-angular/animations` is now tree-shakeable
3544
- `igniteui-angular` components have improved tree-shaking
36-
- **Breaking Change** `getCurrentResourceStrings` has been removed. Use the specific component string imports instead.
45+
- **Breaking Change** `getCurrentResourceStrings` has been removed. Use the specific component string imports instead.
3746
- E.g. EN strings come from `igniteui-angular`: `import { GridResourceStringsEN } from 'igniteui-angular';`
3847
- E.g. DE or other language strings come from `igniteui-angular-i18n`: `import { GridResourceStringsDE } from 'igniteui-angular-i18n';`
3948
- DisplayDensity token and inputs are deprecated in favor of `--ig-size` theming
4049
- We're working on reducing the library size
4150
- `IgxRadioComponent` size has been reduced in half
4251
- `IgxSwitchComponent` size has been reduced in half
43-
- `IgxRadioComponent`
52+
- `IgxRadioComponent`
4453
- **Breaking Change** `IChangeRadioEventArgs` is now `IChangeCheckboxEventArgs`. `ng update` to `17.0.0` will automatically migrate this for you.
4554
- **Breaking Change** `RadioLabelPosition` is now `LabelPosition`. `ng update` to `17.0.0` will automatically migrate this for you.
4655
- `IgxSwitchComponent`
@@ -49,7 +58,7 @@ All notable changes for each version of this project will be documented in this
4958
- `IgxCombo`
5059
- **Breaking Change** `IComboSelectionChangingEventArgs` properties `newSelection` and `oldSelection` have been renamed to `newValue` and `oldValue` respectively to better reflect their function. Just like Combo's `value`, those will emit either the specified property values or full data items depending on whether `valueKey` is set or not. Automatic migrations are available and will be applied on `ng update`.
5160
- `IComboSelectionChangingEventArgs` exposes two new properties `newSelection` and `oldSelection` in place of the old ones that are no longer affected by `valueKey` and consistently emit items from Combo's `data`.
52-
61+
5362
Note: In remote data scenarios with `valueKey` set, selected items that are not currently part of the loaded data chunk will be emitted a partial item data object with the `valueKey` property.
5463
- **Breaking Change** - `IComboSelectionChangingEventArgs` properties `added` and `removed` now always contain data items, regardless of `valueKey` being set. This aligns them with the updated `newSelection` and `oldSelection` properties, including the same limitation for remote data as described above.
5564
- `IgxSimpleCombo`
@@ -61,11 +70,11 @@ All notable changes for each version of this project will be documented in this
6170
- `IgxCombo`,`IgxSimpleCombo`
6271
- **Breaking Change** The `displayValue` property now returns the display text as expected (instead of display values in array).
6372

73+
=======
6474
## 16.1.5
6575
### General
6676
- `IgxButtonGroup`:
6777
- Reverted cancellable on `selected` and `deselected` events (added in 15.1.24) as it was breaking firing order and related handling.
68-
6978
## 16.1.4
7079
### New Features
7180
- `Themes`:
@@ -107,7 +116,7 @@ All notable changes for each version of this project will be documented in this
107116
```
108117
- `IgxBadge`:
109118
- Material icons extended along with any other custom icon set can now be used inside the badge component.
110-
- Code example:
119+
- Code example:
111120

112121
```typescript
113122
import { IgxBadgeComponent, IgxIconService } from 'igniteui-angular';
@@ -150,7 +159,7 @@ All notable changes for each version of this project will be documented in this
150159
```
151160

152161
```css
153-
/*
162+
/*
154163
Add --ig-size to a component or global file.
155164
Available values are:
156165
compact: --ig-size-small

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-editing-actions.component.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IgxTreeGridEditActionsComponent } from '../../test-utils/tree-grid-comp
1515
import { IgxGridEditingActionsComponent } from './grid-editing-actions.component';
1616
import { IgxGridPinningActionsComponent } from './grid-pinning-actions.component';
1717
import { IgxActionStripComponent } from '../action-strip.component';
18-
import { IgxColumnComponent } from '../../grids/public_api';
18+
import { IRowDataCancelableEventArgs, IgxColumnComponent } from '../../grids/public_api';
1919

2020
describe('igxGridEditingActions #grid ', () => {
2121
let fixture;
@@ -203,6 +203,7 @@ describe('igxGridEditingActions #grid ', () => {
203203
expect(grid.rowPinning.emit).toHaveBeenCalledTimes(1);
204204
expect(grid.rowPinning.emit).toHaveBeenCalledWith({
205205
rowID : row.key,
206+
rowKey: row.key,
206207
insertAtIndex: 0,
207208
isPinned: true,
208209
row,
@@ -220,6 +221,7 @@ describe('igxGridEditingActions #grid ', () => {
220221
expect(grid.rowPinning.emit).toHaveBeenCalledTimes(2);
221222
expect(grid.rowPinning.emit).toHaveBeenCalledWith({
222223
rowID : row5.key,
224+
rowKey: row5.key,
223225
insertAtIndex: 1,
224226
isPinned: true,
225227
row: row5,
@@ -355,18 +357,22 @@ describe('igxGridEditingActions #grid ', () => {
355357
expect(editActions[3].componentInstance.iconName).toBe('delete');
356358
const deleteChildBtn = editActions[3].componentInstance;
357359

358-
const rowDeleteArgs = {
360+
const rowDeleteArgs: IRowDataCancelableEventArgs = {
359361
rowID: row.key,
360362
primaryKey: row.key,
363+
rowKey: row.key,
361364
cancel: false,
362365
rowData: treeGrid.getRowData(row.key),
366+
data: treeGrid.getRowData(row.key),
363367
oldValue: null,
364-
owner: treeGrid
368+
owner: treeGrid,
365369
};
366370

367371
const rowDeletedArgs = {
368372
data: treeGrid.getRowData(row.key),
373+
rowData: treeGrid.getRowData(row.key),
369374
primaryKey: row.key,
375+
rowKey: row.key,
370376
owner: treeGrid
371377
};
372378

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
141141
if (!cell) {
142142
return;
143143
}
144-
const args = cell.createEditEventArgs(true);
145-
146-
this.grid.summaryService.clearSummaryCache(args);
144+
const args = cell.createCellEditEventArgs(true);
145+
if (!this.grid.crudService.row) { // should not recalculate summaries when there is row in edit mode
146+
this.grid.summaryService.clearSummaryCache(args);
147+
}
147148
const data = this.getRowData(cell.id.rowID);
148149
const newRowData = reverseMapper(cell.column.field, args.newValue);
149150
this.updateData(this.grid, cell.id.rowID, data, cell.rowData, newRowData);
@@ -187,7 +188,7 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
187188
const hasSummarized = grid.hasSummarizedColumns;
188189
this.crudService.updateRowEditData(row, value);
189190

190-
const args = row.createEditEventArgs(true, event);
191+
const args = row.createRowEditEventArgs(true, event);
191192

192193
// If no valid row is found
193194
if (index === -1) {
@@ -338,7 +339,7 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
338339
public deleteRowById(rowId: any): any {
339340
let index: number;
340341
const grid = this.grid;
341-
const data = this.get_all_data();
342+
const data = this.get_all_data(grid.transactions.enabled);
342343
if (grid.primaryKey) {
343344
// eslint-disable-next-line @typescript-eslint/no-shadow
344345
index = data.map((record) => record[grid.primaryKey]).indexOf(rowId);
@@ -360,7 +361,7 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
360361

361362
const record = data[index];
362363
const key = record ? record[grid.primaryKey] : undefined;
363-
grid.rowDeletedNotifier.next({ data: record, owner: grid, primaryKey: key });
364+
grid.rowDeletedNotifier.next({ data: record, rowData: record, owner: grid, primaryKey: key, rowKey: key });
364365

365366
this.deleteRowFromData(rowId, index);
366367

@@ -424,6 +425,7 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
424425
}
425426

426427
const args: IRowToggleEventArgs = {
428+
rowKey: rowID,
427429
rowID,
428430
expanded,
429431
event,
@@ -585,6 +587,7 @@ export class GridBaseAPIService<T extends GridType> implements GridServiceType {
585587
public get_pin_row_event_args(rowID: any, index?: number, row?: RowType, pinned?: boolean) {
586588
const eventArgs: IPinRowEventArgs = {
587589
isPinned: pinned ? true : false,
590+
rowKey: rowID,
588591
rowID,
589592
row,
590593
cancel: false

0 commit comments

Comments
 (0)