Skip to content

Commit f398da3

Browse files
committed
Merge branch '10.1.x' into ibarakov/fix-8247-10.1.x
# Conflicts: # projects/igniteui-angular/src/lib/grids/cell.component.html # projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html
2 parents b9dc377 + 00bf857 commit f398da3

35 files changed

+660
-203
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ All notable changes for each version of this project will be documented in this
77
### General
88
- `IgxDatePicker`
99
- Added `aria-labelledby` property for the input field. This will ensure the users of assistive technologies will also know what component is used for, upon input focus.
10+
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
11+
- A new `locale` and `pipeArgs` parameters are introduced in the `operate` method exposed by the `IgxNumberSummaryOperand` and `IgxDateSummaryOperand`, which exposes the grid locale. Use the `locale` parameter to get localized summary data (as per the grid locale. If not passed, `locale` defaults to `'en-US'`). Use the `pipeArgs` parameter only if you want to customize the format of the date and numeric values that will be returned.
12+
```typescript
13+
class MySummary extends IgxDateSummaryOperand {
14+
const pipeArgs: IColumnPipeArgs = {
15+
format: 'longDate',
16+
timezone: 'UTC'
17+
}
18+
operate(columnData: any[], allData = [], fieldName, locale: string): IgxSummaryResult[] {
19+
const result = super.operate(columnData, allData, fieldName, locale, pipeArgs);
20+
return result;
21+
}
22+
}
23+
```
24+
- A new `pipeArgs` input property is exposed by the `IgxColumnComponent`, which is used to pass arguments to the Angular `DatePipe` and `DecimalPipe`, to format the display for date and numeric columns.
1025

1126
## 10.1.0
1227

