• 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

3.45
/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row-dimension-header.component.ts
1
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, HostListener, Inject } from '@angular/core';
2

3
import { GridType, IGX_GRID_BASE, PivotGridType } from '../common/grid.interface';
4

5
import { IgxGridHeaderComponent } from '../headers/grid-header.component';
6
import { IgxPivotColumnResizingService } from '../resizing/pivot-grid/pivot-resizing.service';
7
import { SortingIndexPipe } from '../headers/pipes';
8
import { NgTemplateOutlet, NgIf, NgClass } from '@angular/common';
9
import { IgxIconComponent } from '../../icon/icon.component';
10
import { ISortingExpression, SortingDirection } from '../../data-operations/sorting-strategy';
11
import { takeUntil } from 'rxjs/operators';
12
import { PivotRowLayoutType } from './pivot-grid.interface';
13
import { PivotUtil } from './pivot-util';
14

15
/**
16
 * @hidden
17
 */
18
@Component({
19
    changeDetection: ChangeDetectionStrategy.OnPush,
20
    selector: 'igx-pivot-row-dimension-header',
21
    templateUrl: '../headers/grid-header.component.html',
22
    imports: [IgxIconComponent, NgTemplateOutlet, NgIf, NgClass, SortingIndexPipe]
23
})
24
export class IgxPivotRowDimensionHeaderComponent extends IgxGridHeaderComponent implements AfterViewInit {
2✔
25
    private pivotGrid: PivotGridType;
26

27
    constructor(
28
        @Inject(IGX_GRID_BASE) grid: GridType,
UNCOV
29
        public override colResizingService: IgxPivotColumnResizingService,
×
30
        cdr: ChangeDetectorRef,
UNCOV
31
        public refInstance: ElementRef<HTMLElement>
×
32
    ) {
UNCOV
33
        super(grid, colResizingService, cdr, refInstance);
×
34

UNCOV
35
        this.pivotGrid = this.grid as PivotGridType;
×
UNCOV
36
        this.pivotGrid.dimensionsSortingExpressionsChange
×
37
            .pipe(takeUntil(this._destroy$))
UNCOV
38
            .subscribe((_: ISortingExpression[]) => this.setSortIndex());
×
39
    }
40

41
    public ngAfterViewInit(): void {
UNCOV
42
        this.setSortIndex();
×
43
    }
44

45
    @HostListener('click', ['$event'])
46
    public override onClick(event: MouseEvent) {
UNCOV
47
        event.preventDefault();
×
48
    }
49

50
    /**
51
     * @hidden @internal
52
     */
53
    public override get selectable(): boolean {
UNCOV
54
        return false;
×
55
    }
56

57
    /**
58
     * @hidden @internal
59
     */
60
    public override onSortingIconClick(event) {
UNCOV
61
        event.stopPropagation();
×
UNCOV
62
        const dim = this.pivotGrid.getRowDimensionByName(this.column.field);
×
UNCOV
63
        const startDirection = dim.sortDirection || SortingDirection.None;
×
UNCOV
64
        const direction = startDirection + 1 > SortingDirection.Desc ?
×
65
            SortingDirection.None : startDirection + 1;
UNCOV
66
        this.pivotGrid.sortDimension(dim, direction);
×
67
    }
68

69
    protected override getSortDirection() {
UNCOV
70
        const dim = this.pivotGrid.getRowDimensionByName(this.column.field);
×
UNCOV
71
        this.sortDirection = dim?.sortDirection || SortingDirection.None;
×
72
    }
73

74
    protected setSortIndex() {
UNCOV
75
        if (this.column.sortable && this.sortIconContainer) {
×
UNCOV
76
            const visibleRows = this.pivotGrid.pivotUI.rowLayout === PivotRowLayoutType.Vertical ?
×
77
            this.pivotGrid.pivotConfiguration.rows :
78
            PivotUtil.flatten(this.pivotGrid.pivotConfiguration.rows);
UNCOV
79
            const dimIndex = visibleRows.findIndex((target) => target.memberName === this.column.field);
×
UNCOV
80
            const dim = visibleRows[dimIndex];
×
UNCOV
81
            let newSortIndex = -1;
×
UNCOV
82
            if (dim.sortDirection) {
×
UNCOV
83
                let priorSortedDims = 0;
×
UNCOV
84
                for (let i = 0; i < dimIndex; i++) {
×
UNCOV
85
                    if (visibleRows[i].sortDirection) {
×
86
                        priorSortedDims++;
×
87
                    }
88
                }
89

90
                // Sort index starts from 1.
UNCOV
91
                newSortIndex = priorSortedDims + 1;
×
92
            }
93

UNCOV
94
            this.sortIconContainer.nativeElement.setAttribute("data-sortIndex", newSortIndex >= 0 ? newSortIndex : "");
×
95
        }
96
    }
97
}
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