Skip to content

Commit a2260eb

Browse files
authored
Merge pull request #9477 from IgniteUI/mkirkova/fix-9116-master
rename igx-column DataType type to GridColumnDataType
2 parents 408d294 + ca27590 commit a2260eb

29 files changed

+411
-333
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ All notable changes for each version of this project will be documented in this
3636
- `onToolbarExporting` -> `toolbarExporting`
3737
- `onRangeSelection` -> `rangeSelected`
3838
- `IgxGridRowComponent`, `IgxGridGroupByRowComponent`, `IgxTreeGridRowComponent`, `IgxHierarchicalRowComponent` are no longer exposed in the public API. Automatic migration will change these imports with `RowType`.
39+
- The IgxColumn data type `DataType` is renamed to `GridColumnDataType`.
3940
- **Behavioral changes**
4041
- `getRowByIndex`, `getRowByKey`, `cell.row` now return an object implemening the `RowType` interface.
4142
- `dragData` emitted with `IRowDragEndEventArgs`, `IRowDragStartEventArgs` is now `RowType`
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "../../common/schema/class.schema.json",
3+
"changes": [
4+
{
5+
"name": "DataType",
6+
"replaceWith": "GridColumnDataType"
7+
}
8+
]
9+
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,4 +1636,43 @@ export class SimpleComponent {
16361636
}
16371637
}`);
16381638
});
1639+
1640+
it('should rename DataType to GridColumnDataType', async () => {
1641+
appTree.create(
1642+
'/testSrc/appPrefix/component/test.component.ts',
1643+
`import { Component, ViewChild } from '@angular/core';
1644+
import { IgxColumnComponent, DataType } from 'igniteui-angular';
1645+
1646+
@Component({
1647+
selector: 'column-dataType',
1648+
templateUrl: './test.component.html',
1649+
styleUrls: ['./test.component.scss']
1650+
})
1651+
export class ColumnDataType {
1652+
public dataType: DataType = DataType.Boolean;
1653+
}
1654+
`);
1655+
const tree = await schematicRunner
1656+
.runSchematicAsync(migrationName, {}, appTree)
1657+
.toPromise();
1658+
1659+
const expectedContent = `import { Component, ViewChild } from '@angular/core';
1660+
import { IgxColumnComponent, GridColumnDataType } from 'igniteui-angular';
1661+
1662+
@Component({
1663+
selector: 'column-dataType',
1664+
templateUrl: './test.component.html',
1665+
styleUrls: ['./test.component.scss']
1666+
})
1667+
export class ColumnDataType {
1668+
public dataType: GridColumnDataType = GridColumnDataType.Boolean;
1669+
}
1670+
`;
1671+
1672+
expect(
1673+
tree.readContent(
1674+
'/testSrc/appPrefix/component/test.component.ts'
1675+
)
1676+
).toEqual(expectedContent);
1677+
});
16391678
});

projects/igniteui-angular/src/lib/data-operations/README-DATAUTIL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ items: Array<Object> = [
8686
* **SortingStrategy** - class which implements **ISortingStrategy** interface. It specifies sorting algorithm.
8787
* **FilteringStrategy** - class which implements **IFilteringStrategy** interface. It specifies filtering algorithm.
8888
* **FilteringLogic** - class which describes the filtering logic between the different filtering expressions. Its values are **FilteringLogic.And**, **FilteringLogic.Or**.
89-
* **DataType** - enumeration which represent basic data types. Its values are:
90-
* **DataType.Boolean**
91-
* **DataType.Date**
92-
* **DataType.Number**
93-
* **DataType.String**
89+
* **GridColumnDataType** - enumeration which represent basic data types. Its values are:
90+
* **GridColumnDataType.Boolean**
91+
* **GridColumnDataType.Date**
92+
* **GridColumnDataType.Number**
93+
* **GridColumnDataType.String**
9494

projects/igniteui-angular/src/lib/data-operations/data-util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { GridType } from '../grids/common/grid.interface';
2020
/**
2121
* @hidden
2222
*/
23-
export const DataType = mkenum({
23+
export const GridColumnDataType = mkenum({
2424
String: 'string',
2525
Number: 'number',
2626
Boolean: 'boolean',
@@ -30,7 +30,7 @@ export const DataType = mkenum({
3030
Currency: 'currency',
3131
Percent: 'percent'
3232
});
33-
export type DataType = (typeof DataType)[keyof typeof DataType];
33+
export type GridColumnDataType = (typeof GridColumnDataType)[keyof typeof GridColumnDataType];
3434

3535
/**
3636
* @hidden
@@ -221,8 +221,8 @@ export class DataUtil {
221221
return data;
222222
}
223223

224-
public static parseValue(dataType: DataType, value: any): any {
225-
if (dataType === DataType.Number || dataType === DataType.Currency || dataType === DataType.Percent) {
224+
public static parseValue(dataType: GridColumnDataType, value: any): any {
225+
if (dataType === GridColumnDataType.Number || dataType === GridColumnDataType.Currency || dataType === GridColumnDataType.Percent) {
226226
value = parseFloat(value);
227227
}
228228

projects/igniteui-angular/src/lib/data-operations/test-util/data-generator.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {DataType} from '../data-util';
1+
import { GridColumnDataType } from '../data-util';
22

33
/**
44
* @hidden
@@ -15,23 +15,23 @@ const COUNT_COLS = 4;
1515
*/
1616
export interface IDataColumn {
1717
fieldName: string;
18-
type: DataType;
18+
type: GridColumnDataType;
1919
}
2020

2121
/**
2222
* @hidden
2323
*/
2424
export class DataGenerator {
2525
public columns: IDataColumn[] = [];
26-
public data: any [] = [];
26+
public data: any[] = [];
2727
constructor(countRows = COUNT_ROWS, countCols = COUNT_COLS) {
2828
this.columns = this.generateColumns(countCols);
2929
this.data = this.generateData(countRows);
3030
}
3131
public generateArray(startValue, endValue) {
3232
const len = Math.abs(startValue - endValue);
3333
const decrement = startValue > endValue;
34-
return Array.from({length: len + 1}, (e, i) => decrement ? startValue - i : startValue + i);
34+
return Array.from({ length: len + 1 }, (e, i) => decrement ? startValue - i : startValue + i);
3535
}
3636
public getValuesForColumn(data, fieldName) {
3737
return data.map((x) => x[fieldName]);
@@ -47,19 +47,19 @@ export class DataGenerator {
4747
const defaultColumns: IDataColumn[] = [
4848
{
4949
fieldName: 'number',
50-
type: DataType.Number
50+
type: GridColumnDataType.Number
5151
},
5252
{
5353
fieldName: 'string',
54-
type: DataType.String
54+
type: GridColumnDataType.String
5555
},
5656
{
5757
fieldName: 'date',
58-
type: DataType.Date
58+
type: GridColumnDataType.Date
5959
},
6060
{
6161
fieldName: 'boolean',
62-
type: DataType.Boolean
62+
type: GridColumnDataType.Boolean
6363
}
6464
];
6565
if (countCols <= 0) {
@@ -73,7 +73,7 @@ export class DataGenerator {
7373
for (i = 0; i < len; i++) {
7474
res.push({
7575
fieldName: `col${i}`,
76-
type: DataType.String
76+
type: GridColumnDataType.String
7777
});
7878
}
7979
return res;
@@ -90,13 +90,13 @@ export class DataGenerator {
9090
for (j = 0; j < this.columns.length; j++) {
9191
col = this.columns[j];
9292
switch (col.type) {
93-
case DataType.Number:
93+
case GridColumnDataType.Number:
9494
val = i;
9595
break;
96-
case DataType.Date:
96+
case GridColumnDataType.Date:
9797
val = new Date(Date.now() + i * 24 * 60 * 60 * 1000);
9898
break;
99-
case DataType.Boolean:
99+
case GridColumnDataType.Boolean:
100100
val = !!(i % 2);
101101
break;
102102
default:

projects/igniteui-angular/src/lib/grids/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Inputs available on the **IgxGridColumnComponent** to define columns:
352352
|`index`|string|Column index|
353353
|`filteringIgnoreCase`|boolean|Ignore capitalization of strings when filtering is applied. Defaults to _true_.|
354354
|`sortingIgnoreCase`|boolean|Ignore capitalization of strings when sorting is applied. Defaults to _true_.|
355-
|`dataType`|DataType|One of string, number, boolean or Date. When filtering is enabled the filter UI conditions are based on the `dataType` of the column. Defaults to `string` if it is not provided. With `autoGenerate` enabled the grid will try to resolve the correct data type for each column based on the data source.|
355+
|`dataType`|GridColumnDataType|One of string, number, boolean or Date. When filtering is enabled the filter UI conditions are based on the `dataType` of the column. Defaults to `string` if it is not provided. With `autoGenerate` enabled the grid will try to resolve the correct data type for each column based on the data source.|
356356
|`pinned`|boolean|Set column to be pinned or not|
357357
|`searchable`|boolean|Determines whether the column is included in the search. If set to false, the cell values for this column will not be included in the results of the search API of the grid (defaults to true)|
358358
|`groupable`|boolean| Determines whether the column may be grouped via the UI.|

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { Subject } from 'rxjs';
33
import { cloneArray, isEqual, reverseMapper, mergeObjects } from '../core/utils';
4-
import { DataUtil, DataType } from '../data-operations/data-util';
4+
import { DataUtil, GridColumnDataType } from '../data-operations/data-util';
55
import { ISortingExpression, SortingDirection } from '../data-operations/sorting-expression.interface';
66
import { IgxGridCellComponent } from './cell.component';
77
import { IgxGridBaseDirective } from './grid-base.directive';
@@ -17,7 +17,7 @@ import { IGridEditEventArgs, IRowToggleEventArgs } from './common/events';
1717
* @hidden
1818
*/
1919
@Injectable()
20-
export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
20+
export class GridBaseAPIService<T extends IgxGridBaseDirective & GridType> {
2121

2222

2323
public grid: T;
@@ -33,7 +33,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
3333
const grid = this.grid;
3434
let data = grid.filteredData;
3535
if (data && grid.hasPinnedRecords) {
36-
data = grid._filteredUnpinnedData;
36+
data = grid._filteredUnpinnedData;
3737
}
3838
if (!data) {
3939
if (grid.transactions.enabled) {
@@ -47,7 +47,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
4747
const tempData = grid.primaryKey ? data.map(rec => rec[grid.primaryKey]) : data;
4848
const index = tempData.indexOf(rowID);
4949
if (index !== -1) {
50-
data.splice(index, 1);
50+
data.splice(index, 1);
5151
}
5252
});
5353
} else {
@@ -138,7 +138,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
138138
}
139139
}
140140

141-
public update_add_cell(cell: IgxCell, value: any, event?: Event): IGridEditEventArgs {
141+
public update_add_cell(cell: IgxCell, value: any, event?: Event): IGridEditEventArgs {
142142
cell.editValue = value;
143143

144144
const args = cell.createEditEventArgs(true, event);
@@ -194,7 +194,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
194194
}
195195
}
196196
if (!this.grid.rowEditable || !this.crudService.row ||
197-
this.crudService.row.id !== cell.id.rowID || !this.grid.transactions.enabled) {
197+
this.crudService.row.id !== cell.id.rowID || !this.grid.transactions.enabled) {
198198
this.grid.summaryService.clearSummaryCache(args);
199199
this.grid.pipeTrigger++;
200200
}
@@ -226,7 +226,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
226226
return args;
227227
}
228228

229-
const cachedRowData = { ... args.oldValue };
229+
const cachedRowData = { ...args.oldValue };
230230
if (rowInEditMode) {
231231
const hasChanges = grid.transactions.getState(args.rowID, true);
232232
grid.transactions.endPending(false);
@@ -296,7 +296,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
296296
}
297297

298298
public should_apply_number_style(column: ColumnType): boolean {
299-
return column.dataType === DataType.Number;
299+
return column.dataType === GridColumnDataType.Number;
300300
}
301301

302302
public get_data(): any[] {
@@ -450,7 +450,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
450450
}
451451

452452
public get_rec_by_id(rowID) {
453-
return this.grid.primaryKey ? this.getRowData(rowID) : rowID;
453+
return this.grid.primaryKey ? this.getRowData(rowID) : rowID;
454454
}
455455

456456
public allow_expansion_state_change(rowID, expanded) {
@@ -517,7 +517,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
517517
* @param rowCurrentValue Current value of the row as it is with applied previous transactions
518518
* @param rowNewValue New value of the row
519519
*/
520-
protected updateData(grid, rowID, rowValueInDataSource: any, rowCurrentValue: any, rowNewValue: {[x: string]: any}) {
520+
protected updateData(grid, rowID, rowValueInDataSource: any, rowCurrentValue: any, rowNewValue: { [x: string]: any }) {
521521
if (grid.transactions.enabled) {
522522
const transaction: Transaction = {
523523
id: rowID,
@@ -550,7 +550,7 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
550550

551551
if (rowInEditMode && row.id === rowInEditMode.id) {
552552
row.data = { ...row.data, ...rowInEditMode.transactionState };
553-
// TODO: Workaround for updating a row in edit mode through the API
553+
// TODO: Workaround for updating a row in edit mode through the API
554554
} else if (this.grid.transactions.enabled) {
555555
const state = grid.transactions.getState(row.id);
556556
row.data = state ? Object.assign({}, row.data, state.value) : row.data;

0 commit comments

Comments
 (0)