Skip to content

Commit 854c4f3

Browse files
hanastasovzdrawku
andauthored
Return an instance of a public row classes from certain API calls (#9187)
* feat(grid): public row API, grid and tgrid #8668 * chore(*): add sample for public row api * style(*): fix lint error #8668 * style(*): fix lint error #8668 * feat(grid): grid and tgrid API enhance #8668 * chore(*): update row api sample * test(grid): fix test accroding to changes #8668 * chore(*): fix lint errors * chore(*): fix lint errors * test(grid): fix grid tests #9139 * test(grid): fix grid tests #9139 * test(grid): fix grid tests #9139 * test(grid): fix тgrid tests #9139 * feat(grid): find data by index recursively in tgrid #8668 * chore(*): fix lint errors * merge master * test(grid): fix row editing test * fix(grid): fix recursive logic to find element in treegrid * test(grid): exclude test to see how build runs * fix(grid): fix recursive logic to find element in tgrid * fix(grid): recursive logic to find element in tgrid by key * fix(Grid): use recursive logic to find row for every tgrid * fix(grid): return IgxGroupByrow facade instance * chore(*): fix lint errors * chore(*): fix lint errors * chore(*): allow tests to run * chore(*): allow tests to run * fix(grid): implement IgxSummaryRow facade * chore(*): fix lint errors * chore(*): fix lint errors * feat(grid): return IgxSummaryRow instance * test(grid): fix tests and bugs * test(grid): fix hier test that use DOM elements * test(grid): REMOVE F FROM TESTS * test(grid): fix hier tests, use gridAPI * test(grid): fix hier tests, use gridAPI * chore(*): clean code, write examples * chore(*): fix tests to expect row not to be disabled * chore(*): revert some changes frm 620d44b * chore(*): revert some changes frm 620d44b * chore(*): revert some changes 620d44b * chore(*): fix test to get row component * feat(grid): consider all type of rows and pages when finding row * feat(grid): use top pinning position in first step * fix(grid): fix small bugs in finfing pinned row * fix(grid): drop support for get row in other pages * chore(*): fix lint errors * fix(Grid): fix failing test for getting row * fix(grid): get row by key from data rows collection * fix(Grid): collapsed rows should be undefined * fix(grid): use current page data for hier grid * fix(grid): dont add pinned rec to collection, it is already there * fix(grid): deprecate row.rowData, use row.data instead * fix(grid): deprecate row.rowID. use key instead * fix(*): add initial tests #8668 * chore(*): address comments on PR, use dataView * chore(*): remove fit frrom tests * chore(*): remove fit frrom tests * fix(grid): emit RowType row on row pinning * fix(grid): reuse grouprow toggle method * chore(*): remove fit from tests * refactor(grid): extract stuff in BaseRow class * chore(*): Add row API tests * fix(grid): explicitly add setters in derived class * test(grid): update tests to use key isnetad of rowID,dont test disabled * chore(*): remove fit from test * chore(*): fix test to test summary row attributes * chore(*): fix test to verify correct children number * chore(*): rename deprecated, add HGrid test * chore(*): Add separate pinning and hasChildren * chore(*): add final test for editing with update * fix(grid): clear code, use markForCheck * chore(*): clear unsused imports * fix(grid): row drag directive to emit RowType and native element * fix(grid): keep test in its initial variant * chore(*): fix lint errrors with member accessors * fix(grid): dont expose row components in public api * chore(*): fix lint error property shorthand * test(grid): add migration and migration tests * chore(*): update changelog file * chore(*): fix lint errors * chore(*): fix replace bug in migration * chore(*): call update.applyChanges Co-authored-by: Zdravko Kolev <[email protected]>
1 parent b4cb049 commit 854c4f3

File tree

80 files changed

+3041
-1155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3041
-1155
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ All notable changes for each version of this project will be documented in this
77
### General
88
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
99
- **Breaking Change** - The `locale` and `pipeArgs` parameters are removed from the `operate` method exposed by the `IgxNumberSummaryOperand`, `IgxDateSummaryOperand`, `IgxCurrencySummaryOperand` and `IgxPercentSummaryOperand`. They are now set in the `igx-grid-summary-cell` template. To change the locale and format setting of the `igx-grid-summary-cell` the user can use the new `summaryFormatter` property of the `IgxColumnComponent`.
10-
- `IgxTabs`, `IgxBottomNav`
10+
- `IgxGridRowComponent`, `IgxGridGroupByRowComponent`, `IgxTreeGridRowComponent`, `IgxHierarchicalRowComponent` are no longer exposed in the public API. Automatic migration will change these imports with `RowType`.
11+
- **Behavioral changes**
12+
- `getRowByIndex`, `getRowByKey`, `cell.row` now return an object implemening the `RowType` interface.
13+
- `dragData` emitted with `IRowDragEndEventArgs`, `IRowDragStartEventArgs` is now `RowType`
14+
- `IRowDragEndEventArgs`, `IRowDragStartEventArgs` now emit `dragElement`, which holds the dragged row html element.
15+
- `row` in `IPinRowEventArgs` is now `RowType`
1116
- **Breaking Change** - `IgxTabs` and `IgxBottomNav` components were completely refactored in order to provide more flexible and descriptive way to define tab headers and contents. Please make sure to update via `ng update` in order to migrate the existing `igx-tabs` and `igx-bottom-nav` definitions to the new ones.
1217
- `IgxForOfDirective`
1318
- **Breaking Change** - `IgxForOfDirective` events are renamed as follows:

projects/igniteui-angular/migrations/update-12_0_0/index.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,52 @@ igx-bottom-nav-content {
336336
}
337337
igx-bottom-nav-header {
338338
padding: 8px;
339+
}`);
340+
});
341+
342+
it('Should update row component types with RowType', async () => {
343+
appTree.create(
344+
'/testSrc/appPrefix/component/rows.component.ts', `
345+
import { IgxGridComponent, IgxGridRowComponent, IgxHierarchicalRowComponent, RowPinningPosition } from 'igniteui-angular';
346+
export class HGridMultiRowDragComponent {
347+
public onDropAllowed(args: IDropDroppedEventArgs)
348+
const hierRow: IgxHierarchicalRowComponent = args.dragData;
349+
const row: IgxGridRowComponent = args.dragData;
350+
const treeRow: IgxTreeGridRowComponent = args.dragData;
351+
const groupByRow: IgxGridGroupByRowComponent = args.dragData;
352+
const children = (cell.row as IgxTreeGridRowComponent).children;
353+
}
354+
public ngOnInit() {
355+
const hierRow: this.hierGrid1.getRowByIndex(0) as IgxHierarchicalRowComponent;
356+
const row: this.grid1.getRowByIndex(0) as IgxGridRowComponent;
357+
const treeRow: this.treeGrid1.getRowByIndex(0) as IgxTreeGridRowComponent;
358+
const hierRowComp: this.hierGrid1.hGridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
359+
const rowComp: this.grid1.gridAPI.get_row_by_index(0) as IgxGridRowComponent;
360+
const treeRowComp: this.gridAPI.get_row_by_index(0) as IgxTreeGridRowComponent;
361+
}
362+
}`);
363+
const tree = await schematicRunner.runSchematicAsync('migration-20', {}, appTree)
364+
.toPromise();
365+
366+
expect(tree.readContent('/testSrc/appPrefix/component/rows.component.ts'))
367+
.toEqual(`
368+
import { IgxGridComponent, RowType, RowPinningPosition } from 'igniteui-angular';
369+
export class HGridMultiRowDragComponent {
370+
public onDropAllowed(args: IDropDroppedEventArgs)
371+
const hierRow: RowType = args.dragData;
372+
const row: RowType = args.dragData;
373+
const treeRow: RowType = args.dragData;
374+
const groupByRow: RowType = args.dragData;
375+
const children = (cell.row as RowType).children;
376+
}
377+
public ngOnInit() {
378+
const hierRow: this.hierGrid1.getRowByIndex(0) as RowType;
379+
const row: this.grid1.getRowByIndex(0) as RowType;
380+
const treeRow: this.treeGrid1.getRowByIndex(0) as RowType;
381+
const hierRowComp: this.hierGrid1.hGridAPI.get_row_by_index(0) as RowType;
382+
const rowComp: this.grid1.gridAPI.get_row_by_index(0) as RowType;
383+
const treeRowComp: this.gridAPI.get_row_by_index(0) as RowType;
384+
}
339385
}`);
340386
});
341387
});

projects/igniteui-angular/migrations/update-12_0_0/index.ts

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
3434
const changes = new Map<string, FileChange[]>();
3535
const htmlFiles = update.templateFiles;
3636
const sassFiles = update.sassFiles;
37+
const tsFiles = update.tsFiles;
3738
let applyComment = false;
3839

3940
const applyChanges = () => {
@@ -217,6 +218,111 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
217218
}
218219
}
219220

220-
// Apply all selector and input changes
221+
// update row components imports and typings with new RowType interface
222+
const rowsImports = [
223+
'IgxGridRowComponent, ',
224+
'IgxGridGroupByRowComponent, ',
225+
'IgxTreeGridRowComponent, ',
226+
'IgxHierarchicalRowComponent, '];
227+
228+
const rowsImportsNoSpace = [
229+
'IgxGridRowComponent,',
230+
'IgxGridGroupByRowComponent,',
231+
'IgxTreeGridRowComponent,',
232+
'IgxHierarchicalRowComponent,'];
233+
234+
const rowsImportsEnd = [
235+
', IgxGridRowComponent }',
236+
', IgxGridGroupByRowComponent }',
237+
', IgxTreeGridRowComponent }',
238+
', IgxHierarchicalRowComponent }'];
239+
240+
const rowsImportsEndNewLIne = [
241+
'IgxGridRowComponent }',
242+
'IgxGridGroupByRowComponent }',
243+
'IgxTreeGridRowComponent }',
244+
'IgxHierarchicalRowComponent }'];
245+
246+
const typyingsToReplace = [
247+
'as IgxGridRowComponent;',
248+
'as IgxGridRowComponent).',
249+
': IgxGridRowComponent',
250+
251+
'as IgxGridGroupByRowComponent;',
252+
'as IgxGridGroupByRowComponent).',
253+
': IgxGridGroupByRowComponent',
254+
255+
'as IgxTreeGridRowComponent;',
256+
'as IgxTreeGridRowComponent).',
257+
': IgxTreeGridRowComponent',
258+
259+
'as IgxHierarchicalRowComponent;',
260+
'as IgxHierarchicalRowComponent).',
261+
': IgxHierarchicalRowComponent'
262+
];
263+
264+
const replacements = [
265+
'as RowType;',
266+
'as RowType).',
267+
': RowType'
268+
];
269+
270+
271+
for (const entryPath of tsFiles) {
272+
let content = host.read(entryPath).toString();
273+
let importChanged = 0;
274+
275+
rowsImports.forEach((n, i) => {
276+
if (content.indexOf(n) !== -1) {
277+
if (importChanged === 0) {
278+
content = content.replace(n, 'RowType, ');
279+
importChanged++;
280+
} else {
281+
content = content.split(n).join('');
282+
}
283+
}
284+
});
285+
286+
rowsImportsNoSpace.forEach((n, i) => {
287+
if (content.indexOf(n) !== -1) {
288+
if (importChanged === 0) {
289+
content = content.replace(n, 'RowType,');
290+
importChanged++;
291+
} else {
292+
content = content.split(n).join('');
293+
}
294+
}
295+
});
296+
297+
rowsImportsEnd.forEach((n, i) => {
298+
if (content.indexOf(n) !== -1) {
299+
if (importChanged === 0) {
300+
content = content.replace(n, ', RowType }');
301+
importChanged++;
302+
} else {
303+
content = content.split(n).join(' }');
304+
}
305+
}
306+
});
307+
308+
rowsImportsEndNewLIne.forEach((n, i) => {
309+
if (content.indexOf(n) !== -1) {
310+
if (importChanged === 0) {
311+
content = content.replace(n, 'RowType }');
312+
importChanged++;
313+
} else {
314+
content = content.split(n).join('}');
315+
}
316+
}
317+
});
318+
319+
typyingsToReplace.forEach((n, i) => {
320+
if (content.indexOf(n) !== -1) {
321+
content = content.split(n).join(replacements[i % 3]);
322+
}
323+
});
324+
host.overwrite(entryPath, content);
325+
}
326+
221327
update.applyChanges();
222328
};

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { IgxActionStripModule } from '../action-strip.module';
1010
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
1111
import { IgxHierarchicalGridActionStripComponent } from '../../test-utils/hierarchical-grid-components.spec';
1212
import {
13-
IgxHierarchicalRowComponent,
1413
IgxHierarchicalGridComponent,
1514
IgxHierarchicalGridModule
1615
} from '../../grids/hierarchical-grid/public_api';
16+
import { IgxHierarchicalRowComponent } from '../../grids/hierarchical-grid/hierarchical-row.component';
1717

1818
describe('igxGridEditingActions #grid ', () => {
1919
let fixture;
@@ -159,7 +159,7 @@ describe('igxGridEditingActions #grid ', () => {
159159
grid = fixture.componentInstance.grid;
160160
}));
161161
it('should auto-show on mouse enter of row.', () => {
162-
const row = grid.getRowByIndex(0);
162+
const row = grid.gridAPI.get_row_by_index(0);
163163
const rowElem = row.nativeElement;
164164
UIInteractions.simulateMouseEvent('mouseenter', rowElem, 0, 0);
165165
fixture.detectChanges();
@@ -191,7 +191,7 @@ describe('igxGridEditingActions #grid ', () => {
191191
}));
192192

193193
it('should auto-show root actionStrip on mouse enter of root row.', () => {
194-
const row = hierarchicalGrid.getRowByIndex(0);
194+
const row = hierarchicalGrid.gridAPI.get_row_by_index(0);
195195
const rowElem = row.nativeElement;
196196
UIInteractions.simulateMouseEvent('mouseenter', rowElem, 0, 0);
197197
fixture.detectChanges();
@@ -202,13 +202,13 @@ describe('igxGridEditingActions #grid ', () => {
202202
});
203203

204204
it('should auto-show row island actionStrip on mouse enter of child row.', () => {
205-
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
205+
const row = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
206206
row.toggle();
207207
fixture.detectChanges();
208208

209209
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[1];
210210

211-
const childRow = childGrid.getRowByIndex(0);
211+
const childRow = childGrid.gridAPI.get_row_by_index(0);
212212
const rowElem = childRow.nativeElement;
213213
UIInteractions.simulateMouseEvent('mouseenter', rowElem, 0, 0);
214214
fixture.detectChanges();
@@ -220,12 +220,12 @@ describe('igxGridEditingActions #grid ', () => {
220220
});
221221

222222
it('should auto-hide all actionStrip on mouse leave of root grid.', () => {
223-
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
224-
row.toggle();
223+
const row = hierarchicalGrid.getRowByIndex(0);
224+
row.expanded = !row.expanded;
225225
fixture.detectChanges();
226226

227227
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
228-
const childRow = childGrid.getRowByIndex(0);
228+
const childRow = childGrid.gridAPI.get_row_by_index(0);
229229

230230
actionStripRoot.show(row);
231231
actionStripChild.show(childRow);

projects/igniteui-angular/src/lib/directives/drag-drop/drag-drop.directive.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
179179
* @memberof IgxDragDirective
180180
*/
181181
@Input('igxDrag')
182-
public data: any;
182+
public set data(value: any) {
183+
this._data = value;
184+
}
185+
186+
public get data(): any {
187+
return this._data;
188+
}
183189

184190
/**
185191
* An @Input property that indicates when the drag should start.
@@ -571,6 +577,7 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
571577

572578
protected _destroy = new Subject<boolean>();
573579
protected _removeOnDestroy = true;
580+
protected _data: any;
574581

575582
/**
576583
* An @Input property that specifies the offset of the dragged element relative to the mouse in pixels.

0 commit comments

Comments
 (0)