• 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

72.09
/projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
1
import { Inject, Pipe, PipeTransform } from '@angular/core';
2
import { cloneArray } from '../../core/utils';
3
import { DataUtil } from '../../data-operations/data-util';
4
import { IGroupByExpandState } from '../../data-operations/groupby-expand-state.interface';
5
import { IGroupByResult } from '../../data-operations/grouping-result.interface';
6
import { IFilteringExpressionsTree, FilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
7
import { IGroupingExpression } from '../../data-operations/grouping-expression.interface';
8
import { GridType, IGX_GRID_BASE } from '../common/grid.interface';
9
import { FilterUtil, IFilteringStrategy } from '../../data-operations/filtering-strategy';
10
import { GridPagingMode } from '../common/enums';
11
import { ISortingExpression } from '../../data-operations/sorting-strategy';
12
import { IGridSortingStrategy, IGridGroupingStrategy } from '../common/strategy';
13

14
/**
15
 * @hidden
16
 */
17
@Pipe({
18
    name: 'gridSort',
19
    standalone: true
20
})
21
export class IgxGridSortingPipe implements PipeTransform {
2✔
22

23
    constructor(@Inject(IGX_GRID_BASE) private grid: GridType) { }
37✔
24

25
    public transform(collection: any[], sortExpressions: ISortingExpression[], groupExpressions: IGroupingExpression[], sorting: IGridSortingStrategy,
26
        id: string, pipeTrigger: number, pinned?): any[] {
27
        let result: any[];
28
        const expressions = groupExpressions.concat(sortExpressions);
67✔
29
        if (!expressions.length) {
67!
30
            result = collection;
67✔
31
        } else {
UNCOV
32
            result = DataUtil.sort(cloneArray(collection), expressions, sorting, this.grid);
×
33
        }
34
        this.grid.setFilteredSortedData(result, pinned);
67✔
35

36
        return result;
67✔
37
    }
38
}
39

40
/**
41
 * @hidden
42
 */
43
@Pipe({
44
    name: 'gridGroupBy',
45
    standalone: true
46
})
47
export class IgxGridGroupingPipe implements PipeTransform {
2✔
48

49
    constructor(@Inject(IGX_GRID_BASE) private grid: GridType) { }
36✔
50

51
    public transform(collection: any[], expression: IGroupingExpression | IGroupingExpression[],
52
        expansion: IGroupByExpandState | IGroupByExpandState[],
53
        groupingStrategy: IGridGroupingStrategy, defaultExpanded: boolean,
54
        id: string, groupsRecords: any[], _pipeTrigger: number): IGroupByResult {
55

56
        const state = { expressions: [], expansion: [], defaultExpanded };
66✔
57
        state.expressions = this.grid.groupingExpressions;
66✔
58
        let result: IGroupByResult;
59
        const fullResult: IGroupByResult = { data: [], metadata: [] };
66✔
60

61
        if (!state.expressions.length) {
66!
62
            // empty the array without changing reference
63
            groupsRecords.splice(0, groupsRecords.length);
66✔
64
            result = {
66✔
65
                data: collection,
66
                metadata: collection
67
            };
68
        } else {
UNCOV
69
            state.expansion = this.grid.groupingExpansionState;
×
UNCOV
70
            state.defaultExpanded = this.grid.groupsExpanded;
×
UNCOV
71
            result = DataUtil.group(cloneArray(collection), state, groupingStrategy, this.grid, groupsRecords, fullResult);
×
72
        }
73
        this.grid.groupingFlatResult = result.data;
66✔
74
        this.grid.groupingResult = fullResult.data;
66✔
75
        this.grid.groupingMetadata = fullResult.metadata;
66✔
76
        return result;
66✔
77
    }
78
}
79

80
/**
81
 * @hidden
82
 */
83
@Pipe({
84
    name: 'gridPaging',
85
    standalone: true
86
})
87
export class IgxGridPagingPipe implements PipeTransform {
2✔
88

89
    constructor(@Inject(IGX_GRID_BASE) private grid: GridType) { }
36✔
90

91
    public transform(collection: IGroupByResult, enabled: boolean, page = 0, perPage = 15, _: number): IGroupByResult {
×
92
        if (!enabled || this.grid.pagingMode !== GridPagingMode.Local) {
66!
93
            return collection;
66✔
94
        }
UNCOV
95
        const state = {
×
96
            index: page,
97
            recordsPerPage: perPage
98
        };
UNCOV
99
        const total = this.grid._totalRecords >= 0 ? this.grid._totalRecords : collection.data?.length;
×
UNCOV
100
        DataUtil.correctPagingState(state, total);
×
101

UNCOV
102
        const result = {
×
103
            data: DataUtil.page(cloneArray(collection.data), state, total),
104
            metadata: DataUtil.page(cloneArray(collection.metadata), state, total)
105
        };
UNCOV
106
        if (this.grid.page !== state.index) {
×
UNCOV
107
            this.grid.page = state.index;
×
108
        }
UNCOV
109
        this.grid.pagingState = state;
×
UNCOV
110
        return result;
×
111
    }
112
}
113

114
/**
115
 * @hidden
116
 */
117
@Pipe({
118
    name: 'gridFiltering',
119
    standalone: true
120
})
121
export class IgxGridFilteringPipe implements PipeTransform {
2✔
122

123
    constructor(@Inject(IGX_GRID_BASE) private grid: GridType) { }
37✔
124

125
    public transform(collection: any[], expressionsTree: IFilteringExpressionsTree,
126
        filterStrategy: IFilteringStrategy,
127
        advancedExpressionsTree: IFilteringExpressionsTree, id: string, pipeTrigger: number, filteringPipeTrigger: number, pinned?) {
128
        const state = {
72✔
129
            expressionsTree,
130
            strategy: filterStrategy,
131
            advancedExpressionsTree
132
        };
133

134
        if (FilteringExpressionsTree.empty(state.expressionsTree) && FilteringExpressionsTree.empty(state.advancedExpressionsTree)) {
72✔
135
            return collection;
49✔
136
        }
137

138
        const result = FilterUtil.filter(cloneArray(collection), state, this.grid);
23✔
139
        this.grid.setFilteredData(result, pinned);
23✔
140
        return result;
23✔
141
    }
142
}
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