• 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

1.96
/projects/igniteui-angular/src/lib/grids/grid/groupby-row.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    ChangeDetectorRef,
4
    Component,
5
    ElementRef,
6
    HostBinding,
7
    HostListener,
8
    Input,
9
    ViewChild,
10
    TemplateRef,
11
    OnDestroy,
12
    Inject
13
} from '@angular/core';
14
import { NgIf, NgTemplateOutlet, DecimalPipe, DatePipe, getLocaleCurrencyCode, PercentPipe, CurrencyPipe } from '@angular/common';
15

16
import { takeUntil } from 'rxjs/operators';
17
import { Subject } from 'rxjs';
18

19
import { IGroupByRecord } from '../../data-operations/groupby-record.interface';
20
import { GridColumnDataType } from '../../data-operations/data-util';
21
import { IgxGridSelectionService } from '../selection/selection.service';
22
import { GridType, IGX_GRID_BASE } from '../common/grid.interface';
23
import { IgxFilteringService } from '../filtering/grid-filtering.service';
24
import { IgxGridRowComponent } from './grid-row.component';
25
import { GridSelectionMode } from '../common/enums';
26
import { ISelectionNode } from '../common/types';
27
import { IgxCheckboxComponent } from '../../checkbox/checkbox.component';
28
import { IgxBadgeComponent } from '../../badge/badge.component';
29
import { IgxIconComponent } from '../../icon/icon.component';
30
import { IgxColumnFormatterPipe } from '../common/pipes';
31

32
@Component({
33
    changeDetection: ChangeDetectionStrategy.OnPush,
34
    selector: 'igx-grid-groupby-row',
35
    templateUrl: './groupby-row.component.html',
36
    imports: [
37
        NgIf,
38
        NgTemplateOutlet,
39
        DecimalPipe,
40
        DatePipe,
41
        PercentPipe,
42
        CurrencyPipe,
43
        IgxIconComponent,
44
        IgxBadgeComponent,
45
        IgxCheckboxComponent,
46
        IgxColumnFormatterPipe
47
    ]
48
})
49
export class IgxGridGroupByRowComponent implements OnDestroy {
2✔
50
    /**
51
     * @hidden
52
     */
53
    @Input()
54
    public hideGroupRowSelectors: boolean;
55

56
    /**
57
     * @hidden
58
     */
59
    @Input()
60
    public rowDraggable: boolean;
61

62
    /**
63
     * Sets the index of the row.
64
     * ```html
65
     * <igx-grid-groupby-row [gridID]="id" [index]="rowIndex" [groupRow]="rowData" #row></igx-grid-groupby-row>
66
     * ```
67
     */
68
    @Input()
69
    public index: number;
70

71
    /**
72
     * Sets the id of the grid the row belongs to.
73
     * ```html
74
     * <igx-grid-groupby-row [gridID]="id" [index]="rowIndex" [groupRow]="rowData" #row></igx-grid-groupby-row>
75
     * ```
76
     */
77
    @Input()
78
    public gridID: string;
79

80
    /**
81
     * The group record the component renders for.
82
     * ```typescript
83
     * <igx-grid-groupby-row [gridID]="id" [index]="rowIndex" [groupRow]="rowData" #row></igx-grid-groupby-row>
84
     * ```
85
     */
86
    @Input()
87
    public groupRow: IGroupByRecord;
88

89
    /**
90
     * Returns a reference of the content of the group.
91
     * ```typescript
92
     * const groupRowContent = this.grid1.rowList.first.groupContent;
93
     * ```
94
     */
95
    @ViewChild('groupContent', { static: true })
96
    public groupContent: ElementRef;
97

98
    /**
99
     * @hidden
100
     */
101
    @Input()
UNCOV
102
    protected isFocused = false;
×
103

104
    /**
105
     * @hidden
106
     */
107
    @ViewChild('defaultGroupByExpandedTemplate', { read: TemplateRef, static: true })
108
    protected defaultGroupByExpandedTemplate: TemplateRef<any>;
109

110
    /**
111
     * @hidden
112
     */
113
    @ViewChild('defaultGroupByCollapsedTemplate', { read: TemplateRef, static: true })
114
    protected defaultGroupByCollapsedTemplate: TemplateRef<any>;
115

116
    /**
117
     * @hidden
118
     */
UNCOV
119
    protected destroy$ = new Subject<void>();
×
120

121
    /**
122
     * @hidden
123
     */
UNCOV
124
    protected defaultCssClass = 'igx-grid__group-row';
×
125

126
    /**
127
     * @hidden
128
     */
UNCOV
129
    protected paddingIndentationCssClass = 'igx-grid__group-row--padding-level';
×
130

131
    /**
132
     * Returns whether the row is focused.
133
     * ```
134
     * let gridRowFocused = this.grid1.rowList.first.focused;
135
     * ```
136
     */
137
    public get focused(): boolean {
UNCOV
138
        return this.isActive();
×
139
    }
140

141
    /** @hidden @internal */
142
    public get currencyCode(): string {
143
        return this.groupRow.column.pipeArgs.currencyCode ?
×
144
            this.groupRow.column.pipeArgs.currencyCode : getLocaleCurrencyCode(this.grid.locale);
145
    }
146

147
    constructor(
UNCOV
148
        @Inject(IGX_GRID_BASE) public grid: GridType,
×
UNCOV
149
        public gridSelection: IgxGridSelectionService,
×
UNCOV
150
        public element: ElementRef,
×
UNCOV
151
        public cdr: ChangeDetectorRef,
×
UNCOV
152
        public filteringService: IgxFilteringService) {
×
UNCOV
153
        this.gridSelection.selectedRowsChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
×
UNCOV
154
            this.cdr.markForCheck();
×
155
        });
