• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    ChangeDetectorRef,
4
    Component,
5
    DoCheck,
6
    ElementRef,
7
    Input,
8
    QueryList,
9
    TemplateRef,
10
    ViewChild,
11
    ViewChildren,
12
    booleanAttribute
13
} from '@angular/core';
14
import { flatten } from '../../core/utils';
15
import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
16
import { ColumnType, GridType, IgxHeadSelectorTemplateContext } from '../common/grid.interface';
17
import { IgxGridFilteringCellComponent } from '../filtering/base/grid-filtering-cell.component';
18
import { IgxGridFilteringRowComponent } from '../filtering/base/grid-filtering-row.component';
19
import { IgxGridHeaderGroupComponent } from './grid-header-group.component';
20
import { IgxGridHeaderComponent } from './grid-header.component';
21
import { IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe } from './pipes';
22
import { IgxGridTopLevelColumns } from '../common/pipes';
23
import { IgxCheckboxComponent } from '../../checkbox/checkbox.component';
24
import { IgxColumnMovingDropDirective } from '../moving/moving.drop.directive';
25
import { NgIf, NgTemplateOutlet, NgClass, NgFor, NgStyle } from '@angular/common';
26

27
/**
28
 *
29
 * For all intents & purposes treat this component as what a <thead> usually is in the default <table> element.
30
 *
31
 * This container holds the grid header elements and their behavior/interactions.
32
 *
33
 * @hidden @internal
34
 */
