Skip to content

Commit 6949521

Browse files
authored
Merge pull request #4394 from IgniteUI/7.2.x
Merging 7.2.x into master
2 parents 152d6b0 + 02cab2e commit 6949521

Some content is hidden

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

49 files changed

+1832
-332
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
# 7.2.3
6+
- `IPinColumnEventArgs` new property - added a new property `isPinned` to the `IPinColumnEventArgs` interface. Now the `onColumnPinning` event emits information whether the column is pinned or unpinned.
7+
- `igxGrid`
8+
- `igxFilterCellTemplate` directive added that allows retemplating of the filter cell.
9+
- `IgxColumnComponent` now has `filterCellTemplate` property that can be used to retemplate the filter cell.
10+
511
# 7.2.2
612
- **Components' Display Type** - All components now have their CSS display property explicitly set on the host element to ensure width, padding, and margins are applied when set directly on the host selectors.
713
- **Themes**

projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ describe('IgxDatePicker', () => {
438438

439439
it('#3595 - Should be able to change month', fakeAsync(() => {
440440
const fixture = TestBed.createComponent(IgxDatePickerTestComponent);
441+
fixture.componentInstance.datePicker.value = new Date(2019, 2, 10);
442+
tick(300);
441443
fixture.detectChanges();
442444

443445
const dom = fixture.debugElement;
@@ -448,14 +450,14 @@ describe('IgxDatePicker', () => {
448450

449451
let month = fixture.debugElement.nativeElement.getElementsByClassName('igx-calendar-picker__date')[0];
450452
month.dispatchEvent(new Event('click'));
451-
tick();
453+
tick(200);
452454
fixture.detectChanges();
453455

454-
const firstMonth = document.getElementsByClassName('igx-calendar__month')[1];
456+
const firstMonth = document.getElementsByClassName('igx-calendar__month')[0];
455457
const expectedResult = (firstMonth as HTMLElement).innerText;
456458

457459
firstMonth.dispatchEvent(new Event('click'));
458-
tick();
460+
tick(200);
459461
fixture.detectChanges();
460462

461463
month = fixture.debugElement.nativeElement.getElementsByClassName('igx-calendar-picker__date')[0];

projects/igniteui-angular/src/lib/directives/for-of/virtual.helper.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ export class VirtualHelperComponent implements OnDestroy {
1010

1111
@ViewChild('container', { read: ViewContainerRef }) public _vcr;
1212
@Input() public itemsLength: number;
13-
public height: number;
13+
14+
public set height(value) {
15+
if (this.destroyed) {
16+
return;
17+
}
18+
this._height = value;
19+
this.cdr.detectChanges();
20+
}
21+
22+
public get height() {
23+
return this._height;
24+
}
1425

1526
@HostBinding('class')
1627
public cssClasses = 'igx-vhelper--vertical';
1728

1829
public destroyed;
30+
private _height: number;
1931

2032
constructor(public elementRef: ElementRef, public cdr: ChangeDetectorRef) { }
2133

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ A list of the events emitted by the **igx-grid**:
235235
|`onRowAdded`|Emitted when a row is being added to the grid through the API. Returns the data for the new row object.|
236236
|`onRowDeleted`|Emitted when a row is deleted through the grid API. Returns the row object being removed.|
237237
|`onDataPreLoad`| Emitted when a new chunk of data is loaded from virtualization. |
238-
|`onColumnPinning`|Emitted when a column is pinned through the grid API. The index that the column is inserted at may be changed through the `insertAtIndex` property.|
238+
|`onColumnPinning`|Emitted when a column is pinned or unpinned through the grid API. The index that the column is inserted at may be changed through the `insertAtIndex` property. Use `isPinned` to check whether the column is pinned or unpinned.|
239239
|`onColumnResized`|Emitted when a column is resized. Returns the column object, previous and new column width.|
240240
|`onContextMenu`|Emitted when a cell is right clicked. Returns the cell object.|
241241
|`onDoubleClick`|Emitted when a cell is double clicked. Returns the cell object.|
@@ -351,6 +351,7 @@ Here is a list of all public methods exposed by **IgxGridColumnComponent**:
351351
|`headerTemplate`|TemplateRef|Yes|Yes|Get/Set a reference to a template which will be applied to the column header.|
352352
|`footerTemplate`|TemplateRef|Yes|Yes|Get/Set a reference to a template which will be applied to the column footer.|
353353
|`inlineEditorTemplate`|TemplateRef|Yes|Yes|Get/Set a reference to a template which will be applied as a cell enters edit mode.|
354+
|`filterCellTemplate`|TemplateRef|Yes|Yes|Get/Set a reference to a template which will be applied to the filter cell of the column.|
354355

355356

356357
## Filtering Conditions

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
337337
if (emittedArgs.oldValue !== undefined
338338
&& isEqual(emittedArgs.oldValue, emittedArgs.newValue)) { return; }
339339
const rowValue = this.get_all_data(id, grid.transactions.enabled)[rowIndex];
340+
if (grid.hasSummarizedColumns) {
341+
grid.summaryService.clearSummaryCache(emittedArgs);
342+
}
340343
this.updateData(grid, rowID, rowValue, currentGridEditState.rowData, { [column.field]: emittedArgs.newValue });
341344
if (grid.primaryKey === column.field) {
342345
if (currentGridEditState.isRowSelected) {
@@ -585,6 +588,12 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
585588
return column.dataType === DataType.Number;
586589
}
587590

591+
public get_data(id: string): any[] {
592+
const grid = this.get(id);
593+
const data = grid.data ? grid.data : [];
594+
return data;
595+
}
596+
588597
public get_all_data(id: string, includeTransactions = false): any[] {
589598
const grid = this.get(id);
590599
let data = grid.data ? grid.data : [];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
[igxFocus]="focused" [disableRipple]="true"></igx-checkbox>
2626
</ng-container>
2727
<ng-container *ngIf="column.dataType === 'date'">
28-
<igx-date-picker [outlet]="grid.outletDirective" mode="dropdown" (onSelection)="editValue = $event"
28+
<igx-date-picker [style.width.%]="100" [outlet]="grid.outletDirective" mode="dropdown" (onSelection)="editValue = $event"
2929
[locale]="grid.locale" [(ngModel)]="editValue" [igxFocus]="focused" [labelVisibility]="false">
3030
</igx-date-picker>
3131
</ng-container>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ export class IgxGridCellComponent implements OnInit, OnChanges {
524524
}
525525
this._clearCellSelection();
526526
this._saveCellSelection();
527-
const hasFilteredResults = this.grid.filteredData ? this.grid.filteredData.length > 0 : true;
527+
const hasFilteredResults = this.grid.filteredData ? this.grid.filteredData.indexOf(this.row.rowData) !== -1 :
528+
this.grid.dataRowList.map(r => r.rowID).indexOf(this.cellID.rowID) !== -1;
528529
if (hasFilteredResults) {
529530
if (this.column.editable && this.previousCellEditMode && hasFilteredResults) {
530531
this.inEditMode = true;
@@ -842,7 +843,6 @@ export class IgxGridCellComponent implements OnInit, OnChanges {
842843
if (this.column.editable) {
843844
if (this.inEditMode) {
844845
this.grid.endEdit(true);
845-
this.inEditMode = false;
846846
this.nativeElement.focus();
847847
} else {
848848
this.inEditMode = true;

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

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
forwardRef
1212
} from '@angular/core';
1313
import { DataType } from '../data-operations/data-util';
14-
import { IgxTextHighlightDirective } from '../directives/text-highlight/text-highlight.directive';
1514
import { GridBaseAPIService } from './api.service';
1615
import { IgxGridCellComponent } from './cell.component';
1716
import { IgxDateSummaryOperand, IgxNumberSummaryOperand, IgxSummaryOperand } from './summaries/grid-summary';
1817
import { IgxRowComponent } from './row.component';
1918
import {
2019
IgxCellEditorTemplateDirective,
2120
IgxCellHeaderTemplateDirective,
22-
IgxCellTemplateDirective
21+
IgxCellTemplateDirective,
22+
IgxFilterCellTemplateDirective
2323
} from './grid.common';
2424
import { IgxGridHeaderComponent } from './grid-header.component';
2525
import { DefaultSortingStrategy, ISortingStrategy } from '../data-operations/sorting-strategy';
@@ -718,6 +718,34 @@ export class IgxColumnComponent implements AfterContentInit {
718718
this.grid.cdr.markForCheck();
719719
}
720720
}
721+
/**
722+
* Returns a reference to the `filterCellTemplate`.
723+
* ```typescript
724+
* let filterCellTemplate = this.column.filterCellTemplate;
725+
* ```
726+
* @memberof IgxColumnComponent
727+
*/
728+
@Input('filterCellTemplate')
729+
get filterCellTemplate(): TemplateRef<any> {
730+
return this._filterCellTemplate;
731+
}
732+
/**
733+
* Sets the quick filter template.
734+
* ```html
735+
* <ng-template #filterCellTemplate IgxFilterCellTemplate let-column="column">
736+
* <input (input)="onInput()">
737+
* </ng-template>
738+
* ```
739+
* ```typescript
740+
* @ViewChild("'filterCellTemplate'", {read: TemplateRef })
741+
* public filterCellTemplate: TemplateRef<any>;
742+
* this.column.filterCellTemplate = this.filterCellTemplate;
743+
* ```
744+
* @memberof IgxColumnComponent
745+
*/
746+
set filterCellTemplate(template: TemplateRef<any>) {
747+
this._filterCellTemplate = template;
748+
}
721749
/**
722750
* Gets the cells of the column.
723751
* ```typescript
@@ -871,6 +899,10 @@ export class IgxColumnComponent implements AfterContentInit {
871899
*@hidden
872900
*/
873901
protected _inlineEditorTemplate: TemplateRef<any>;
902+
/**
903+
*@hidden
904+
*/
905+
protected _filterCellTemplate: TemplateRef<any>;
874906
/**
875907
*@hidden
876908
*/
@@ -935,6 +967,12 @@ export class IgxColumnComponent implements AfterContentInit {
935967
@ContentChild(IgxCellEditorTemplateDirective, { read: IgxCellEditorTemplateDirective })
936968
protected editorTemplate: IgxCellEditorTemplateDirective;
937969

970+
/**
971+
*@hidden
972+
*/
973+
@ContentChild(IgxFilterCellTemplateDirective, { read: IgxFilterCellTemplateDirective })
974+
public filterCellTemplateDirective: IgxFilterCellTemplateDirective;
975+
938976
constructor(public gridAPI: GridBaseAPIService<IgxGridBaseComponent & IGridDataBindable>, public cdr: ChangeDetectorRef) { }
939977
/**
940978
*@hidden
@@ -949,6 +987,9 @@ export class IgxColumnComponent implements AfterContentInit {
949987
if (this.editorTemplate) {
950988
this._inlineEditorTemplate = this.editorTemplate.template;
951989
}
990+
if (this.filterCellTemplateDirective) {
991+
this._filterCellTemplate = this.filterCellTemplateDirective.template;
992+
}
952993
if (!this.summaries) {
953994
switch (this.dataType) {
954995
case DataType.String:
@@ -1027,7 +1068,7 @@ export class IgxColumnComponent implements AfterContentInit {
10271068
this._unpinnedIndex = grid._unpinnedColumns.indexOf(this);
10281069
index = index !== undefined ? index : grid._pinnedColumns.length;
10291070
const targetColumn = grid._pinnedColumns[index];
1030-
const args = { column: this, insertAtIndex: index };
1071+
const args = { column: this, insertAtIndex: index, isPinned: true };
10311072
grid.onColumnPinning.emit(args);
10321073

10331074
if (grid._pinnedColumns.indexOf(this) === -1) {
@@ -1087,6 +1128,7 @@ export class IgxColumnComponent implements AfterContentInit {
10871128
this._pinned = false;
10881129

10891130
const targetColumn = grid._unpinnedColumns[index];
1131+
10901132
grid._unpinnedColumns.splice(index, 0, this);
10911133
if (grid._pinnedColumns.indexOf(this) !== -1) {
10921134
grid._pinnedColumns.splice(grid._pinnedColumns.indexOf(this), 1);
@@ -1102,9 +1144,14 @@ export class IgxColumnComponent implements AfterContentInit {
11021144

11031145
grid.reinitPinStates();
11041146

1147+
const insertAtIndex = grid._unpinnedColumns.indexOf(this);
1148+
const args = { column: this, insertAtIndex, isPinned: false };
1149+
grid.onColumnPinning.emit(args);
1150+
11051151
grid.cdr.detectChanges();
11061152
this.grid.filteringService.refreshExpressions();
11071153
this.grid.refreshSearch(true);
1154+
11081155
return true;
11091156
}
11101157
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
</igx-chip>
4242
</ng-template>
4343

44-
<ng-container *ngTemplateOutlet="template; context: { $implicit: this }"></ng-container>
44+
<ng-container *ngTemplateOutlet="template; context: context"></ng-container>

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering-cell.component.ts

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,17 @@ export class IgxGridFilteringCellComponent implements AfterViewInit, OnInit, DoC
8282

8383
@HostListener('keydown.tab', ['$event'])
8484
public onTabKeyDown(eventArgs) {
85-
const nextIndex = this.filteringService.unpinnedFilterableColumns.indexOf(this.column) + 1;
8685

8786
if (this.isLastElementFocused()) {
88-
if (this.column === this.getLastPinnedFilterableColumn() &&
89-
(!this.isColumnLeftVisible(nextIndex) || !this.isColumnRightVisible(nextIndex))) {
90-
this.filteringService.scrollToFilterCell(this.filteringService.unpinnedFilterableColumns[nextIndex], false);
91-
eventArgs.stopPropagation();
92-
return;
93-
}
94-
95-
if (nextIndex >= this.filteringService.unpinnedFilterableColumns.length) {
96-
if (!this.filteringService.grid.filteredData || this.filteringService.grid.filteredData.length > 0) {
97-
if (this.filteringService.grid.rowList.filter(row => row instanceof IgxGridGroupByRowComponent).length > 0) {
98-
eventArgs.stopPropagation();
99-
return;
100-
}
101-
this.navService.goToFirstCell();
102-
}
103-
eventArgs.preventDefault();
104-
} else if (!this.column.pinned && !this.isColumnRightVisible(nextIndex)) {
105-
eventArgs.preventDefault();
106-
this.filteringService.scrollToFilterCell(this.filteringService.unpinnedFilterableColumns[nextIndex], true);
107-
}
87+
this.filteringService.grid.navigation.navigateNextFilterCell(this.column, eventArgs);
10888
}
10989
eventArgs.stopPropagation();
11090
}
11191

11292
@HostListener('keydown.shift.tab', ['$event'])
11393
public onShiftTabKeyDown(eventArgs) {
11494
if (this.isFirstElementFocused()) {
115-
const prevIndex = this.filteringService.unpinnedFilterableColumns.indexOf(this.column) - 1;
116-
117-
if (prevIndex >= 0 && this.column.visibleIndex > 0 && !this.isColumnLeftVisible(prevIndex) && !this.column.pinned) {
118-
eventArgs.preventDefault();
119-
this.filteringService.scrollToFilterCell(this.filteringService.unpinnedFilterableColumns[prevIndex], false);
120-
} else if (this.column.visibleIndex === 0 ||
121-
(prevIndex < 0 && !this.getFirstPinnedFilterableColumn()) ||
122-
this.column === this.getFirstPinnedFilterableColumn()) {
123-
eventArgs.preventDefault();
124-
}
95+
this.filteringService.grid.navigation.navigatePrevFilterCell(this.column, eventArgs);
12596
}
12697
eventArgs.stopPropagation();
12798
}
@@ -148,6 +119,11 @@ export class IgxGridFilteringCellComponent implements AfterViewInit, OnInit, DoC
148119
return null;
149120
}
150121

122+
if (this.column.filterCellTemplate) {
123+
this.currentTemplate = this.column.filterCellTemplate;
124+
return this.column.filterCellTemplate;
125+
}
126+
151127
const expressionTree = this.column.filteringExpressionsTree;
152128
if (!expressionTree || expressionTree.filteringOperands.length === 0) {
153129
this.currentTemplate = this.emptyFilter;
@@ -163,6 +139,16 @@ export class IgxGridFilteringCellComponent implements AfterViewInit, OnInit, DoC
163139
return this.defaultFilter;
164140
}
165141

142+
/**
143+
* Gets the context passed to the filter template.
144+
* @memberof IgxGridFilteringCellComponent
145+
*/
146+
get context() {
147+
return {
148+
column: this.column
149+
};
150+
}
151+
166152
/**
167153
* Chip clicked event handler.
168154
*/
@@ -345,16 +331,6 @@ export class IgxGridFilteringCellComponent implements AfterViewInit, OnInit, DoC
345331
}
346332
}
347333

348-
private getLastPinnedFilterableColumn(): IgxColumnComponent {
349-
const pinnedFilterableColums =
350-
this.filteringService.grid.pinnedColumns.filter(col => !(col instanceof IgxColumnGroupComponent) && col.filterable);
351-
return pinnedFilterableColums[pinnedFilterableColums.length - 1];
352-
}
353-
354-
private getFirstPinnedFilterableColumn(): IgxColumnComponent {
355-
return this.filteringService.grid.pinnedColumns.filter(col => !(col instanceof IgxColumnGroupComponent) && col.filterable)[0];
356-
}
357-
358334
private isColumnRightVisible(columnIndex: number): boolean {
359335
if (this.filteringService.areAllColumnsInView) {
360336
return true;

0 commit comments

Comments
 (0)