projects/igniteui-angular/src/lib/core/styles/themes/schemas/light/_grid.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ $_bootstrap-grid: extend(
604604
/// @prop {Color} header-text-color [igx-color: 'primary'] - The table header text color.
605605
/// @prop {Map} header-selected-background [igx-color: ('primary', 50)] - The table header background color when selected (ex. column selection).
606606
/// @prop {Map} header-selected-text-color [igx-color: 'primary'] - The table header text color when selected (ex. column selection).
607-
/// @prop {Map} header-border-color [igx-color: ('primary', 100)] - The color used for header borders.
607+
/// @prop {Map} header-border-color [igx-color: ('primary', 500), rgba: .24] - The color used for header borders.
608608
///
609609
/// @prop {Map} filtering-header-text-color [igx-color: ('primary', 900)] - The text color color of the filtered column header.
610610
/// @prop {Map} filtering-background-or [igx-color: 'warn'] - The background color of advanced filtering "OR" condition.
@@ -673,7 +673,8 @@ $_indigo-grid: extend(
673673
),
674674

675675
header-border-color: (
676-
igx-color: ('primary', 100)
676+
igx-color: ('primary', 500),
677+
rgba: .24
677678
),
678679

679680
filtering-header-text-color: (

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
270270

271271

272272
public get displayContainer(): HTMLElement | undefined {
273-
return this.dc.instance._viewContainer.element.nativeElement;
273+
return this.dc?.instance?._viewContainer?.element?.nativeElement;
274274
}
275275

276276
public get virtualHelper() {
@@ -372,11 +372,11 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
372372
protected removeScrollEventListeners() {
373373
if (this.igxForScrollOrientation === 'horizontal') {
374374
this._zone.runOutsideAngular(() =>
375-
this.scrollComponent.nativeElement.removeEventListener('scroll', this.func)
375+
this.scrollComponent?.nativeElement?.removeEventListener('scroll', this.func)
376376
);
377377
} else {
378378
this._zone.runOutsideAngular(() =>
379-
this.scrollComponent.nativeElement.removeEventListener('scroll', this.verticalScrollHandler)
379+
this.scrollComponent?.nativeElement?.removeEventListener('scroll', this.verticalScrollHandler)
380380
);
381381
}
382382
}
@@ -717,7 +717,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
717717
* ```
718718
*/
719719
public getScroll() {
720-
return this.scrollComponent.nativeElement;
720+
return this.scrollComponent?.nativeElement;
721721
}
722722
/**
723723
* Returns the size of the element at the specified index.

projects/igniteui-angular/src/lib/grids/cell.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
formatter
2020
? (value | columnFormatter: formatter)
2121
: column.dataType === 'number'
22-
? (value | igxdecimal: grid.locale)
22+
? (value | number:column.pipeArgs.digitsInfo:grid.locale)
2323
: column.dataType === 'date'
24-
? (value | igxdate: grid.locale)
24+
? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale)
2525
: value
2626
"
2727
[row]="rowData"
@@ -32,9 +32,9 @@
3232
formatter
3333
? (value | columnFormatter: formatter)
3434
: column.dataType === "number"
35-
? (value | igxdecimal: grid.locale)
35+
? (value | number:column.pipeArgs.digitsInfo:grid.locale)
3636
: column.dataType === "date"
37-
? (value | igxdate: grid.locale)
37+
? (value | date:column.pipeArgs.format:column.pipeArgs.timezone:grid.locale)
3838
: value
3939
}}</div>
4040
<igx-icon

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ import {
4242
IgxCollapsibleIndicatorTemplateDirective,
4343
IgxFilterCellTemplateDirective
4444
} from './templates.directive';
45-
import { MRLResizeColumnInfo, MRLColumnSizeInfo } from './interfaces';
45+
import { MRLResizeColumnInfo, MRLColumnSizeInfo, IColumnPipeArgs } from './interfaces';
46+
47+
const DEFAULT_DATE_FORMAT = 'mediumDate';
48+
const DEFAULT_DIGITS_INFO = '1.0-3';
4649

4750
/**
4851
* **Ignite UI for Angular Column** -
@@ -1180,6 +1183,37 @@ export class IgxColumnComponent implements AfterContentInit {
11801183
return this._visibleWhenCollapsed;
11811184
}
11821185

1186+
private _pipeArgs: IColumnPipeArgs = { format: DEFAULT_DATE_FORMAT, digitsInfo: DEFAULT_DIGITS_INFO };
1187+
/**
1188+
* Provide parameters for DatePipe and DecimalPipe to customize the display format for date and numeric columns.
1189+
* Accepts an `IColumnPipeArgs` object with any of the `format`, `timezone` and `digitsInfo` properties.
1190+
* For more details see https://angular.io/api/common/DatePipe and https://angular.io/api/common/DecimalPipe
1191+
* @example
1192+
* ```typescript
1193+
* const pipeArgs: IColumnPipeArgs = {
1194+
* format: 'longDate',
1195+
* timezone: 'UTC',
1196+
* digitsInfo: '1.1-2'
1197+
* }
1198+
* ```
1199+
* ```html
1200+
* <igx-column dataType="date" [pipeArgs]="pipeArgs"></igx-column>
1201+
* <igx-column dataType="number" [pipeArgs]="pipeArgs"></igx-column>
1202+
* ```
1203+
* @memberof IgxColumnComponent
1204+
*/
1205+
@Input()
1206+
set pipeArgs(value: IColumnPipeArgs) {
1207+
this._pipeArgs = Object.assign(this._pipeArgs, value);
1208+
this.grid.summaryService.clearSummaryCache();
1209+
(this.grid as any)._pipeTrigger++;
1210+
this.grid.notifyChanges();
1211+
}
1212+
get pipeArgs(): IColumnPipeArgs {
1213+
return this._pipeArgs;
1214+
}
1215+
1216+
11831217
/**
11841218
* @hidden
11851219
* @internal
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { IgxColumnComponent } from './column.component';
22

3-
3+
/**
4+
* @hidden
5+
* @internal
6+
*/
47
export interface MRLColumnSizeInfo {
58
ref: IgxColumnComponent;
69
width: number;
@@ -9,7 +12,26 @@ export interface MRLColumnSizeInfo {
912
widthSetByUser: boolean;
1013
}
1114

15+
/**
16+
* @hidden
17+
* @internal
18+
*/
1219
export interface MRLResizeColumnInfo {
1320
target: IgxColumnComponent;
1421
spanUsed: number;
1522
}
23+
24+
export interface IColumnPipeArgs {
25+
/** The date/time components that a date column will display, using predefined options or a custom format string. */
26+
format?: string;
27+
/** A timezone offset (such as '+0430'), or a standard UTC/GMT or continental US timezone abbreviation. */
28+
timezone?: string;
29+
/**
30+
* Decimal representation options, specified by a string in the following format:
31+
* `{minIntegerDigits}`.`{minFractionDigits}`-`{maxFractionDigits}`.
32+
* `minIntegerDigits`: The minimum number of integer digits before the decimal point. Default is 1.
33+
* `minFractionDigits`: The minimum number of digits after the decimal point. Default is 0.
34+
* `maxFractionDigits`: The maximum number of digits after the decimal point. Default is 3.
35+
*/
36+
digitsInfo?: string;
37+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TemplateRef } from '@angular/core';
22
import { DataType } from '../../data-operations/data-util';
33
import { ISortingStrategy } from '../../data-operations/sorting-strategy';
44
import { FilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
5+
import { IColumnPipeArgs } from '../columns/interfaces';
56

67
/**
78
* @hidden
@@ -43,6 +44,6 @@ export interface ColumnType {
4344
topLevelParent?: ColumnType;
4445
parent?: ColumnType;
4546
hasLastPinnedChildColumn: boolean;
46-
47+
pipeArgs: IColumnPipeArgs;
4748
getGridTemplate(isRow: boolean, isIE: boolean): string;
4849
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
IgxGridCellStyleClassesPipe,
1010
IgxGridPaginatorOptionsPipe,
1111
IgxHasVisibleColumnsPipe,
12-
IgxDatePipeComponent,
13-
IgxDecimalPipeComponent,
1412
IgxGridRowPinningPipe,
1513
IgxColumnActionEnabledPipe,
1614
IgxFilterActionColumnsPipe,
@@ -23,8 +21,6 @@ import {
2321

2422
@NgModule({
2523
declarations: [
26-
IgxDatePipeComponent,
27-
IgxDecimalPipeComponent,
2824
IgxGridFilterConditionPipe,
2925
IgxGridTransactionPipe,
3026
IgxGridNotGroupedPipe,
@@ -43,8 +39,6 @@ import {
4339
IgxColumnFormatterPipe
4440
],
4541
exports: [
46-
IgxDatePipeComponent,
47-
IgxDecimalPipeComponent,
4842
IgxGridFilterConditionPipe,
4943
IgxGridTransactionPipe,
5044
IgxGridNotGroupedPipe,

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { EventEmitter } from '@angular/core';
44
import { IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
55
import { IGridResourceStrings } from '../../core/i18n/grid-resources';
66
import { ISortingExpression } from '../../data-operations/sorting-expression.interface';
7+
import { IGroupingExpression } from '../../data-operations/grouping-expression.interface';
8+
import { TransactionService, Transaction, State } from '../../services/public_api';
9+
import { ITreeGridRecord } from '../tree-grid/public_api';
710

811
export interface IGridDataBindable {
912
data: any[];
@@ -46,6 +49,8 @@ export interface GridType extends IGridDataBindable {
4649
summariesRowList: any;
4750
headerContainer: any;
4851
dataView: any[];
52+
transactions: TransactionService<Transaction, State>;
53+
defaultSummaryHeight: number;
4954

5055
rowInEditMode: any;
5156
rowEditTabs: any;
@@ -56,6 +61,8 @@ export interface GridType extends IGridDataBindable {
5661

5762
sortingExpressions: ISortingExpression[];
5863
sortingExpressionsChange: EventEmitter<ISortingExpression[]>;
64+
filteringExpressionsTree: IFilteringExpressionsTree;
65+
filteringExpressionsTreeChange: EventEmitter<IFilteringExpressionsTree>;
5966
advancedFilteringExpressionsTree: IFilteringExpressionsTree;
6067
advancedFilteringExpressionsTreeChange: EventEmitter<IFilteringExpressionsTree>;
6168

@@ -66,6 +73,22 @@ export interface GridType extends IGridDataBindable {
6673
isColumnGrouped(fieldName: string): boolean;
6774
isDetailRecord(rec: any): boolean;
6875
isGroupByRecord(rec: any): boolean;
76+
notifyChanges(repaint: boolean): void;
77+
}
78+
79+
/**
80+
* An interface describing a Flat Grid type
81+
*/
82+
export interface FlatGridType extends GridType {
83+
groupingExpressions: IGroupingExpression[];
84+
groupingExpressionsChange: EventEmitter<IGroupingExpression[]>;
85+
}
86+
87+
/**
88+
* An interface describing a Tree Grid type
89+
*/
90+
export interface TreeGridType extends GridType {
91+
records: Map<any, ITreeGridRecord>;
6992
}
7093

7194
export interface GridSVGIcon {

projects/igniteui-angular/src/lib/grids/common/pipes.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Pipe, PipeTransform, Inject, LOCALE_ID } from '@angular/core';
1+
import { Pipe, PipeTransform, Inject } from '@angular/core';
22
import { GridBaseAPIService } from '../api.service';
33
import { IgxGridBaseDirective } from '../grid-base.directive';
44
import { DataUtil } from '../../data-operations/data-util';
55
import { cloneArray, resolveNestedPath } from '../../core/utils';
66
import { GridType } from './grid.interface';
7-
import { DatePipe, DecimalPipe } from '@angular/common';
87
import { IgxColumnComponent } from '../columns/column.component';
98
import { ColumnDisplayOrder } from './enums';
109
import { IgxColumnActionsComponent } from '../column-actions/column-actions.component';
@@ -163,60 +162,6 @@ export class IgxHasVisibleColumnsPipe implements PipeTransform {
163162

164163
}
165164

166-
167-
/**
168-
* @hidden
169-
* @internal
170-
*/
171-
@Pipe({
172-
name: 'igxdate'
173-
})
174-
export class IgxDatePipeComponent extends DatePipe implements PipeTransform {
175-
176-
private readonly DEFAULT_DATE_FORMAT = 'mediumDate';
177-
178-
constructor(@Inject(LOCALE_ID) locale: string) {
179-
// D.P. constructor duplication due to es6 compilation, might be obsolete in the future
180-
super(locale);
181-
}
182-
transform(value: any, locale: string): string {
183-
if (value && value instanceof Date) {
184-
if (locale) {
185-
return super.transform(value, this.DEFAULT_DATE_FORMAT, undefined, locale);
186-
} else {
187-
return super.transform(value);
188-
}
189-
} else {
190-
return value;
191-
}
192-
}
193-
}
194-
195-
/**
196-
* @hidden
197-
* @internal
198-
*/
199-
@Pipe({
200-
name: 'igxdecimal'
201-
})
202-
export class IgxDecimalPipeComponent extends DecimalPipe implements PipeTransform {
203-
constructor(@Inject(LOCALE_ID) locale: string) {
204-
// D.P. constructor duplication due to es6 compilation, might be obsolete in the future
205-
super(locale);
206-
}
207-
transform(value: any, locale: string): string {
208-
if (value && typeof value === 'number') {
209-
if (locale) {
210-
return super.transform(value, undefined, locale);
211-
} else {
212-
return super.transform(value);
213-
}
214-
} else {
215-
return value;
216-
}
217-
}
218-
}
219-
220165
/**
221166
* @hidden
222167
*/

0 commit comments

Comments
 (0)