• 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

52.94
/projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-row.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    Component,
4
    HostBinding,
5
    forwardRef,
6
    ElementRef,
7
    ViewChildren,
8
    QueryList,
9
    ViewChild,
10
    TemplateRef
11
} from '@angular/core';
12
import { IgxRowDirective } from '../row.directive';
13
import { IgxHierarchicalGridCellComponent } from './hierarchical-cell.component';
14
import { GridType } from '../common/grid.interface';
15
import { IgxGridNotGroupedPipe, IgxGridCellStylesPipe, IgxGridCellStyleClassesPipe, IgxGridDataMapperPipe, IgxGridTransactionStatePipe } from '../common/pipes';
16
import { IgxCheckboxComponent } from '../../checkbox/checkbox.component';
17
import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
18
import { IgxRowDragDirective } from '../row-drag.directive';
19
import { IgxIconComponent } from '../../icon/icon.component';
20
import { NgTemplateOutlet, NgIf, NgClass, NgStyle, NgFor } from '@angular/common';
21

22
@Component({
23
    changeDetection: ChangeDetectionStrategy.OnPush,
24
    selector: 'igx-hierarchical-grid-row',
25
    templateUrl: './hierarchical-row.component.html',
26
    providers: [{ provide: IgxRowDirective, useExisting: forwardRef(() => IgxHierarchicalRowComponent) }],
5✔
27
    imports: [NgTemplateOutlet, IgxIconComponent, NgIf, IgxRowDragDirective, NgClass, IgxGridForOfDirective, IgxHierarchicalGridCellComponent, NgStyle, IgxCheckboxComponent, NgFor, IgxGridNotGroupedPipe, IgxGridCellStylesPipe, IgxGridCellStyleClassesPipe, IgxGridDataMapperPipe, IgxGridTransactionStatePipe]
28
})
29
export class IgxHierarchicalRowComponent extends IgxRowDirective {
2✔
30
    @ViewChild('expander', { read: ElementRef })
31
    public expander: ElementRef<HTMLElement>;
32

33
    @ViewChildren(forwardRef(() => IgxHierarchicalGridCellComponent), { read: IgxHierarchicalGridCellComponent })
2✔
34
    protected override _cells: QueryList<IgxHierarchicalGridCellComponent>;
35

36
    /**
37
     * @hidden
38
     */
39
    @ViewChild('defaultExpandedTemplate', { read: TemplateRef, static: true })
40
    protected defaultExpandedTemplate: TemplateRef<any>;
41

42
    /**
43
     * @hidden
44
     */
45
    @ViewChild('defaultEmptyTemplate', { read: TemplateRef, static: true })
46
    protected defaultEmptyTemplate: TemplateRef<any>;
47

48
    /**
49
     * @hidden
50
     */
51
    @ViewChild('defaultCollapsedTemplate', { read: TemplateRef, static: true })
52
    protected defaultCollapsedTemplate: TemplateRef<any>;
53

54
    protected expanderClass = 'igx-grid__hierarchical-expander';
5✔
55
    protected rolActionClass = 'igx-grid__tr-action';
5✔
56

57
    /**
58
     * @hidden
59
     */
60
    public get expanderClassResolved() {
61
        return {
54✔
62
            [`${this.expanderClass} ${this.rolActionClass}`]: !this.pinned || this.disabled,
54!
63
            [`${this.expanderClass}--empty`]: this.pinned && !this.disabled
54!
64
        };
65
    }
66

67
    public override get viewIndex(): number {
68
        return this.index + this.grid.page * this.grid.perPage;
324✔
69
    }
70

71
    /**
72
     * Returns whether the row is expanded.
73
     * ```typescript
74
     * const RowExpanded = this.grid1.rowList.first.expanded;
75
     * ```
76
     */
77
    public override get expanded() {
78
        return this.grid.gridAPI.get_row_expansion_state(this.data);
104✔
79
    }
80

81
    /**
82
     * @hidden
83
     */
84
    @HostBinding('class.igx-grid__tr--expanded')
85
    public get expandedClass() {
86
        return this.expanded && !this.pinned;
50!
87
    }
88

89
    public override get hasChildren() {
90
        return !!this.grid.childLayoutKeys.length;
54✔
91
    }
92

93
    /**
94
     * @hidden
95
     */
96
    @HostBinding('class.igx-grid__tr--highlighted')
97
    public get highlighted() {
98
        return this.grid && this.grid.highlightedRowID === this.key;
50✔
99
    }
100

101
    /**
102
     * @hidden
103
     */
104
    public expanderClick(event) {
UNCOV
105
        event.stopPropagation();
×
UNCOV
106
        this.toggle();
×
107
    }
108

109
    /**
110
     * Toggles the hierarchical row.
111
     * ```typescript
112
     * this.grid1.rowList.first.toggle()
113
     * ```
114
     */
115
    public toggle() {
UNCOV
116
        if (this.added) {
×
117
            return;
×
118
        }
119
        // K.D. 28 Feb, 2022 #10634 Don't trigger endEdit/commit upon row expansion state change
120
        // this.endEdit(this.grid.rootGrid);
UNCOV
121
        this.grid.gridAPI.set_row_expansion_state(this.key, !this.expanded);
×
UNCOV
122
        this.grid.cdr.detectChanges();
×
123
    }
124

125
    /**
126
     * @hidden
127
     * @internal
128
     */
129
    public select = () => {
5✔
UNCOV
130
        this.grid.selectRows([this.key]);
×
131
    };
132

133
    /**
134
     * @hidden
135
     * @internal
136
     */
137
    public deselect = () => {
5✔
138
        this.grid.deselectRows([this.key]);
×
139
    };
140

141
    /**
142
     * @hidden
143
     */
144
    public get iconTemplate() {
145
        let expandable = true;
54✔
146
        if (this.grid.hasChildrenKey) {
54!
UNCOV
147
            expandable = this.data[this.grid.hasChildrenKey];
×
148
        }
149
        if (!expandable || (this.pinned && !this.disabled)) {
54!
UNCOV
150
            return this.defaultEmptyTemplate;
×
151
        }
152
        if (this.expanded) {
54!
UNCOV
153
            return this.grid.rowExpandedIndicatorTemplate || this.defaultExpandedTemplate;
×
154
        } else {
155
            return this.grid.rowCollapsedIndicatorTemplate || this.defaultCollapsedTemplate;
54✔
156
        }
157
    }
158

159
    // TODO: consider moving into CRUD
160
    protected endEdit(grid: GridType) {
161
        if (grid.gridAPI.crudService.cellInEditMode) {
×
162
            grid.gridAPI.crudService.endEdit();
×
163
        }
164
        grid.gridAPI.getChildGrids(true).forEach(g => {
×
165
            if (g.gridAPI.crudService.cellInEditMode) {
×
166
                g.gridAPI.crudService.endEdit();
×
167
            }
168
        });
169
    }
170
}
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