• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13949450844

19 Mar 2025 02:46PM CUT coverage: 91.638%. First build
13949450844

Pull #15523

github

web-flow
Merge 0e52e01ef into 3fb0f11cc
Pull Request #15523: Enable filtering expression `conditionName` only use. Related fixes for elements Blazor grid.

13315 of 15569 branches covered (85.52%)

4 of 4 new or added lines in 1 file covered. (100.0%)

26839 of 29288 relevant lines covered (91.64%)

34010.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.86
/projects/igniteui-angular/src/lib/grids/grouping/tree-grid-group-by-area.component.ts
1
import {
2
    AfterContentInit,
3
    Component,
4
    ElementRef,
5
    Input,
6
    IterableDiffer,
7
    IterableDiffers,
8
    OnDestroy,
9
    booleanAttribute,
10
} from '@angular/core';
11
import { Subject } from 'rxjs';
12
import { takeUntil } from 'rxjs/operators';
13
import { IChipsAreaReorderEventArgs } from '../../chips/public_api';
14
import { PlatformUtil } from '../../core/utils';
15
import { IGroupingExpression } from '../../data-operations/grouping-expression.interface';
16
import { ISortingExpression } from '../../data-operations/sorting-strategy';
17
import { IgxGroupByAreaDirective, IgxGroupByMetaPipe } from './group-by-area.directive';
18
import { IgxDropDirective } from '../../directives/drag-drop/drag-drop.directive';
19
import { IgxGroupAreaDropDirective } from '../grid.directives';
20
import { IgxSuffixDirective } from '../../directives/suffix/suffix.directive';
21
import { IgxIconComponent } from '../../icon/icon.component';
22
import { IgxChipComponent } from '../../chips/chip.component';
23
import { NgTemplateOutlet } from '@angular/common';
24
import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
25

26
/**
27
 * An internal component representing the group-by drop area for the igx-grid component.
28
 *
29
 * @hidden @internal
30
 */
31
@Component({
32
    selector: 'igx-tree-grid-group-by-area',
33
    templateUrl: 'group-by-area.component.html',
34
    providers: [{ provide: IgxGroupByAreaDirective, useExisting: IgxTreeGridGroupByAreaComponent }],
35
    imports: [IgxChipsAreaComponent, IgxChipComponent, IgxIconComponent, IgxSuffixDirective, IgxGroupAreaDropDirective, IgxDropDirective, NgTemplateOutlet, IgxGroupByMetaPipe]
36
})
37
export class IgxTreeGridGroupByAreaComponent extends IgxGroupByAreaDirective implements AfterContentInit, OnDestroy {
2✔
38
    @Input({ transform: booleanAttribute })
39
    public get hideGroupedColumns() {
40
        return this._hideGroupedColumns;
4✔
41
    }
42

43
    public set hideGroupedColumns(value: boolean) {
44
        if (this.grid?.columns && this.expressions) {
10✔
45
            this.setColumnsVisibility(value);
10✔
46
        }
47

48
        this._hideGroupedColumns = value;
10✔
49
    }
50

51
    private _hideGroupedColumns = false;
12✔
52
    private groupingDiffer: IterableDiffer<IGroupingExpression>;
53
    private destroy$ = new Subject<any>();
12✔
54

55
    constructor(private differs: IterableDiffers, ref: ElementRef<HTMLElement>, platform: PlatformUtil) {
12✔
56
        super(ref, platform);
12✔
57
    }
58

59
    public ngAfterContentInit(): void {
60
        if (this.grid.columns && this.expressions) {
12✔
61
            this.groupingDiffer = this.differs.find(this.expressions).create();
12✔
62
            this.updateColumnsVisibility();
12✔
63
        }
64

65
        this.grid.sortingExpressionsChange.pipe(takeUntil(this.destroy$)).subscribe((sortingExpressions: ISortingExpression[]) => {
12✔
66
            if (!this.expressions || !this.expressions.length) {
×
67
                return;
×
68
            }
69

70
            let changed = false;
×
71

72
            sortingExpressions.forEach((sortExpr: ISortingExpression) => {
×
73
                const fieldName = sortExpr.fieldName;
×
74
                const groupingExpr = this.expressions.find(ex => ex.fieldName === fieldName);
×
75
                if (groupingExpr && groupingExpr.dir !== sortExpr.dir) {
×
76
                    groupingExpr.dir = sortExpr.dir;
×
77
                    changed = true;
×
78
                }
79
            });
80

81
            if (changed) {
×
82
                this.expressions = [...this.expressions];
×
83
            }
84
        });
85
    }
86

87
    public ngOnDestroy(): void {
88
        this.destroy$.next(true);
12✔
89
        this.destroy$.complete();
12✔
90
    }
91

92
    public handleReorder(event: IChipsAreaReorderEventArgs) {
93
        const { chipsArray, originalEvent } = event;
×
94
        const newExpressions = this.getReorderedExpressions(chipsArray);
×
95

96
        this.chipExpressions = newExpressions;
×
97

98
        // When reordered using keyboard navigation, we don't have `onMoveEnd` event.
99
        if (originalEvent instanceof KeyboardEvent) {
×
100
            this.expressions = newExpressions;
×
101
        }
102
    }
103

104
    public handleMoveEnd() {
105
        this.expressions = this.chipExpressions;
×
106
    }
107

108
    public groupBy(expression: IGroupingExpression) {
109
        this.expressions.push(expression);
×
110
        this.expressions = [...this.expressions];
×
111
    }
112

113
    public clearGrouping(name: string) {
114
        this.expressions = this.expressions.filter(item => item.fieldName !== name);
×
115
        this.grid.sortingExpressions = this.grid.sortingExpressions.filter(item => item.fieldName !== name);
×
116
        this.grid.notifyChanges(true);
×
117
    }
118

119
    protected override expressionsChanged() {
120
        this.updateColumnsVisibility();
11✔
121
    }
122

123
    private updateColumnsVisibility() {
124
        if (this.groupingDiffer && this.grid.columns && !this.grid.hasColumnLayouts) {
23✔
125
            const changes = this.groupingDiffer.diff(this.expressions);
15✔
126
            if (changes && this.grid.columns.length > 0) {
15✔
127
                changes.forEachAddedItem((rec) => {
3✔
128
                    const col = this.grid.getColumnByName(rec.item.fieldName);
1✔
129
                    col.hidden = this.hideGroupedColumns;
1✔
130
                });
131
                changes.forEachRemovedItem((rec) => {
3✔
132
                    const col = this.grid.getColumnByName(rec.item.fieldName);
2✔
133
                    col.hidden = false;
2✔
134
                });
135
            }
136
        }
137
    }
138

139
    private setColumnsVisibility(value) {
140
        if (this.grid.columns.length > 0 && !this.grid.hasColumnLayouts) {
10✔
141
            this.expressions.forEach((expr) => {
1✔
142
                const col = this.grid.getColumnByName(expr.fieldName);
2✔
143
                col.hidden = value;
2✔
144
            });
145
        }
146
    }
147
}
148

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