156
    }
157

158

159
    @HostListener('pointerdown')
160
    public activate() {
UNCOV
161
        this.grid.navigation.setActiveNode({ row: this.index });
×
162
    }
163

164
    @HostListener('click', ['$event'])
165
    public onClick(event: MouseEvent) {
UNCOV
166
        this.grid.rowClick.emit({
×
167
            row: this.grid.createRow(this.index),
168
            event
169
        });
170
    }
171

172
    /**
173
     * @hidden
174
     * @internal
175
     */
176
    public ngOnDestroy(): void {
UNCOV
177
        this.destroy$.next();
×
UNCOV
178
        this.destroy$.complete();
×
179
    }
180

181
    /**
182
     * Returns whether the group row is expanded.
183
     * ```typescript
184
     * const groupRowExpanded = this.grid1.rowList.first.expanded;
185
     * ```
186
     */
187
    @HostBinding('attr.aria-expanded')
188
    public get expanded(): boolean {
UNCOV
189
        return this.grid.isExpandedGroup(this.groupRow);
×
190
    }
191

192
    /**
193
     * @hidden
194
     */
195
    @HostBinding('attr.aria-describedby')
196
    public get describedBy(): string {
UNCOV
197
        const grRowExpr = this.groupRow.expression !== undefined ? this.groupRow.expression.fieldName : '';
×
UNCOV
198
        return this.gridID + '_' + grRowExpr;
×
199
    }
200

201
    @HostBinding('attr.data-rowIndex')
202
    public get dataRowIndex() {
UNCOV
203
        return this.index;
×
204
    }
205

206
    /**
207
     * Returns a reference to the underlying HTML element.
208
     * ```typescript
209
     * const groupRowElement = this.nativeElement;
210
     * ```
211
     */
212
    public get nativeElement(): any {
UNCOV
213
        return this.element.nativeElement;
×
214
    }
215

216
    @HostBinding('attr.id')
217
    public get attrCellID() {
UNCOV
218
        return `${this.gridID}_${this.index}`;
×
219
    }
220

221
    /**
222
     * Returns the style classes applied to the group rows.
223
     * ```typescript
224
     * const groupCssStyles = this.grid1.rowList.first.styleClasses;
225
     * ```
226
     */
227
    @HostBinding('class')
228
    public get styleClasses(): string {
UNCOV
229
        return `${this.defaultCssClass} ` + `${this.paddingIndentationCssClass}-` + this.groupRow.level +
×
230
            (this.isActive() ? ` ${this.defaultCssClass}--active` : '');
×
231
    }
232

233
    public isActive() {
UNCOV
234
        return this.grid.navigation.activeNode ? this.grid.navigation.activeNode.row === this.index : false;
×
235
    }
