Skip to content

Commit a6dd214

Browse files
authored
Merge branch 'master' into pbozhinov/fix-7416
2 parents c4d5753 + 58bc3fc commit a6dd214

28 files changed

+390
-110
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ All notable changes for each version of this project will be documented in this
2222
### General
2323
- `IgxHierarchicalGrid`
2424
- `onGridInitialized` - New output has been exposed. Emitted after a grid is being initialized for the corresponding row island.
25-
25+
- **Behavioral Change** - When moving a column `DropPosition.None` is now acting like `DropPosition.AfterDropTarget`.
2626
## 9.1.0
2727

2828
### General

ROADMAP.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ To Be Updated
1919

2020
## Milestone 11 (Released June 2nd, 2020)
2121

22-
1. Dock Manger [#5980](https://github.com/IgniteUI/igniteui-angular/issues/5980)
23-
2. Range Date Picker [#5732](https://github.com/IgniteUI/igniteui-angular/issues/5732)
24-
3. Keyboard Navigation Enhancement [#6755](https://github.com/IgniteUI/igniteui-angular/issues/6755)
25-
4. Column freezing/Pinning on the right (igx-grid) [#5879](https://github.com/IgniteUI/igniteui-angular/issues/5879)
26-
5. Column Selection for IgxGrid [#6578](https://github.com/IgniteUI/igniteui-angular/issues/6578)
27-
6. Splitter [#6639](https://github.com/IgniteUI/igniteui-angular/issues/6639)
28-
7. Row Pinning IgxGrid [#6640](https://github.com/IgniteUI/igniteui-angular/issues/6640)
29-
8. Data Analysis Directive [#1752](https://github.com/IgniteUI/igniteui-angular-samples/issues/1752)
30-
9. Slider does not support RTL [#5212](https://github.com/igniteui/igniteui-angular/issues/5212)
31-
10. Circular Progress Indicator does not support RTL [#5903](https://github.com/igniteui/igniteui-angular/issues/5903)
32-
11. Action Strip [#6941](https://github.com/IgniteUI/igniteui-angular/issues/6941)
33-
12. Theme igx-component scrollbars [#6675](https://github.com/IgniteUI/igniteui-angular/issues/6675)
34-
13. Use CSS variables by default [#6803](https://github.com/IgniteUI/igniteui-angular/issues/6675)
22+
1. **[DONE]** Dock Manger - Public Preview [#5980](https://github.com/IgniteUI/igniteui-angular/issues/5980)
23+
2. **[DONE]** Range Date Picker [#5732](https://github.com/IgniteUI/igniteui-angular/issues/5732)
24+
3. **[DONE]** Keyboard Navigation Enhancement [#6755](https://github.com/IgniteUI/igniteui-angular/issues/6755)
25+
4. **[DONE]** Column freezing/Pinning on the right (igx-grid) [#5879](https://github.com/IgniteUI/igniteui-angular/issues/5879)
26+
5. **[DONE]** Column Selection for IgxGrid [#6578](https://github.com/IgniteUI/igniteui-angular/issues/6578)
27+
6. **[DONE]** Splitter [#6639](https://github.com/IgniteUI/igniteui-angular/issues/6639)
28+
7. **[DONE]** Row Pinning IgxGrid [#6640](https://github.com/IgniteUI/igniteui-angular/issues/6640)
29+
8. **[DONE]** Data Analysis Directive [#1752](https://github.com/IgniteUI/igniteui-angular-samples/issues/1752)
30+
9. **[DONE]** Slider does not support RTL [#5212](https://github.com/igniteui/igniteui-angular/issues/5212)
31+
10. **[DONE]** Circular Progress Indicator does not support RTL [#5903](https://github.com/igniteui/igniteui-angular/issues/5903)
32+
11. **[DONE]** Action Strip [#6941](https://github.com/IgniteUI/igniteui-angular/issues/6941)
33+
12. **[DONE]** Theme igx-component scrollbars [#6675](https://github.com/IgniteUI/igniteui-angular/issues/6675)
34+
13. **[DONE]** Use CSS variables by default [#6803](https://github.com/IgniteUI/igniteui-angular/issues/6675)
3535

3636
## Milestone 10 (Released February 10th, 2020)
3737

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,26 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
179179
* this.parentVirtDir.totalItemCount = data.Count;
180180
* ```
181181
*/
182-
public totalItemCount: number = null;
182+
public get totalItemCount() {
183+
return this._totalItemCount;
184+
}
185+
186+
public set totalItemCount(val) {
187+
if (this._totalItemCount !== val) {
188+
this._totalItemCount = val;
189+
// update sizes in case total count changes.
190+
const newSize = this.initSizesCache(this.igxForOf);
191+
const sizeDiff = this.scrollComponent.size - newSize;
192+
this.scrollComponent.size = newSize;
193+
const lastChunkExceeded = this.state.startIndex + this.state.chunkSize > val;
194+
if (lastChunkExceeded) {
195+
this.state.startIndex = val - this.state.chunkSize;
196+
}
197+
this._adjustScrollPositionAfterSizeChange(sizeDiff);
198+
}
199+
}
200+
201+
private _totalItemCount: number = null;
183202

184203
/**
185204
* An event that is emitted after a new chunk has been loaded.
@@ -320,7 +339,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
320339
/**
321340
* @hidden
322341
*/
323-
protected get isRemote(): boolean {
342+
public get isRemote(): boolean {
324343
return this.totalItemCount !== null;
325344
}
326345

@@ -1117,13 +1136,17 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
11171136
const newHeight = this.initSizesCache(this.igxForOf);
11181137

11191138
const diff = oldHeight - newHeight;
1139+
this._adjustScrollPositionAfterSizeChange(diff);
1140+
}
11201141

1142+
private _adjustScrollPositionAfterSizeChange(sizeDiff) {
11211143
// if data has been changed while container is scrolled
11221144
// should update scroll top/left according to change so that same startIndex is in view
1123-
if (Math.abs(diff) > 0 && this.scrollPosition > 0) {
1145+
if (Math.abs(sizeDiff) > 0 && this.scrollPosition > 0) {
11241146
this.recalcUpdateSizes();
11251147
const offset = parseInt(this.dc.instance._viewContainer.element.nativeElement.style.top, 10);
1126-
this.scrollPosition = this.sizesCache[this.state.startIndex] - offset;
1148+
const newSize = this.sizesCache[this.state.startIndex] - offset;
1149+
this.scrollPosition = newSize === this.scrollPosition ? newSize + 1 : newSize;
11271150
}
11281151
}
11291152

@@ -1525,7 +1548,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15251548
if (changes && !this.isRemote) {
15261549
newHeight = this.handleCacheChanges(changes);
15271550
} else {
1528-
newHeight = this.initSizesCache(this.igxForOf);
1551+
return;
15291552
}
15301553

15311554
const diff = oldHeight - newHeight;

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.
@@ -3756,21 +3757,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
37563757
*/
37573758
protected _moveColumns(from: IgxColumnComponent, to: IgxColumnComponent, pos: DropPosition) {
37583759
const list = this.columnList.toArray();
3759-
const fromIndex = list.indexOf(from);
3760-
let toIndex = list.indexOf(to);
3761-
3762-
if (pos === DropPosition.BeforeDropTarget) {
3763-
toIndex--;
3764-
if (toIndex < 0) {
3765-
toIndex = 0;
3766-
}
3767-
}
3768-
3769-
if (pos === DropPosition.AfterDropTarget) {
3770-
toIndex++;
3771-
}
3772-
3773-
list.splice(toIndex, 0, ...list.splice(fromIndex, 1));
3760+
this._reorderColumns(from, to, pos, list);
37743761
const newList = this._resetColumnList(list);
37753762
this.columnList.reset(newList);
37763763
this.columnList.notifyOnChanges();
@@ -3798,39 +3785,27 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
37983785
* @hidden
37993786
*/
38003787
protected _reorderColumns(from: IgxColumnComponent, to: IgxColumnComponent, position: DropPosition, columnCollection: any[]) {
3801-
let dropIndex = columnCollection.indexOf(to);
3802-
3803-
if (to.columnGroup) {
3804-
dropIndex += to.allChildren.length;
3805-
}
3788+
const fromIndex = columnCollection.indexOf(from);
3789+
const childColumnsCount = from.allChildren.length;
3790+
// remove item(s) to be moved.
3791+
const fromCollection = columnCollection.splice(fromIndex, childColumnsCount + 1);
38063792

3807-
if (position === DropPosition.BeforeDropTarget) {
3808-
dropIndex--;
3809-
}
3793+
let dropIndex = columnCollection.indexOf(to);
38103794

38113795
if (position === DropPosition.AfterDropTarget) {
38123796
dropIndex++;
3797+
if (to.columnGroup) {
3798+
dropIndex += to.allChildren.length;
3799+
}
38133800
}
3814-
3815-
columnCollection.splice(dropIndex, 0, ...columnCollection.splice(columnCollection.indexOf(from), 1));
3801+
columnCollection.splice(dropIndex, 0, ...fromCollection);
38163802
}
38173803
/**
38183804
* @hidden
38193805
*/
38203806
protected _moveChildColumns(parent: IgxColumnComponent, from: IgxColumnComponent, to: IgxColumnComponent, pos: DropPosition) {
38213807
const buffer = parent.children.toArray();
3822-
const fromIndex = buffer.indexOf(from);
3823-
let toIndex = buffer.indexOf(to);
3824-
3825-
if (pos === DropPosition.BeforeDropTarget) {
3826-
toIndex--;
3827-
}
3828-
3829-
if (pos === DropPosition.AfterDropTarget) {
3830-
toIndex++;
3831-
}
3832-
3833-
buffer.splice(toIndex, 0, ...buffer.splice(fromIndex, 1));
3808+
this._reorderColumns(from, to, pos, buffer);
38343809
parent.children.reset(buffer);
38353810
}
38363811
/**
@@ -3842,19 +3817,17 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
38423817
*/
38433818
public moveColumn(column: IgxColumnComponent, dropTarget: IgxColumnComponent, pos: DropPosition = DropPosition.None) {
38443819

3820+
if (column === dropTarget) {
3821+
return;
3822+
}
38453823
let position = pos;
3846-
const fromIndex = column.visibleIndex;
3847-
const toIndex = dropTarget.visibleIndex;
3848-
3849-
if (pos === DropPosition.BeforeDropTarget && fromIndex < toIndex) {
3850-
position = DropPosition.BeforeDropTarget;
3851-
} else if (pos === DropPosition.AfterDropTarget && fromIndex > toIndex) {
3852-
position = DropPosition.AfterDropTarget;
3853-
} else {
3854-
position = DropPosition.None;
3824+
if (position === DropPosition.None) {
3825+
warningShown = showMessage(
3826+
'DropPosition.None is deprecated.' +
3827+
'Use DropPosition.AfterDropTarget instead.',
3828+
warningShown);
3829+
position = DropPosition.AfterDropTarget;
38553830
}
3856-
3857-
38583831
if ((column.level !== dropTarget.level) ||
38593832
(column.topLevelParent !== dropTarget.topLevelParent)) {
38603833
return;
@@ -3912,6 +3885,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
39123885
if (this.hasColumnLayouts) {
39133886
this.columns.filter(x => x.columnLayout).forEach(x => x.populateVisibleIndexes());
39143887
}
3888+
// after reordering is done reset cached column collections.
3889+
this.resetColumnCollections();
3890+
column.resetCaches();
39153891

39163892
const args = {
39173893
source: column,
@@ -5195,8 +5171,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
51955171
* @hidden
51965172
*/
51975173
protected reinitPinStates() {
5198-
this._pinnedColumns = (this.hasColumnGroups) ? this.columnList.filter((c) => c.pinned) :
5199-
this.columnList.filter((c) => c.pinned).sort((a, b) => this._pinnedColumns.indexOf(a) - this._pinnedColumns.indexOf(b));
5174+
this._pinnedColumns = this.columnList
5175+
.filter((c) => c.pinned).sort((a, b) => this._pinnedColumns.indexOf(a) - this._pinnedColumns.indexOf(b));
52005176
this._unpinnedColumns = this.hasColumnGroups ? this.columnList.filter((c) => !c.pinned) :
52015177
this.columnList.filter((c) => !c.pinned)
52025178
.sort((a, b) => this._unpinnedColumns.indexOf(a) - this._unpinnedColumns.indexOf(b));

0 commit comments

Comments
 (0)