Skip to content

Commit 123f25d

Browse files
authored
Merge branch 'master' into didimmova/fix-textarea-8078-master
2 parents 0e02f4b + da150d8 commit 123f25d

15 files changed

+888
-54
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ All notable changes for each version of this project will be documented in this
3131
- **Breaking Change** - The `selectedRows` method is now an `@Input` property. Setting it to an array of Row IDs will update the grid's selection state, any previous selection will be cleared. Setting it to an empty array will clear the selection entirely.
3232
- **Breaking Change** - Removed `IgxExcelStyleSortingTemplateDirective`, `IgxExcelStyleHidingTemplateDirective`, `IgxExcelStyleMovingTemplateDirective`, `IgxExcelStylePinningTemplateDirective` and `IgxExcelStyleSelectingTemplateDirective` directives for re-templating the Excel style filter menu. Added two new directives for re-templating the column operations and filter operations areas - `IgxExcelStyleColumnOperationsTemplateDirective` and `IgxExcelStyleFilterOperationsTemplateDirective`. Exposed all internal components of the Excel style filter menu in order to be used inside the templates.
3333
- **Breaking Change** - `IgxColumnHiding` and `IgxColumnPinning` components have been deprecated in favor of a component combining the their functionality - `IgxColumnActions` which is used with either of the new `IgxColumnPinning` and `IgxColumnHiding` directives that specify the action to be triggered through the UI.
34+
- Added `move` method which allows to move a column to a specified visible index. The method is exposed off the `IgxColumnComponent`.
3435
- `igxGrid`
3536
- **Behavioral Change** - For numeric columns, the onCellEdit arguments' newValue will now contain the numeric value that will be committed instead of the string input.
3637
- Added `onScroll` event, which is emitted when the grid is scrolled vertically or horizontally.

projects/igniteui-angular/src/lib/badge/badge.component.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class IgxBadgeComponent {
8787
* ```
8888
*/
8989
@Input()
90-
public value = '';
90+
public value: string | number = '';
9191

9292
/**
9393
* Sets/gets an icon for the badge from the material icons set.
@@ -154,18 +154,13 @@ export class IgxBadgeComponent {
154154
* @internal
155155
*/
156156
get roleDescription() {
157-
let message: string;
158-
159157
// tslint:disable-next-line:prefer-conditional-expression
160158
if (this.icon) {
161-
message = this.type + ' type badge with icon type ' + this.icon;
162-
} else if (this.value) {
163-
message = this.type + ' badge type with value ' + this.value;
164-
} else {
165-
message = this.type + ' badge type without value';
159+
return this.type + ' type badge with icon type ' + this.icon;
160+
} else if (this.value || this.value === 0) {
161+
return this.type + ' badge type with value ' + this.value;
166162
}
167-
168-
return message;
163+
return this.type + ' badge type without value';
169164
}
170165

171166
/**

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

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ Here is a list of all public methods exposed by **IgxGridColumnComponent**:
364364
|--- |--- |
365365
|`pin(): boolean`|Pins the column. Returns if the operation is successful.|
366366
|`unpin(): boolean`|Unpins the column. Returns if the operation is successful.|
367+
|`move(index): boolean`|Moves the column to the specified visible index.|
367368

368369

369370
### Getters/Setters

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

+11
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,15 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
357357
// // D.P. constructor duplication due to es6 compilation, might be obsolete in the future
358358
// super(gridAPI, cdr);
359359
// }
360+
361+
/**
362+
* @hidden
363+
* Calculates the number of visible columns, based on indexes of first and last visible columns.
364+
*/
365+
public calcChildren(): number {
366+
const visibleChildren = this.allChildren.filter(c => c.visibleIndex > -1);
367+
const fi = visibleChildren[0].visibleIndex;
368+
const li = visibleChildren[visibleChildren.length - 1].visibleIndex;
369+
return li - fi + 1;
370+
}
360371
}

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

+61
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import {
4444
IgxFilterCellTemplateDirective
4545
} from './templates.directive';
4646
import { MRLResizeColumnInfo, MRLColumnSizeInfo } from './interfaces';
47+
import { DropPosition } from '../moving/moving.service';
48+
import { IgxColumnGroupComponent } from './column-group.component';
4749

4850
/**
4951
* **Ignite UI for Angular Column** -
@@ -1762,6 +1764,65 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
17621764

17631765
return true;
17641766
}
1767+
1768+
/**
1769+
* Moves a column to the specified visible index.
1770+
* If passed index is invalid, or if column would receive a different visible index after moving, moving is not performed.
1771+
* If passed index would move the column to a different column group. moving is not performed.
1772+
* @example
1773+
* ```typescript
1774+
* column.move(index);
1775+
* ```
1776+
* @memberof IgxColumnComponent
1777+
*/
1778+
public move(index: number) {
1779+
let target;
1780+
const grid = (this.grid as IgxGridBaseDirective);
1781+
let columns: Array<IgxColumnComponent | IgxColumnGroupComponent> = grid.columnList.filter(c => c.visibleIndex > -1);
1782+
// grid last visible index
1783+
const li = columns.map(c => c.visibleIndex).reduce(function(a, b) {
1784+
return Math.max(a, b);
1785+
});
1786+
const parent = this.parent;
1787+
const isPreceding = this.visibleIndex < index;
1788+
1789+
if (index === this.visibleIndex || index < 0 || index > li) {
1790+
return;
1791+
}
1792+
1793+
if (parent) {
1794+
columns = columns.filter(c => c.level >= this.level && c !== this && c.parent !== this &&
1795+
c.topLevelParent === this.topLevelParent);
1796+
}
1797+
// tslint:disable:max-line-length
1798+
// If isPreceding, find a target such that when the current column is placed after it, current colummn will receive a visibleIndex === index. This takes into account visible children of the columns.
1799+
// If !isPreceding, finds a column of the same level and visible index that equals the passed index agument (c.visibleIndex === index). No need to consider the children here.
1800+
// tslint:enable:max-line-length
1801+
if (isPreceding) {
1802+
columns = columns.filter(c => c.visibleIndex > this.visibleIndex);
1803+
target = columns.find(c => c.level === this.level && c.visibleIndex + c.calcChildren() - this.calcChildren() === index);
1804+
} else {
1805+
columns = columns.filter(c => c.visibleIndex < this.visibleIndex);
1806+
target = columns.find(c => c.level === this.level && c.visibleIndex === index);
1807+
}
1808+
1809+
if (!target || (target.pinned && this.disablePinning)) {
1810+
return;
1811+
}
1812+
1813+
const pos = isPreceding ? DropPosition.AfterDropTarget : DropPosition.BeforeDropTarget;
1814+
grid.moveColumn(this, target as IgxColumnComponent, pos);
1815+
}
1816+
1817+
/**
1818+
* No children for the column, so will returns 1 or 0, if the column is hidden.
1819+
* @hidden
1820+
*/
1821+
public calcChildren(): number {
1822+
const children = this.hidden ? 0 : 1;
1823+
return children;
1824+
}
1825+
17651826
/**
17661827
* Returns a reference to the top level parent column.
17671828
* ```typescript

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3909,7 +3909,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
39093909
* Moves a column to the specified drop target.
39103910
* @example
39113911
* ```typescript
3912-
* grid.moveColumn(compName, persDetails);
3912+
* grid.moveColumn(column, dropTarget);
39133913
* ```
39143914
*/
39153915
public moveColumn(column: IgxColumnComponent, dropTarget: IgxColumnComponent, pos: DropPosition = DropPosition.AfterDropTarget) {

0 commit comments

Comments
 (0)