Skip to content

Commit 730797e

Browse files
committed
refactor: Column moving behavior
1 parent daa8d75 commit 730797e

File tree

44 files changed

+234
-256
lines changed

Some content is hidden

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

44 files changed

+234
-256
lines changed

projects/igniteui-angular/src/lib/grids/columns/column-layout.component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ export class IgxColumnLayoutComponent extends IgxColumnGroupComponent implements
122122
} else {
123123
this.children.forEach(child => child.hidden = this.hidden);
124124
}
125-
126-
this.children.forEach(child => {
127-
child.movable = false;
128-
});
129125
}
130126

131127
/*

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
427427
/**
428428
* Sets/gets whether the column is movable.
429429
* Default value is `false`.
430+
*
431+
* @deprecated
432+
* Use `IgxGridComponent.moving` instead.
433+
*
430434
* ```typescript
431435
* let isMovable = this.column.movable;
432436
* ```
@@ -436,8 +440,6 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
436440
*
437441
* @memberof IgxColumnComponent
438442
*/
439-
@WatchColumnChanges()
440-
@notifyChanges()
441443
@Input()
442444
public movable = false;
443445
/**

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface GridType extends IGridDataBindable {
3232
renderedRowHeight: number;
3333
summaryPipeTrigger: number;
3434
hasColumnLayouts: boolean;
35+
moving: boolean;
3536

3637
filterMode: FilterMode;
3738

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<igx-excel-style-sorting *ngIf="column?.sortable">
1010
</igx-excel-style-sorting>
1111

12-
<igx-excel-style-moving *ngIf="column?.movable">
12+
<igx-excel-style-moving *ngIf="grid?.moving">
1313
</igx-excel-style-moving>
1414

1515
<igx-excel-style-pinning *ngIf="!column?.disablePinning && displayDensity==='comfortable'">

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
195195
@Input()
196196
public autoGenerate = false;
197197

198+
/**
199+
* Controls whether columns moving is enabled in the grid.
200+
*
201+
*/
202+
@Input()
203+
public moving = false;
204+
198205
/**
199206
* Gets/Sets a custom template when empty.
200207
*
@@ -4905,13 +4912,16 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
49054912
/**
49064913
* Returns if the `IgxGridComponent` has moveable columns.
49074914
*
4915+
* @deprecated
4916+
* Use `IgxGridComponent.moving` instead.
4917+
*
49084918
* @example
49094919
* ```typescript
49104920
* const movableGrid = this.grid.hasMovableColumns;
49114921
* ```
49124922
*/
49134923
public get hasMovableColumns(): boolean {
4914-
return this.columnList && this.columnList.some((col) => col.movable);
4924+
return this.moving;
49154925
}
49164926

