• 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

2.08
/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row-dimension-content.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    ChangeDetectorRef,
4
    Component,
5
    createComponent,
6
    ElementRef,
7
    EnvironmentInjector,
8
    HostBinding,
9
    Inject,
10
    Injector,
11
    Input,
12
    OnChanges,
13
    QueryList,
14
    SimpleChanges,
15
    TemplateRef,
16
    ViewChild,
17
    ViewChildren,
18
    ViewContainerRef
19
} from '@angular/core';
20
import { IgxColumnComponent } from '../columns/column.component';
21
import { IGX_GRID_BASE, PivotGridType } from '../common/grid.interface';
22
import { IgxGridHeaderRowComponent } from '../headers/grid-header-row.component';
23
import { IPivotDimension, IPivotDimensionData, IPivotGridGroupRecord } from './pivot-grid.interface';
24
import { IgxPivotRowDimensionHeaderGroupComponent } from './pivot-row-dimension-header-group.component';
25
import { PivotUtil } from './pivot-util';
26
import { IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe } from '../headers/pipes';
27
import { IgxIconComponent } from '../../icon/icon.component';
28
import { NgClass, NgStyle } from '@angular/common';
29
import { IMultiRowLayoutNode } from '../common/types';
30

31
/**
32
 *
33
 * For all intents & purposes treat this component as what a <thead> usually is in the default <table> element.
34
 *
35
 * This container holds the pivot grid header elements and their behavior/interactions.
36
 *
37
 * @hidden @internal
38
 */