236

237
    /**
238
     * @hidden @internal
239
     */
240
    public getRowID(rowData): IgxGridRowComponent {
UNCOV
241
        return this.grid.primaryKey ? rowData[this.grid.primaryKey] : rowData;
×
242
    }
243

244
    /**
245
     * @hidden @internal
246
     */
247
    public onGroupSelectorClick(event) {
UNCOV
248
        if (!this.grid.isMultiRowSelectionEnabled) {
×
UNCOV
249
            return;
×
250
        }
UNCOV
251
        event.stopPropagation();
×
UNCOV
252
        if (this.areAllRowsInTheGroupSelected) {
×
UNCOV
253
            this.gridSelection.deselectRows(this.groupRow.records.map(x => this.getRowID(x)));
×
254
        } else {
UNCOV
255
            this.gridSelection.selectRows(this.groupRow.records.map(x => this.getRowID(x)));
×
256
        }
257
    }
258

259
    /**
260
     * Toggles the group row.
261
     * ```typescript
262
     * this.grid1.rowList.first.toggle()
263
     * ```
264
     */
265
    public toggle() {
UNCOV
266
        this.grid.toggleGroup(this.groupRow);
×
267
    }
268

269
    public get iconTemplate() {
UNCOV
270
        if (this.expanded) {
×
UNCOV
271
            return this.grid.rowExpandedIndicatorTemplate || this.defaultGroupByExpandedTemplate;
×
272
        } else {
UNCOV
273
            return this.grid.rowCollapsedIndicatorTemplate || this.defaultGroupByCollapsedTemplate;
×
274
        }
275
    }
276

277
    protected get selectionNode(): ISelectionNode {
278
        return {
×
279
            row: this.index,
280
            column: this.gridSelection.activeElement ? this.gridSelection.activeElement.column : 0
×
281
        };
282
    }
283

284
    /**
285
     * @hidden @internal
286
    */
287
    public get dataType(): any {
UNCOV
288
        const column = this.groupRow.column;
×
UNCOV
289
        return (column && column.dataType) || GridColumnDataType.String;
×
290
    }
291

292
    /**
293
     * @hidden @internal
294
     */
295
    public get formatter(): any {
UNCOV
296
        const column = this.groupRow.column;
×
UNCOV
297
        return (column && column.formatter) || null;
×
298
    }
299

300
    /**
301
     * @hidden @internal
302
     */
303
    public get areAllRowsInTheGroupSelected(): boolean {
UNCOV
304
        return this.groupRow.records.every(x => this.gridSelection.isRowSelected(this.getRowID(x)));
×
305
    }
306

307
    /**
308
     * @hidden @internal
309
     */
310
    public get selectedRowsInTheGroup(): any[] {
UNCOV
311
        const selectedIds = new Set(this.gridSelection.filteredSelectedRowIds);
×
UNCOV
312
        return this.groupRow.records.filter(rowID => selectedIds.has(this.getRowID(rowID)));
×
313
    }
314

315
    /**
316
     * @hidden @internal
317
     */
318
    public get groupByRowCheckboxIndeterminateState(): boolean {
UNCOV
319
        if (this.selectedRowsInTheGroup.length > 0) {
×
UNCOV
320
            return !this.areAllRowsInTheGroupSelected;
×
321
        }
UNCOV
322
        return false;
×
323
    }
324

325
    /**
326
     * @hidden @internal
327
     */
328
    public get groupByRowSelectorBaseAriaLabel(): string {
UNCOV
329
        const ariaLabel: string = this.areAllRowsInTheGroupSelected ?
×
330
            this.grid.resourceStrings.igx_grid_groupByArea_deselect_message : this.grid.resourceStrings.igx_grid_groupByArea_select_message;
UNCOV
331
        return ariaLabel.replace('{0}', this.groupRow.expression.fieldName).replace('{1}', this.groupRow.value);
×
332
    }
333

334
    /**
335
     * @hidden @internal
336
     */
337
    public get showRowSelectors(): boolean {
UNCOV
338
        return this.grid.rowSelection !== GridSelectionMode.none && !this.hideGroupRowSelectors;
×
339
    }
340

341
}
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