49174927
/**

projects/igniteui-angular/src/lib/grids/grid/column-moving.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ describe('IgxGrid - Column Moving #grid', () => {
269269

270270

271271
it('Should reorder only movable columns when dropping the ghost image on an interactive area.', (async () => {
272+
pending('Check applicability after moving behavior change');
272273
const headers: DebugElement[] = fixture.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS));
273274

274275
expect(grid.columns[0].movable).toBeTruthy();

projects/igniteui-angular/src/lib/grids/grid/column-selection.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,6 @@ describe('IgxGrid - Column Selection #grid', () => {
10911091
});
10921092

10931093
it('Moving: Verify that when move a column, it stays selected', () => {
1094-
colProductID.movable = true;
1095-
colProductName.movable = true;
10961094
colProductID.selected = true;
10971095
fix.detectChanges();
10981096

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
29162916
}));
29172917

29182918
it('Should move column left/right when clicking buttons.', fakeAsync(() => {
2919-
grid.columns[2].movable = true;
2919+
grid.moving = true;
29202920
fix.detectChanges();
29212921

29222922
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
@@ -2957,7 +2957,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
29572957
expect(grid.pinnedColumns.length).toBe(1);
29582958

29592959
const columnToMove = grid.unpinnedColumns[grid.unpinnedColumns.length - 1];
2960-
columnToMove.movable = true;
2960+
grid.moving = true;
29612961

29622962
GridFunctions.clickExcelFilterIconFromCode(fix, grid, columnToMove.field);
29632963

@@ -3415,11 +3415,10 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
34153415
}));
34163416

34173417
it('Should move pinned column correctly by using move buttons', fakeAsync(() => {
3418+
grid.moving = true;
34183419
const productNameCol = grid.getColumnByName('ProductName');
34193420
const idCol = grid.getColumnByName('ID');
3420-
productNameCol.movable = true;
34213421
productNameCol.pinned = true;
3422-
idCol.movable = true;
34233422
idCol.pinned = true;
34243423
fix.detectChanges();
34253424

@@ -3460,11 +3459,10 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
34603459
}));
34613460

34623461
it('Should move unpinned column correctly by using move buttons', fakeAsync(() => {
3462+
grid.moving = true;
34633463
const productNameCol = grid.getColumnByName('ProductName');
34643464
const downloadsCol = grid.getColumnByName('Downloads');
3465-
productNameCol.movable = true;
34663465
productNameCol.pinned = true;
3467-
downloadsCol.movable = true;
34683466
fix.detectChanges();
34693467
expect(GridFunctions.getColumnHeaderTitleByIndex(fix, 0).innerText).toBe('ProductName');
34703468
expect(GridFunctions.getColumnHeaderTitleByIndex(fix, 2).innerText).toBe('Downloads');
@@ -3559,7 +3557,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
35593557
it('display density is properly applied on the excel style filtering component', fakeAsync(() => {
35603558
const column = grid.columns.find((c) => c.field === 'ProductName');
35613559
column.sortable = true;
3562-
column.movable = true;
3560+
grid.moving = true;
35633561
fix.detectChanges();
35643562

35653563
// Open excel style filtering component and verify its display density
@@ -3623,7 +3621,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
36233621
it('display density is properly applied on the excel style custom filtering dialog', fakeAsync(() => {
36243622
const column = grid.columns.find((c) => c.field === 'ProductName');
36253623
column.sortable = true;
3626-
column.movable = true;
3624+
grid.moving = true;
36273625
fix.detectChanges();
36283626

36293627
// Open excel style custom filtering dialog and verify its display density
@@ -5427,7 +5425,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
54275425
}));
54285426

54295427
it('Should move column left/right when clicking buttons from template', fakeAsync(() => {
5430-
grid.columns[2].movable = true;
5428+
grid.moving = true;
54315429
fix.detectChanges();
54325430

54335431
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
@@ -5884,7 +5882,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
58845882
fix.detectChanges();
58855883
// Make 'AnotherField' column movable.
58865884
const column = grid.columns.find((c) => c.field === 'AnotherField');
5887-
column.movable = true;
5885+
grid.moving = true;
58885886
fix.detectChanges();
58895887

58905888
// Pin the 'General Information' group by pinning its child 'ProductName' column.

projects/igniteui-angular/src/lib/grids/grid/grid-row-editing.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,9 +1416,9 @@ describe('IgxGrid - Row Editing #grid', () => {
14161416
}));
14171417

14181418
it(`Moving: Should exit edit mode when moving a column`, () => {
1419+
grid.moving = true;
14191420
const column = grid.columnList.filter(c => c.field === 'ProductName')[0];
14201421
const targetColumn = grid.columnList.filter(c => c.field === 'ProductID')[0];
1421-
column.movable = true;
14221422

14231423
fix.detectChanges();
14241424

projects/igniteui-angular/src/lib/grids/grid/grid-summary.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ describe('IgxGrid - Summaries #grid', () => {
580580
}));
581581

582582
it('Moving: should move summaries when move column', () => {
583+
grid.moving = true;
583584
const colUnitsInStock = grid.getColumnByName('UnitsInStock');
584585
const colProductID = grid.getColumnByName('ProductID');
585-
colUnitsInStock.movable = true;
586586
fix.detectChanges();
587587

588588
grid.moveColumn(colUnitsInStock, colProductID, DropPosition.BeforeDropTarget);

0 commit comments

Comments
 (0)