• 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

9.52
/projects/igniteui-angular/src/lib/data-operations/pivot-sort-strategy.ts
1
import { parseDate } from '../core/utils';
2
import { PivotGridType } from '../grids/common/grid.interface';
3
import { IPivotGridRecord } from '../grids/pivot-grid/pivot-grid.interface';
4
import { PivotUtil } from '../grids/pivot-grid/pivot-util';
5
import { GridColumnDataType } from './data-util';
6
import { DefaultSortingStrategy, SortingDirection } from './sorting-strategy';
7

8
export class DefaultPivotGridRecordSortingStrategy extends DefaultSortingStrategy {
9
    protected static override _instance: DefaultPivotGridRecordSortingStrategy = null;
2✔
10
    public static override instance(): DefaultPivotGridRecordSortingStrategy {
UNCOV
11
        return this._instance || (this._instance = new this());
×
12
    }
13
    public override sort(data: any[],
14
        fieldName: string,
15
        dir: SortingDirection,
16
        ignoreCase: boolean,
17
        valueResolver: (obj: any, key: string, isDate?: boolean) => any,
18
        isDate?: boolean,
19
        isTime?: boolean,
20
        _grid?: PivotGridType) {
UNCOV
21
        const reverse = (dir === SortingDirection.Desc ? -1 : 1);
×
UNCOV
22
        const cmpFunc = (obj1, obj2) => this.compareObjects(obj1, obj2, fieldName, reverse, ignoreCase, this.getFieldValue, isDate, isTime);
×
UNCOV
23
        return this.arraySort(data, cmpFunc);
×
24
    }
25

26
    protected getFieldValue(obj: IPivotGridRecord, key: string, _isDate = false, _isTime = false): any {
×
UNCOV
27
        return obj.aggregationValues.get(key);
×
28
    }
29
}
30

31

32
export class DefaultPivotSortingStrategy extends DefaultSortingStrategy {
33
    protected static override _instance: DefaultPivotSortingStrategy = null;
2✔
34
    protected dimension;
35
    public static override instance(): DefaultPivotSortingStrategy {
UNCOV
36
        return this._instance || (this._instance = new this());
×
37
    }
38
    public override sort(data: any[],
39
        fieldName: string,
40
        dir: SortingDirection,
41
        ignoreCase: boolean,
42
        valueResolver: (obj: any, key: string, isDate?: boolean) => any,
43
        isDate?: boolean,
44
        isTime?: boolean,
45
        grid?: PivotGridType) {
UNCOV
46
        const key = fieldName;
×
UNCOV
47
        const allDimensions = grid.allDimensions;
×
UNCOV
48
        const enabledDimensions = allDimensions.filter(x => x && x.enabled);
×
UNCOV
49
        this.dimension = PivotUtil.flatten(enabledDimensions).find(x => x.memberName === key);
×
UNCOV
50
        const reverse = (dir === SortingDirection.Desc ? -1 : 1);
×
UNCOV
51
        const cmpFunc = (obj1, obj2) => this.compareObjects(obj1, obj2, key, reverse, ignoreCase, this.getFieldValue, isDate, isTime);
×
UNCOV
52
        return this.arraySort(data, cmpFunc);
×
53
    }
54

55
    protected getFieldValue(obj: any, key: string, _isDate = false, isTime = false): any {
×
UNCOV
56
        let resolvedValue = PivotUtil.extractValueFromDimension(this.dimension, obj) || obj[0];
×
UNCOV
57
        const formatAsDate = this.dimension.dataType === GridColumnDataType.Date || this.dimension.dataType === GridColumnDataType.DateTime;
×
UNCOV
58
        if (formatAsDate) {
×
UNCOV
59
            const date = parseDate(resolvedValue);
×
UNCOV
60
            resolvedValue = isTime && date ?
×
61
                new Date().setHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()) : date;
62

63
        }
UNCOV
64
        return resolvedValue;
×
65
    }
66
}
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