Skip to content

Commit f163a12

Browse files
authored
Merge branch 'master' into iganchev/select-implement-hint
2 parents 0e74953 + eb13c97 commit f163a12

21 files changed

+137
-97
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ All notable changes for each version of this project will be documented in this
55
## 10.0.0
66

77
### General
8+
- `igxGrid`
9+
- **Behavioral Change** - Group rows now display the group column's header name instead of field when one is available.
810
- `igx-select`, `igx-combo`, `igx-drop-down`
9-
- **Behavioral Change** - The select, combo, and dropdown items now have display block and text-overflow ellipsis enabled by default.
11+
- **Behavioral Change** - The select, combo, and dropdown items now have display block and text-overflow ellipsis enabled by default.
1012
- `IgxTransaction` - The `onStateUpdate` now emits with information of its origin. The emitted value is of type `StateUpdateEvent`, which has two properties:
1113
- `origin` - it can vary within the values of the `TransactionEventOrigin` interface;
1214
- `actions` - contains information about the transactions, that caused the emission of the event.
@@ -23,7 +25,7 @@ All notable changes for each version of this project will be documented in this
2325
### General
2426
- `IgxHierarchicalGrid`
2527
- `onGridInitialized` - New output has been exposed. Emitted after a grid is being initialized for the corresponding row island.
26-
28+
- **Behavioral Change** - When moving a column `DropPosition.None` is now acting like `DropPosition.AfterDropTarget`.
2729
## 9.1.0
2830

2931
### General

projects/igniteui-angular/src/lib/data-operations/groupby-record.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ISortingExpression } from './sorting-expression.interface';
2+
import { IgxColumnComponent } from '../grids/columns/column.component';
23