35
@Component({
36
    changeDetection: ChangeDetectionStrategy.OnPush,
37
    selector: 'igx-grid-header-row',
38
    templateUrl: './grid-header-row.component.html',
39
    imports: [NgIf, IgxColumnMovingDropDirective, NgTemplateOutlet, NgClass, NgFor, IgxGridHeaderGroupComponent, NgStyle, IgxGridForOfDirective, IgxGridFilteringRowComponent, IgxCheckboxComponent, IgxGridTopLevelColumns, IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe]
40
})
41
export class IgxGridHeaderRowComponent implements DoCheck {
2✔
42

43
    /** The grid component containing this element. */
44
    @Input()
45
    public grid: GridType;
46

47
    /** Pinned columns of the grid. */
48
    @Input()
49
    public pinnedColumnCollection: ColumnType[] = [];
37✔
50

51
    /** Unpinned columns of the grid. */
52
    @Input()
53
    public unpinnedColumnCollection: ColumnType[] = [];
37✔
54

55
    @Input()
56
    public activeDescendant: string;
57

58
    @Input({ transform: booleanAttribute })
59
    public hasMRL: boolean;
60

61
    @Input()
62
    public width: number;
63

64
    /**
65
     * Header groups inside the header row.
66
     *
67
     * @remarks
68
     * Note: These are only the top level header groups in case there are multi-column headers
69
     * or a specific column layout. If you want to get the flattened collection use the `groups`
70
     * property below.
71
     *
72
     * @hidden @internal
73
     * */
74
    @ViewChildren(IgxGridHeaderGroupComponent)
75
    public _groups: QueryList<IgxGridHeaderGroupComponent>;
76

77
    /**
78
     * The flattened header groups collection.
79
     *
80
     * @hidden @internal
81
     */
82
    public get groups(): IgxGridHeaderGroupComponent[] {
83
        return flatten(this._groups?.toArray() ?? []);
212!
84
    }
85

86
    /** Header components in the header row. */
87
    public get headers(): IgxGridHeaderComponent[] {
88
        return this.groups.map(group => group.header);
×
89
    }
90

91
    /** Filtering cell components in the header row. */
92
    public get filters(): IgxGridFilteringCellComponent[] {
93
        return this.groups.map(group => group.filter);
×
94
    }
95

96
    /** The virtualized part of the header row containing the unpinned header groups. */
97
    @ViewChild('headerVirtualContainer', { read: IgxGridForOfDirective, static: true })
98
    public headerContainer: IgxGridForOfDirective<ColumnType, ColumnType[]>;
99

100
    public get headerForOf() {
101
        return this.headerContainer;
113✔
102
    }
103

104
    @ViewChild('headerDragContainer')
105
    public headerDragContainer: ElementRef<HTMLElement>;
106

107
    @ViewChild('headerSelectorContainer')
108
    public headerSelectorContainer: ElementRef<HTMLElement>;
109

110
    @ViewChild('headerGroupContainer')
111
    public headerGroupContainer: ElementRef<HTMLElement>;
112

113
    @ViewChild('headSelectorBaseTemplate')
114
    public headSelectorBaseTemplate: TemplateRef<IgxHeadSelectorTemplateContext>;
115

116
    @ViewChild(IgxGridFilteringRowComponent)
117
    public filterRow: IgxGridFilteringRowComponent;
118

119
    /**
120
     * Expand/collapse all child grids area in a hierarchical grid.
121
     * `undefined` in the base and tree grids.
122
     *
123
     * @internal @hidden
124
     */
125
    @ViewChild('headerHierarchyExpander')
126
    public headerHierarchyExpander: ElementRef<HTMLElement>;
127

128
    public get navigation() {
129
        return this.grid.navigation;
×
130
    }
131

132
    public get nativeElement() {
133
        return this.ref.nativeElement;
164✔
134
    }
135

136
    /**
137
     * Returns whether the current grid instance is a hierarchical grid.
138
     * as only hierarchical grids have the `isHierarchicalRecord` method.
139
     *
140
     * @hidden @internal
141
     */
142
    public get isHierarchicalGrid() {
143
        return !!this.grid.isHierarchicalRecord;
386✔
144
    }
145

146
    public get indentationCSSClasses() {
UNCOV
147
        return `igx-grid__header-indentation igx-grid__row-indentation--level-${this.grid.groupingExpressions.length}`;
×
148
    }
149

150
    public get rowSelectorsContext(): IgxHeadSelectorTemplateContext {
UNCOV
151
        const ctx = {
×
152
            $implicit: {
153
                selectedCount: this.grid.selectionService.filteredSelectedRowIds.length as number,
154
                totalCount: this.grid.totalRowsCountAfterFilter as number
155
            }
156
        } as IgxHeadSelectorTemplateContext;
157

UNCOV
158
        if (this.isHierarchicalGrid) {
×
UNCOV
159
            ctx.$implicit.selectAll = () => this.grid.selectAllRows();
×
UNCOV
160
            ctx.$implicit.deselectAll = () => this.grid.deselectAllRows();
×
161
        }
162

UNCOV
163
        return ctx;
×
164
    }
165

166
    constructor(
167
        protected ref: ElementRef<HTMLElement>,
37✔
168
        protected cdr: ChangeDetectorRef
37✔
169
    ) { }
170

171
    /**
172
     * This hook exists as a workaround for the unfortunate fact
173
     * that when we have pinned columns in the grid, the unpinned columns headers
174
     * are affected by a delayed change detection cycle after a horizontal scroll :(
175
     * Thus, we tell the parent grid change detector to check us at each cycle.
176
     *
177
     * @hidden @internal
178
     */
179
    public ngDoCheck() {
180
        this.cdr.markForCheck();
406✔
181
    }
182

183
    /**
184
     * @hidden @internal
185
     */
186
    public scroll(event: Event) {
187
        this.grid.preventHeaderScroll(event);
×
188
    }
189

190
    public headerRowSelection(event: MouseEvent) {
UNCOV
191
        if (!this.grid.isMultiRowSelectionEnabled) {
×
UNCOV
192
            return;
×
193
        }
194

UNCOV
195
        if (this.grid.selectionService.areAllRowSelected()) {
×
UNCOV
196
            this.grid.selectionService.clearRowSelection(event);
×
197
        } else {
UNCOV
198
            this.grid.selectionService.selectAllRows(event);
×
199
        }
200
    }
201
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc