Skip to content

Commit 0742fd6

Browse files
authored
Add template context guards for ES Loading, MDV and GroupBy row (#12093)
* Add template context guards for ES Loading, MDV and GroupBy row * chore(*): Fix unsued dir parameter warning
1 parent e983cb7 commit 0742fd6

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,3 +698,12 @@ export interface ISizeInfo {
698698
width: number,
699699
padding: number
700700
}
701+
702+
export interface IgxGridMasterDetailContext {
703+
$implicit: any;
704+
index: number;
705+
}
706+
707+
export interface IgxGroupByRowTemplateContext {
708+
$implicit: IGroupByRecord;
709+
}

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ import { IgxTreeComponent, ITreeNodeSelectionEvent } from '../../../tree/public_
3131
selector: '[igxExcelStyleLoading]'
3232
})
3333
export class IgxExcelStyleLoadingValuesTemplateDirective {
34-
constructor(public template: TemplateRef<any>) { }
34+
public static ngTemplateContextGuard(_dir: IgxExcelStyleLoadingValuesTemplateDirective,
35+
ctx: unknown): ctx is undefined {
36+
return true
37+
};
38+
constructor(public template: TemplateRef<undefined>) { }
3539
}
3640

3741
/**
@@ -71,14 +75,14 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
7175
/**
7276
* @hidden @internal
7377
*/
74-
@ViewChild('addToCurrentFilterCheckbox', { read: IgxCheckboxComponent, static: false })
75-
public addToCurrentFilterCheckbox: IgxCheckboxComponent;
78+
@ViewChild('addToCurrentFilterCheckbox', { read: IgxCheckboxComponent, static: false })
79+
public addToCurrentFilterCheckbox: IgxCheckboxComponent;
7680

7781
/**
7882
* @hidden @internal
7983
*/
80-
@ViewChild('tree', { read: IgxTreeComponent, static: false })
81-
public tree: IgxTreeComponent;
84+
@ViewChild('tree', { read: IgxTreeComponent, static: false })
85+
public tree: IgxTreeComponent;
8286

8387
/**
8488
* @hidden @internal
@@ -295,7 +299,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
295299
/**
296300
* @hidden @internal
297301
*/
298-
public onNodeSelectionChange(eventArgs: ITreeNodeSelectionEvent) {
302+
public onNodeSelectionChange(eventArgs: ITreeNodeSelectionEvent) {
299303
eventArgs.added.forEach(node => {
300304
(node.data as FilterListItem).isSelected = true;
301305
});
@@ -349,7 +353,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
349353
*/
350354
public get applyButtonDisabled(): boolean {
351355
return (this._selectAllItem && !this._selectAllItem.isSelected && !this._selectAllItem.indeterminate) ||
352-
(this.displayedListData && this.displayedListData.length === 0);
356+
(this.displayedListData && this.displayedListData.length === 0);
353357
}
354358

355359
/**
@@ -555,7 +559,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
555559
/**
556560
* @hidden @internal
557561
*/
558-
public isTreeEmpty() {
562+
public isTreeEmpty() {
559563
return this.esf.isHierarchical && this.displayedListData.length === 0;
560564
}
561565

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IgxGridSelectionService } from '../selection/selection.service';
2222
import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service';
2323
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
2424
import { FilterMode, GridInstanceType } from '../common/enums';
25-
import { CellType, GridType, IGX_GRID_BASE, IGX_GRID_SERVICE_BASE, RowType } from '../common/grid.interface';
25+
import { CellType, GridType, IgxGridMasterDetailContext, IgxGroupByRowTemplateContext, IGX_GRID_BASE, IGX_GRID_SERVICE_BASE, RowType } from '../common/grid.interface';
2626
import { IgxGroupByRowSelectorDirective } from '../selection/row-selectors';
2727
import { IgxGridCRUDService } from '../common/crud.service';
2828
import { IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../grid-public-row';
@@ -155,7 +155,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
155155
* @hidden @internal
156156
*/
157157
@ContentChildren(IgxGridDetailTemplateDirective, { read: TemplateRef })
158-
public detailTemplate: QueryList<TemplateRef<any>> = new QueryList();
158+
public detailTemplate: QueryList<TemplateRef<IgxGridMasterDetailContext>> = new QueryList();
159159

160160
/**
161161
* @hidden @internal
@@ -251,7 +251,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
251251
/**
252252
* @hidden
253253
*/
254-
protected _groupRowTemplate: TemplateRef<any>;
254+
protected _groupRowTemplate: TemplateRef<IgxGroupByRowTemplateContext>;
255255
/**
256256
* @hidden
257257
*/
@@ -544,7 +544,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
544544
/**
545545
* @hidden @internal
546546
*/
547-
public getDetailsContext(rowData, index) {
547+
public getDetailsContext(rowData, index): IgxGridDetailTemplateDirective {
548548
return {
549549
$implicit: rowData,
550550
index
@@ -603,11 +603,11 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
603603
* this.grid.groupRowTemplate = myRowTemplate;
604604
* ```
605605
*/
606-
public get groupRowTemplate(): TemplateRef<any> {
606+
public get groupRowTemplate(): TemplateRef<IgxGroupByRowTemplateContext> {
607607
return this._groupRowTemplate;
608608
}
609609

610-
public set groupRowTemplate(template: TemplateRef<any>) {
610+
public set groupRowTemplate(template: TemplateRef<IgxGroupByRowTemplateContext>) {
611611
this._groupRowTemplate = template;
612612
this.notifyChanges();
613613
}

projects/igniteui-angular/src/lib/grids/grid/grid.directives.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Directive, ElementRef, Renderer2, NgZone, HostBinding, TemplateRef } fr
22
import { IgxDropDirective } from '../../directives/drag-drop/drag-drop.directive';
33
import { IgxColumnMovingDragDirective } from '../moving/moving.drag.directive';
44
import { IgxGroupByAreaDirective } from '../grouping/group-by-area.directive';
5-
import { ColumnType } from '../common/grid.interface';
5+
import { ColumnType, IgxGridMasterDetailContext, IgxGroupByRowTemplateContext } from '../common/grid.interface';
66

77
/**
88
* @hidden
@@ -11,8 +11,12 @@ import { ColumnType } from '../common/grid.interface';
1111
selector: '[igxGroupByRow]'
1212
})
1313
export class IgxGroupByRowTemplateDirective {
14+
public static ngTemplateContextGuard(_dir: IgxGroupByRowTemplateDirective,
15+
ctx: unknown): ctx is IgxGroupByRowTemplateContext {
16+
return true
17+
};
1418

15-
constructor(public template: TemplateRef<any>) { }
19+
constructor(public template: TemplateRef<IgxGroupByRowTemplateContext>) { }
1620

1721
}
1822

@@ -23,6 +27,10 @@ export class IgxGroupByRowTemplateDirective {
2327
selector: '[igxGridDetail]'
2428
})
2529
export class IgxGridDetailTemplateDirective {
30+
public static ngTemplateContextGuard(_dir: IgxGridDetailTemplateDirective,
31+
ctx: unknown): ctx is IgxGridMasterDetailContext {
32+
return true
33+
};
2634
}
2735

2836
/**
@@ -74,7 +82,7 @@ export class IgxExcelStyleHeaderIconDirective {
7482
/**
7583
* @hidden
7684
*/
77-
@Directive({
85+
@Directive({
7886
selector: '[igxSortHeaderIcon]'
7987
})
8088
export class IgxSortHeaderIconDirective {

0 commit comments

Comments
 (0)