34
/**
45
* @hidden
@@ -13,4 +14,5 @@ export interface IGroupByRecord {
1314
groupParent: IGroupByRecord;
1415
groups?: IGroupByRecord[];
1516
height: number;
17+
column?: IgxColumnComponent;
1618
}

projects/igniteui-angular/src/lib/data-operations/sorting-strategy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,16 @@ export class IgxSorting implements IGridSortingStrategy {
160160
let result = [];
161161
while (i < data.length) {
162162
const group = this.groupedRecordsByExpression(data, i, expressions[level]);
163+
const column = grid ? grid.getColumnByName(expressions[level].fieldName) : null;
163164
const groupRow: IGroupByRecord = {
164165
expression: expressions[level],
165166
level,
166167
records: cloneArray(group),
167168
value: group[0][expressions[level].fieldName],
168169
groupParent: parent,
169170
groups: [],
170-
height: grid ? grid.renderedRowHeight : null
171+
height: grid ? grid.renderedRowHeight : null,
172+
column: column
171173
};
172174
if (parent) {
173175
parent.groups.push(groupRow);

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,16 +1584,30 @@ export class IgxColumnComponent implements AfterContentInit {
15841584
this._pinned = true;
15851585
this.pinnedChange.emit(this._pinned);
15861586
this._unpinnedIndex = grid._unpinnedColumns.indexOf(this);
1587-
index = index !== undefined ? index : grid._pinnedColumns.length;
1587+
const rootPinnedCols = grid._pinnedColumns.filter((c) => c.level === 0);
1588+
index = index !== undefined ? index : rootPinnedCols.length;
15881589
const targetColumn = grid._pinnedColumns[index];
15891590
const args = { column: this, insertAtIndex: index, isPinned: true };
15901591
grid.onColumnPinning.emit(args);
15911592

15921593
if (grid._pinnedColumns.indexOf(this) === -1) {
1593-
grid._pinnedColumns.splice(args.insertAtIndex, 0, this);
1594+
if (!grid.hasColumnGroups) {
1595+
grid._pinnedColumns.splice(args.insertAtIndex, 0, this);
1596+
} else {
1597+
// insert based only on root collection
1598+
rootPinnedCols.splice(args.insertAtIndex, 0, this);
1599+
let allPinned = [];
1600+
// re-create hierarchy
1601+
rootPinnedCols.forEach(group => {
1602+
allPinned.push(group);
1603+
allPinned = allPinned.concat(group.allChildren);
1604+
});
1605+
grid._pinnedColumns = allPinned;
1606+
}
15941607

15951608
if (grid._unpinnedColumns.indexOf(this) !== -1) {
1596-
grid._unpinnedColumns.splice(grid._unpinnedColumns.indexOf(this), 1);
1609+
const childrenCount = this.allChildren.length;
1610+
grid._unpinnedColumns.splice(grid._unpinnedColumns.indexOf(this), 1 + childrenCount);
15971611
}
15981612
}
15991613

@@ -1650,13 +1664,16 @@ export class IgxColumnComponent implements AfterContentInit {
16501664

16511665
const targetColumn = grid._unpinnedColumns[index];
16521666

1653-
grid._unpinnedColumns.splice(index, 0, this);
1654-
if (grid._pinnedColumns.indexOf(this) !== -1) {
1655-
grid._pinnedColumns.splice(grid._pinnedColumns.indexOf(this), 1);
1667+
if (!hasIndex) {
1668+
grid._unpinnedColumns.splice(index, 0, this);
1669+
if (grid._pinnedColumns.indexOf(this) !== -1) {
1670+
grid._pinnedColumns.splice(grid._pinnedColumns.indexOf(this), 1);
1671+
}
16561672
}
16571673

1674+
16581675
if (hasIndex) {
1659-
grid._moveColumns(this, targetColumn);
1676+
grid.moveColumn(this, targetColumn);
16601677
}
16611678

16621679
if (this.columnGroup) {

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

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ import { IgxColumnGroupComponent } from './columns/column-group.component';
151151
import { IGridSortingStrategy } from '../data-operations/sorting-strategy';
152152
import { IgxRowDragGhostDirective, IgxDragIndicatorIconDirective } from './row-drag.directive';
153153
import { isNumber } from 'util';
154+
import { showMessage } from '../core/deprecateDecorators';
154155

155156
const MINIMUM_COLUMN_WIDTH = 136;
156157
const FILTER_ROW_HEIGHT = 50;
157-
158+
let warningShown = false;
158159
// By default row editing overlay outlet is inside grid body so that overlay is hidden below grid header when scrolling.
159160
// In cases when grid has 1-2 rows there isn't enough space in grid body and row editing overlay should be shown above header.
160161
// Default row editing overlay height is higher then row height that is why the case is valid also for row with 2 rows.
@@ -3773,21 +3774,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
37733774
*/
37743775
protected _moveColumns(from: IgxColumnComponent, to: IgxColumnComponent, pos: DropPosition) {
37753776
const list = this.columnList.toArray();
3776-
const fromIndex = list.indexOf(from);
3777-
let toIndex = list.indexOf(to);
3778-
3779-
if (pos === DropPosition.BeforeDropTarget) {
3780-
toIndex--;
3781-
if (toIndex < 0) {
3782-
toIndex = 0;
3783-
}
3784-
}
3785-
3786-
if (pos === DropPosition.AfterDropTarget) {
3787-
toIndex++;
3788-
}
3789-
3790-
list.splice(toIndex, 0, ...list.splice(fromIndex, 1));
3777+
this._reorderColumns(from, to, pos, list);
37913778
const newList = this._resetColumnList(list);
37923779
this.columnList.reset(newList);
37933780
this.columnList.notifyOnChanges();
@@ -3815,39 +3802,27 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
38153802
* @hidden
38163803
*/
38173804
protected _reorderColumns(from: IgxColumnComponent, to: IgxColumnComponent, position: DropPosition, columnCollection: any[]) {
3818-
let dropIndex = columnCollection.indexOf(to);
3819-
3820-
if (to.columnGroup) {
3821-
dropIndex += to.allChildren.length;
3822-
}
3805+
const fromIndex = columnCollection.indexOf(from);
3806+
const childColumnsCount = from.allChildren.length;
3807+
// remove item(s) to be moved.
3808+
const fromCollection = columnCollection.splice(fromIndex, childColumnsCount + 1);
38233809

3824-
if (position === DropPosition.BeforeDropTarget) {
3825-
dropIndex--;
3826-
}
3810+
let dropIndex = columnCollection.indexOf(to);
38273811

38283812
if (position === DropPosition.AfterDropTarget) {
38293813
dropIndex++;
3814+
if (to.columnGroup) {
3815+
dropIndex += to.allChildren.length;
3816+
}
38303817
}
3831-
3832-
columnCollection.splice(dropIndex, 0, ...columnCollection.splice(columnCollection.indexOf(from), 1));
3818+
columnCollection.splice(dropIndex, 0, ...fromCollection);
38333819
}
38343820
/**
38353821
* @hidden
38363822
*/
38373823
protected _moveChildColumns(parent: IgxColumnComponent, from: IgxColumnComponent, to: IgxColumnComponent, pos: DropPosition) {
38383824
const buffer = parent.children.toArray();
3839-
const fromIndex = buffer.indexOf(from);
3840-
let toIndex = buffer.indexOf(to);
3841-
3842-
if (pos === DropPosition.BeforeDropTarget) {
3843-
toIndex--;
3844-
}
3845-
3846-
if (pos === DropPosition.AfterDropTarget) {
3847-
toIndex++;
3848-
}
3849-
3850-
buffer.splice(toIndex, 0, ...buffer.splice(fromIndex, 1));
3825+
this._reorderColumns(from, to, pos, buffer);
38513826
parent.children.reset(buffer);
38523827
}
38533828
/**
@@ -3859,19 +3834,17 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
38593834
*/
38603835
public moveColumn(column: IgxColumnComponent, dropTarget: IgxColumnComponent, pos: DropPosition = DropPosition.None) {
38613836

3837+
if (column === dropTarget) {
3838+
return;
3839+
}
38623840
let position = pos;
3863-
const fromIndex = column.visibleIndex;
3864-
const toIndex = dropTarget.visibleIndex;
3865-
3866-
if (pos === DropPosition.BeforeDropTarget && fromIndex < toIndex) {
3867-
position = DropPosition.BeforeDropTarget;
3868-
} else if (pos === DropPosition.AfterDropTarget && fromIndex > toIndex) {
3869-
position = DropPosition.AfterDropTarget;
3870-
} else {
3871-
position = DropPosition.None;
3841+
if (position === DropPosition.None) {
3842+
warningShown = showMessage(
3843+
'DropPosition.None is deprecated.' +
3844+
'Use DropPosition.AfterDropTarget instead.',
3845+
warningShown);
3846+
position = DropPosition.AfterDropTarget;
38723847
}
3873-
3874-
38753848
if ((column.level !== dropTarget.level) ||
38763849
(column.topLevelParent !== dropTarget.topLevelParent)) {
38773850
return;
@@ -3929,6 +3902,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
39293902
if (this.hasColumnLayouts) {
39303903
this.columns.filter(x => x.columnLayout).forEach(x => x.populateVisibleIndexes());
39313904
}
3905+
// after reordering is done reset cached column collections.
3906+
this.resetColumnCollections();
3907+
column.resetCaches();
39323908

39333909
const args = {
39343910
source: column,
@@ -5212,8 +5188,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
52125188
* @hidden
52135189
*/
52145190
protected reinitPinStates() {
5215-
this._pinnedColumns = (this.hasColumnGroups) ? this.columnList.filter((c) => c.pinned) :
5216-
this.columnList.filter((c) => c.pinned).sort((a, b) => this._pinnedColumns.indexOf(a) - this._pinnedColumns.indexOf(b));
5191+
this._pinnedColumns = this.columnList
5192+
.filter((c) => c.pinned).sort((a, b) => this._pinnedColumns.indexOf(a) - this._pinnedColumns.indexOf(b));
52175193
this._unpinnedColumns = this.hasColumnGroups ? this.columnList.filter((c) => !c.pinned) :
52185194
this.columnList.filter((c) => !c.pinned)
52195195
.sort((a, b) => this._unpinnedColumns.indexOf(a) - this._unpinnedColumns.indexOf(b));

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
1414
import { IgxGridHeaderComponent } from '../headers/grid-header.component';
1515
import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec';
1616
import { wait } from '../../test-utils/ui-interactions.spec';
17+
import { DropPosition } from '../moving/moving.service';
1718

1819
const GRID_COL_THEAD_TITLE_CLASS = 'igx-grid__th-title';
1920
const GRID_COL_GROUP_THEAD_TITLE_CLASS = 'igx-grid__thead-title';
@@ -786,10 +787,10 @@ describe('IgxGrid - multi-column headers #grid', () => {
786787
const ci = fixture.componentInstance;
787788
const grid = ci.grid;
788789

789-
ci.idCol.pinned = true;
790+
ci.genInfoColGroup.pinned = true;
790791
tick();
791792
fixture.detectChanges();
792-
ci.genInfoColGroup.pinned = true;
793+
ci.idCol.pinned = true;
793794
tick();
794795
fixture.detectChanges();
795796
ci.postalCodeColGroup.pinned = true;
@@ -799,13 +800,14 @@ describe('IgxGrid - multi-column headers #grid', () => {
799800
tick();
800801
fixture.detectChanges();
801802

802-
testColumnsVisibleIndexes([ci.idCol].concat(ci.genInfoColList)
803+
testColumnsVisibleIndexes(ci.genInfoColList.concat(ci.idCol)
803804
.concat(ci.postalCodeColList).concat(ci.cityColList).concat(ci.countryColList)
804805
.concat(ci.regionColList).concat(ci.addressColList).concat(ci.phoneColList)
805806
.concat(ci.faxColList));
806807

807808
// unpinning with index
808809
expect(grid.unpinColumn(ci.genInfoColGroup, 2)).toBe(true);
810+
fixture.detectChanges();
809811
const postUnpinningColList = [ci.idCol].concat(ci.postalCodeColList).concat(ci.cityColList)
810812
.concat(ci.countryColList).concat(ci.regionColList).concat(ci.genInfoColList)
811813
.concat(ci.addressColList).concat(ci.phoneColList).concat(ci.faxColList);
@@ -814,31 +816,34 @@ describe('IgxGrid - multi-column headers #grid', () => {
814816

815817
// pinning to non-existent index
816818
expect(grid.pinColumn(ci.genInfoColGroup, 15)).toBe(false);
819+
fixture.detectChanges();
817820
testColumnsVisibleIndexes(postUnpinningColList);
818821
testColumnPinning(ci.genInfoColGroup, false);
819822

820823
// pinning to negative index
821824
expect(grid.pinColumn(ci.genInfoColGroup, -15)).toBe(false);
825+
fixture.detectChanges();
822826
testColumnsVisibleIndexes(postUnpinningColList);
823827
testColumnPinning(ci.genInfoColGroup, false);
824828

825829
// pinning with index
826830
expect(grid.pinColumn(ci.genInfoColGroup, 2)).toBe(true);
831+
fixture.detectChanges();
827832
const postPinningColList = [ci.idCol].concat(ci.postalCodeColList).concat(ci.genInfoColList)
828833
.concat(ci.cityColList).concat(ci.countryColList).concat(ci.regionColList)
829834
.concat(ci.addressColList).concat(ci.phoneColList).concat(ci.faxColList);
830835
testColumnsVisibleIndexes(postPinningColList);
831836
testColumnPinning(ci.genInfoColGroup, true);
832837

833-
// unpinning to non-existent index
834-
expect(grid.unpinColumn(ci.genInfoColGroup, 15)).toBe(false);
835-
testColumnsVisibleIndexes(postPinningColList);
836-
testColumnPinning(ci.genInfoColGroup, true);
838+
// // unpinning to non-existent index
839+
// expect(grid.unpinColumn(ci.genInfoColGroup, 15)).toBe(false);
840+
// testColumnsVisibleIndexes(postPinningColList);
841+
// testColumnPinning(ci.genInfoColGroup, true);
837842

838-
// unpinning to negative index
839-
expect(grid.unpinColumn(ci.genInfoColGroup, -15)).toBe(false);
840-
testColumnsVisibleIndexes(postPinningColList);
841-
testColumnPinning(ci.genInfoColGroup, true);
843+
// // unpinning to negative index
844+
// expect(grid.unpinColumn(ci.genInfoColGroup, -15)).toBe(false);
845+
// testColumnsVisibleIndexes(postPinningColList);
846+
// testColumnPinning(ci.genInfoColGroup, true);
842847
}));
843848

844849
it('Should initially pin the whole group when one column of the group is pinned', fakeAsync(() => {
@@ -927,7 +932,7 @@ describe('IgxGrid - multi-column headers #grid', () => {
927932
testColumnsOrder(genInfoCols.concat(locCols).concat(contactInfoCols));
928933

929934
// moving last to be first
930-
grid.moveColumn(ci.contactInfoColGroup, ci.genInfoColGroup);
935+
grid.moveColumn(ci.contactInfoColGroup, ci.genInfoColGroup, DropPosition.BeforeDropTarget);
931936
tick();
932937
fixture.detectChanges();
933938
testColumnsOrder(contactInfoCols.concat(genInfoCols).concat(locCols));
@@ -945,7 +950,7 @@ describe('IgxGrid - multi-column headers #grid', () => {
945950
testColumnsOrder(genInfoCols.concat(contactInfoCols).concat(locCols));
946951

947952
// moving inner to be first
948-
grid.moveColumn(ci.contactInfoColGroup, ci.genInfoColGroup);
953+
grid.moveColumn(ci.contactInfoColGroup, ci.genInfoColGroup, DropPosition.BeforeDropTarget);
949954
tick();
950955
fixture.detectChanges();
951956
testColumnsOrder(contactInfoCols.concat(genInfoCols).concat(locCols));
@@ -973,7 +978,7 @@ describe('IgxGrid - multi-column headers #grid', () => {
973978
ci.regionCol, ci.cityCol];
974979

975980
// moving last to be first
976-
grid.moveColumn(ci.postalCodeCol, ci.phoneCol);
981+
grid.moveColumn(ci.postalCodeCol, ci.phoneCol, DropPosition.BeforeDropTarget);
977982
tick();
978983
fixture.detectChanges();
979984
testColumnsOrder(genInfoAndLocCols.concat([ci.contactInfoColGroup,
@@ -994,7 +999,7 @@ describe('IgxGrid - multi-column headers #grid', () => {
994999
ci.phoneCol, ci.postalCodeCol, ci.faxCol]));
9951000

9961001
// moving inner to be first
997-
grid.moveColumn(ci.postalCodeCol, ci.phoneCol);
1002+
grid.moveColumn(ci.postalCodeCol, ci.phoneCol, DropPosition.BeforeDropTarget);
9981003
tick();
9991004
fixture.detectChanges();
10001005
testColumnsOrder(genInfoAndLocCols.concat([ci.contactInfoColGroup,
@@ -1029,14 +1034,14 @@ describe('IgxGrid - multi-column headers #grid', () => {
10291034
const grid = ci.grid;
10301035

10311036
// moving a two-level col
1032-
grid.moveColumn(ci.phoneCol, ci.locationColGroup);
1037+
grid.moveColumn(ci.phoneCol, ci.locationColGroup, DropPosition.BeforeDropTarget);
10331038
tick();
10341039
fixture.detectChanges();
10351040
testColumnsOrder([ci.contactInfoColGroup, ci.phoneCol, ci.locationColGroup, ci.countryCol,
10361041
ci.genInfoColGroup, ci.companyNameCol, ci.cityCol]);
10371042

10381043
// moving a three-level col
1039-
grid.moveColumn(ci.cityCol, ci.contactInfoColGroup);
1044+
grid.moveColumn(ci.cityCol, ci.contactInfoColGroup, DropPosition.BeforeDropTarget);
10401045
tick();
10411046
fixture.detectChanges();
10421047
const colsOrder = [ci.cityCol, ci.contactInfoColGroup, ci.phoneCol,
@@ -1090,7 +1095,7 @@ describe('IgxGrid - multi-column headers #grid', () => {
10901095
fixture.detectChanges();
10911096

10921097
// moving group from unpinned to pinned
1093-
ci.grid.moveColumn(ci.phoneColGroup, ci.idCol);
1098+
ci.grid.moveColumn(ci.phoneColGroup, ci.idCol, DropPosition.BeforeDropTarget);
10941099
tick();
10951100
fixture.detectChanges();
10961101
let postMovingOrder = ci.phoneColList.concat([ci.idCol]).concat(ci.genInfoColList)

0 commit comments

Comments
 (0)