Skip to content

Commit f97fe06

Browse files
committed
feat(pivot): Implement filters area dropdown
1 parent 5332957 commit f97fe06

File tree

7 files changed

+252
-71
lines changed

7 files changed

+252
-71
lines changed

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class IgxFilteringService implements OnDestroy {
3535

3636
private columnsWithComplexFilter = new Set<string>();
3737
private areEventsSubscribed = false;
38-
private destroy$ = new Subject<boolean>();
38+
protected destroy$ = new Subject<boolean>();
3939
private isFiltering = false;
4040
private columnToExpressionsMap = new Map<string, ExpressionUI[]>();
4141
private columnStartIndex = -1;
42-
private _filterMenuOverlaySettings: OverlaySettings = {
42+
protected _filterMenuOverlaySettings: OverlaySettings = {
4343
closeOnEscape: true,
4444
closeOnOutsideClick: true,
4545
modal: false,
@@ -50,11 +50,11 @@ export class IgxFilteringService implements OnDestroy {
5050
}),
5151
scrollStrategy: new AbsoluteScrollStrategy()
5252
};
53-
private lastActiveNode;
53+
protected lastActiveNode;
5454

5555
constructor(
5656
private iconService: IgxIconService,
57-
private _overlayService: IgxOverlayService,
57+
protected _overlayService: IgxOverlayService,
5858
) { }
5959

6060
public ngOnDestroy(): void {

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-filtering.service.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { Injectable } from '@angular/core';
2+
import { first, takeUntil } from 'rxjs/operators';
23
import { IFilteringOperation } from '../../data-operations/filtering-condition';
34
import { FilteringLogic } from '../../data-operations/filtering-expression.interface';
45
import { FilteringExpressionsTree, IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
6+
import { ColumnType } from '../common/grid.interface';
57
import { IgxFilteringService } from '../filtering/grid-filtering.service';
68
import { IgxPivotGridComponent } from './pivot-grid.component';
79
import { PivotUtil } from './pivot-util';
810

911
@Injectable()
1012
export class IgxPivotFilteringService extends IgxFilteringService {
13+
private filtersESFId;
14+
1115
public clearFilter(field: string): void {
1216
this.clear_filter(field);
1317
}
@@ -47,4 +51,44 @@ export class IgxPivotFilteringService extends IgxFilteringService {
4751
(grid as any).setupColumns();
4852
}
4953
}
54+
55+
public toggleFiltersESF(dropdown: any, element: HTMLElement, column: ColumnType, shouldReattach: boolean) {
56+
const filterIcon = column.filteringExpressionsTree ? 'igx-excel-filter__icon--filtered' : 'igx-excel-filter__icon';
57+
const filterIconTarget = element.querySelector(`.${filterIcon}`) as HTMLElement || element;
58+
59+
const { id, ref } = (this.grid as IgxPivotGridComponent).createFilterESF(dropdown, column, {
60+
...this._filterMenuOverlaySettings,
61+
...{ target: filterIconTarget }
62+
}, shouldReattach);
63+
64+
this.filtersESFId = id;
65+
66+
if (shouldReattach) {
67+
this._overlayService.opening
68+
.pipe(
69+
first(overlay => overlay.id === id),
70+
takeUntil(this.destroy$)
71+
)
72+
.subscribe(() => this.lastActiveNode = this.grid.navigation.activeNode);
73+
74+
this._overlayService.closed
75+
.pipe(
76+
first(overlay => overlay.id === id),
77+
takeUntil(this.destroy$)
78+
)
79+
.subscribe(() => {
80+
this._overlayService.detach(id);
81+
ref?.destroy();
82+
this.grid.navigation.activeNode = this.lastActiveNode;
83+
this.grid.theadRow.nativeElement.focus();
84+
});
85+
86+
this.grid.columnPinned.pipe(first()).subscribe(() => ref?.destroy());
87+
this._overlayService.show(id);
88+
}
89+
}
90+
91+
public hideESF() {
92+
this._overlayService.hide(this.filtersESFId);
93+
}
5094
}

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</ng-template>
4848
</ng-template>
4949
<ng-template #record_template let-rowIndex="index" let-rowData>
50-
<igx-pivot-row [pivotRowWidths]='pivotRowWidths' [gridID]="id" [index]="rowIndex" [data]="rowData"
50+
<igx-pivot-row [pivotRowWidths]='pivotRowWidths' [gridID]="id" [index]="rowIndex" [data]="rowData"
5151
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:pipeTrigger"
5252
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger" #row>
5353
</igx-pivot-row>

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { IgxGridBaseDirective } from '../grid-base.directive';
3030
import { IgxFilteringService } from '../filtering/grid-filtering.service';
3131
import { IgxGridSelectionService } from '../selection/selection.service';
3232
import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service';
33-
import { GridServiceType, GridType, IGX_GRID_BASE, IGX_GRID_SERVICE_BASE, RowType } from '../common/grid.interface';
33+
import { ColumnType, GridType, IGX_GRID_BASE, RowType } from '../common/grid.interface';
3434
import { IgxGridCRUDService } from '../common/crud.service';
3535
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
3636
import { DEFAULT_PIVOT_KEYS, IDimensionsChange, IPivotConfiguration, IPivotDimension, IPivotKeys, IValuesChange, PivotDimensionType } from './pivot-grid.interface';
@@ -117,8 +117,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
117117
@ViewChild(IgxPivotHeaderRowComponent, { static: true })
118118
public theadRow: IgxPivotHeaderRowComponent;
119119

120-
121-
122120
@Input()
123121
/**
124122
* Gets/Sets the pivot configuration with all related dimensions and values.
@@ -610,6 +608,20 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
610608
return;
611609
}
612610

611+
/** @hidden @internal */
612+
public createFilterESF(dropdown: any, column: ColumnType, options: OverlaySettings, shouldReatach: boolean) {
613+
options.outlet = this.outlet;
614+
if (dropdown) {
615+
dropdown.initialize(column, this.overlayService);
616+
if (shouldReatach) {
617+
const id = this.overlayService.attach(dropdown.element, options);
618+
dropdown.overlayComponentId = id;
619+
return { id, ref: undefined };
620+
}
621+
return {id: dropdown.overlayComponentId, ref: undefined};
622+
}
623+
}
624+
613625
/** @hidden */
614626
public featureColumnsWidth() {
615627
return this.pivotRowWidths;

0 commit comments

Comments
 (0)