• 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

51.43
/projects/igniteui-angular/src/lib/grids/summaries/summary-cell.component.ts
1
import { Component, Input, HostBinding, HostListener, ChangeDetectionStrategy, ElementRef, TemplateRef, booleanAttribute } from '@angular/core';
2
import {
3
    IgxSummaryOperand,
4
    IgxSummaryResult
5
} from './grid-summary';
6
import { GridColumnDataType } from '../../data-operations/data-util';
7
import { formatCurrency, formatDate, formatNumber, formatPercent, getLocaleCurrencyCode, getLocaleCurrencySymbol, NgIf, NgTemplateOutlet, NgFor } from '@angular/common';
8
import { ISelectionNode } from '../common/types';
9
import { ColumnType } from '../common/grid.interface';
10

11
@Component({
12
    changeDetection: ChangeDetectionStrategy.OnPush,
13
    selector: 'igx-grid-summary-cell',
14
    templateUrl: './summary-cell.component.html',
15
    imports: [NgIf, NgTemplateOutlet, NgFor]
16
})
17
export class IgxSummaryCellComponent {
2✔
18

19
    @Input()
20
    public summaryResults: IgxSummaryResult[];
21

22
    @Input()
23
    public column: ColumnType;
24

25
    @Input()
26
    public firstCellIndentation = 0;
225✔
27

28
    @Input({ transform: booleanAttribute })
29
    public hasSummary = false;
225✔
30

31
    @Input()
32
    public summaryFormatter: (summaryResult: IgxSummaryResult, summaryOperand: IgxSummaryOperand) => any;
33

34
    @Input()
35
    public summaryTemplate: TemplateRef<any>;
36

37
    /** @hidden */
38
    @Input()
39
    @HostBinding('class.igx-grid-summary--active')
40
    public active: boolean;
41

42
    @Input()
43
    @HostBinding('attr.data-rowIndex')
44
    public rowIndex: number;
45

46
    constructor(private element: ElementRef) {
225✔
47
    }
48

49
    @HostBinding('attr.data-visibleIndex')
50
    public get visibleColumnIndex(): number {
51
        return this.column.visibleIndex;
4,450✔
52
    }
53

54
    @HostBinding('attr.id')
55
    public get attrCellID() {
56
        return `${this.grid.id}_${this.rowIndex}_${this.visibleColumnIndex}`;
2,225✔
57
    }
58

59
    @HostListener('pointerdown')
60
    public activate() {
UNCOV
61
        const currNode = this.grid.navigation.activeNode;
×
UNCOV
62
        if (currNode && this.rowIndex === currNode.row && this.visibleColumnIndex === currNode.column) {
×
63
            return;
×
64
        }
65

UNCOV
66
        this.grid.navigation.setActiveNode({ row: this.rowIndex, column: this.visibleColumnIndex }, 'summaryCell');
×
UNCOV
67
        this.grid.cdr.detectChanges();
×
68
    }
69

70
    protected get selectionNode(): ISelectionNode {
71
        return {
×
72
            row: this.rowIndex,
73
            column: this.column.columnLayoutChild ? this.column.parent.visibleIndex : this.visibleColumnIndex,
×
74
            isSummaryRow: true
75
        };
76
    }
77

78
    public get width() {
79
        return this.column.getCellWidth();
×
80
    }
81

82
    public get nativeElement(): any {
UNCOV
83
        return this.element.nativeElement;
×
84
    }
85

86
    public get columnDatatype(): GridColumnDataType {
87
        return this.column.dataType;
×
88
    }
89

90
    public get itemHeight() {
91
        return this.column.grid.defaultSummaryHeight;
358✔
92
    }
93

94
    /**
95
     * @hidden
96
     */
97
    public get grid() {
98
        return (this.column.grid as any);
3,299✔
99
    }
100

101
    /**
102
     * @hidden @internal
103
     */
104
    public get currencyCode(): string {
UNCOV
105
        return this.column.pipeArgs.currencyCode ?
×
106
            this.column.pipeArgs.currencyCode : getLocaleCurrencyCode(this.grid.locale);
107
    }
108

109
    /**
110
     * @hidden @internal
111
     */
112
    public get currencySymbol(): string {
UNCOV
113
        return this.column.pipeArgs.display ?
×
114
            this.column.pipeArgs.display : getLocaleCurrencySymbol(this.grid.locale);
115
    }
116

117
    public translateSummary(summary: IgxSummaryResult): string {
118
        return this.grid.resourceStrings[`igx_grid_summary_${summary.key}`] || summary.label;
358!
119
    }
120

121
    /**
122
     * @hidden @internal
123
     */
124
    public formatSummaryResult(summary: IgxSummaryResult): string {
125
        if (summary.summaryResult === undefined || summary.summaryResult === null || summary.summaryResult === '') {
716!
UNCOV
126
            return '';
×
127
        }
128

129
        if (this.summaryFormatter) {
716!
UNCOV
130
            return this.summaryFormatter(summary, this.column.summaries);
×
131
        }
132

133
        const args = this.column.pipeArgs;
716✔
134
        const locale = this.grid.locale;
716✔
135

136
        if (summary.key === 'count') {
716✔
137
            return formatNumber(summary.summaryResult, locale)
244✔
138
        }
139

140
        if (summary.defaultFormatting) {
472✔
141
            switch (this.column.dataType) {
472!
142
                case GridColumnDataType.Number:
143
                    return formatNumber(summary.summaryResult, locale, args.digitsInfo);
472✔
144
                case GridColumnDataType.Date:
145
                case GridColumnDataType.DateTime:
146
                case GridColumnDataType.Time:
UNCOV
147
                    return formatDate(summary.summaryResult, args.format, locale, args.timezone);
×
148
                case GridColumnDataType.Currency:
UNCOV
149
                    return formatCurrency(summary.summaryResult, locale, this.currencySymbol, this.currencyCode, args.digitsInfo);
×
150
                case GridColumnDataType.Percent:
UNCOV
151
                    return formatPercent(summary.summaryResult, locale, args.digitsInfo);
×
152
            }
153
        }
UNCOV
154
        return summary.summaryResult;
×
155
    }
156
}
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