39
@Component({
40
    changeDetection: ChangeDetectionStrategy.OnPush,
41
    selector: 'igx-pivot-row-dimension-content',
42
    templateUrl: './pivot-row-dimension-content.component.html',
43
    imports: [IgxPivotRowDimensionHeaderGroupComponent, NgClass, NgStyle, IgxIconComponent, IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe]
44
})
45
export class IgxPivotRowDimensionContentComponent extends IgxGridHeaderRowComponent implements OnChanges {
2✔
46
    @HostBinding('style.grid-row-start')
47
    public get rowStart(): string {
UNCOV
48
        return this.layout ? `${this.layout.rowStart}` : "";
×
49
    }
50

51
    @HostBinding('style.grid-row-end')
52
    public get rowsEnd(): string {
UNCOV
53
        return this.layout ? `${this.layout.rowEnd}` : "";
×
54
    }
55

56
    @HostBinding('style.grid-column-start')
57
    public get colStart(): string {
UNCOV
58
        return this.layout ? `${this.layout.colStart}` : "";
×
59
    }
60

61
    @HostBinding('style.grid-column-end')
62
    public get colEnd(): string {
UNCOV
63
        return this.layout ? `${this.layout.colEnd}` : "";
×
64
    }
65

66
    /**
67
     * @hidden
68
     * @internal
69
     */
70
    @Input()
71
    public rowIndex: number;
72

73
    /**
74
     * @hidden
75
     * @internal
76
     */
77
    @Input()
78
    public colIndex: number;
79

80
    @Input()
81
    public layout: IMultiRowLayoutNode;
82

83
    @Input()
84
    public dimension: IPivotDimension;
85

86
    @Input()
87
    public rootDimension: IPivotDimension;
88

89
    @Input()
90
    public rowData: IPivotGridGroupRecord;
91

92
    /**
93
    * @hidden @internal
94
    */
95
    @ViewChild('headerTemplate', { read: TemplateRef, static: true })
96
    public headerTemplate: TemplateRef<any>;
97

98
    /**
99
     * @hidden @internal
100
     */
101
    @ViewChild('headerDefaultTemplate', { read: TemplateRef, static: true })
102
    public headerTemplateDefault: TemplateRef<any>;
103

104
    @ViewChildren(IgxPivotRowDimensionHeaderGroupComponent)
105
    public headerGroups: QueryList<IgxPivotRowDimensionHeaderGroupComponent>
106

107
    constructor(
UNCOV
108
        @Inject(IGX_GRID_BASE) public override grid: PivotGridType,
×
109
        ref: ElementRef<HTMLElement>,
UNCOV
110
        protected injector: Injector,
×
UNCOV
111
        protected envInjector: EnvironmentInjector,
×
112
        cdr: ChangeDetectorRef,
UNCOV
113
        protected viewRef: ViewContainerRef
×
114
    ) {
UNCOV
115
        super(ref, cdr);
×
116
    }
117

118
    /**
119
     * @hidden @internal
120
     */
121
    public rowDimensionData: IPivotDimensionData;
122

123
    public get rowDimensionColumn() {
UNCOV
124
        return this.rowDimensionData?.column;
×
125
    }
126

127
    /**
128
    * @hidden
129
    * @internal
130
    */
131
    public ngOnChanges(changes: SimpleChanges) {
UNCOV
132
        if (changes.rowData) {
×
133
            // generate new rowDimension on row data change
UNCOV
134
            this.rowDimensionData = null;
×
UNCOV
135
            this.viewRef.clear();
×
UNCOV
136
            this.extractFromDimensions();
×
UNCOV
137
            this.viewRef.clear();
×
138
        }
UNCOV
139
        if (changes.width && this.rowDimensionData) {
×
UNCOV
140
            const data = this.rowDimensionData;
×
UNCOV
141
            data.column.width = this.grid.rowDimensionWidthToPixels(this.rootDimension) + 'px';
×
142
        }
143
    }
144

145
    /**
146
    * @hidden
147
    * @internal
148
    */
149
    public toggleRowDimension(event) {
UNCOV
150
        this.grid.toggleRow(this.getRowDimensionKey());
×
UNCOV
151
        this.grid.navigation.onRowToggle(this.getExpandState(), this.dimension, this.rowData, this.layout);
×
UNCOV
152
        event?.stopPropagation();
×
153
    }
154

155

156
    /**
157
     * @hidden
158
     * @internal
159
     */
160
    public getRowDimensionKey() {
UNCOV
161
        const dimData = this.rowDimensionData;
×
UNCOV
162
        const key = PivotUtil.getRecordKey(this.rowData, dimData.dimension);
×
UNCOV
163
        return key;
×
164
    }
165

166
    public getExpandState() {
UNCOV
167
        return this.grid.gridAPI.get_row_expansion_state(this.getRowDimensionKey());
×
168
    }
169

170
    public getLevel() {
UNCOV
171
        return this.grid.hasHorizontalLayout ? 0 : this.dimension.level;
×
172
    }
173

174
    protected getHeaderWidthFromDimension() {
UNCOV
175
        if (this.grid.hasHorizontalLayout) {
×
UNCOV
176
            return this.width === -1 ? 'fit-content' : this.width;
×
177
        }
UNCOV
178
        return this.grid.rowDimensionWidth(this.rootDimension);
×
179
    }
180

181
    protected extractFromDimensions() {
UNCOV
182
        if (this.dimension && this.rowData) {
×
UNCOV
183
            const col = this.extractFromDimension(this.dimension, this.rowData);
×
UNCOV
184
            const prevDims = [];
×
UNCOV
185
            this.rowDimensionData = {
×
186
                column: col,
187
                dimension: this.dimension,
188
                prevDimensions: prevDims
189
            };
190
        }
191
    }
192

193
    protected extractFromDimension(dim: IPivotDimension, rowData: IPivotGridGroupRecord) {
UNCOV
194
        const field = dim.memberName;
×
UNCOV
195
        const header = rowData?.dimensionValues.get(field);
×
UNCOV
196
        const col = this._createColComponent(field, header, dim);
×
UNCOV
197
        return col;
×
198
    }
199

200
    protected _createColComponent(field: string, header: string, dim: IPivotDimension) {
UNCOV
201
        const ref = createComponent(IgxColumnComponent, { environmentInjector: this.envInjector, elementInjector: this.injector});
×
UNCOV
202
        ref.instance.field = field;
×
UNCOV
203
        ref.instance.header = header;
×
UNCOV
204
        ref.instance.width = this.grid.rowDimensionWidthToPixels(this.rootDimension) + 'px';
×
UNCOV
205
        ref.instance.resizable = this.grid.rowDimensionResizing;
×
UNCOV
206
        (ref as any).instance._vIndex = this.grid.columns.length + this.rowIndex + this.rowIndex * this.grid.pivotConfiguration.rows.length;
×
207

208

UNCOV
209
        if (header && dim.childLevel && (!this.rowData.totalRecordDimensionName || this.rowData.totalRecordDimensionName !== dim.memberName)) {
×
UNCOV
210
            ref.instance.headerTemplate = this.headerTemplate;
×
211
        } else {
UNCOV
212
            ref.instance.headerTemplate = this.headerTemplateDefault;
×
213
        }
UNCOV
214
        return ref.instance;
×
215
    }
216
}
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