Skip to content

Commit aceb2b7

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Apply review comments.
1 parent 0b84427 commit aceb2b7

File tree

3 files changed

+147
-13
lines changed

3 files changed

+147
-13
lines changed

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

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,55 @@ import { FilteringExpressionsTree } from '../../data-operations/filtering-expres
33
import { SortingDirection } from '../../data-operations/sorting-strategy';
44
import { ColumnType } from '../common/grid.interface';
55

6+
7+
/**
8+
* Default pivot keys used for data processing in the pivot pipes.
9+
*/
610
export const DEFAULT_PIVOT_KEYS = {
711
aggregations: 'aggregations', records: 'records', children: 'children', level: 'level',
812
rowDimensionSeparator: '_', columnDimensionSeparator: '-'
913
};
1014

15+
16+
/**
17+
* Event emitted when dimension collection for rows, columns of filters is changed.
18+
*/
1119
export interface IDimensionsChange {
20+
/** The new list of dimensions. */
1221
dimensions: IPivotDimension[],
22+
/** The dimension list type - Row, Column or Filter. */
1323
dimensionCollectionType: PivotDimensionType
1424
}
1525

26+
/**
27+
* Event emitted when values list is changed.
28+
*/
1629
export interface IValuesChange {
30+
/** The new list of values. */
1731
values: IPivotValue[]
1832
}
1933

34+
/**
35+
* Interface describing Pivot data processing for dimensions.
36+
* Should contain a process method and return records hierarchy based on the provided dimensions.
37+
*/
2038
export interface IPivotDimensionStrategy {
2139
process(collection: any,
2240
dimensions: IPivotDimension[],
2341
values: IPivotValue[],
2442
pivotKeys?: IPivotKeys): any[];
2543
}
2644

45+
/**
46+
* Interface describing a PivotAggregation function.
47+
* Accepts an array of extracted data members and a array of the original data records.
48+
*/
2749
export type PivotAggregation = (members: any[], data: any[]) => any;
2850

51+
/**
52+
* Interface describing a IPivotAggregator class.
53+
* Used for specifying custom aggregator lists.
54+
*/
2955
export interface IPivotAggregator {
3056
/** Aggregation unique key. */
3157
key: string;
@@ -38,7 +64,7 @@ export interface IPivotAggregator {
3864
aggregator: (members: any[], data?: any[]) => any;
3965
}
4066

41-
/**
67+
/**
4268
* Configuration of the pivot grid.
4369
*/
4470
export interface IPivotConfiguration {
@@ -54,9 +80,13 @@ export interface IPivotConfiguration {
5480
values: IPivotValue[] | null;
5581
/** Dimensions to be displayed in the filter area. */
5682
filters?: IPivotDimension[] | null;
83+
/** Pivot data keys used for data generation. Can be used for custom remote scenarios where the data is pre-populated. */
5784
pivotKeys?: IPivotKeys;
5885
}
5986

87+
/**
88+
* Configuration of a pivot dimension.
89+
*/
6090
export interface IPivotDimension {
6191
/** Allows defining a hierarchy when multiple sub groups need to be extracted from single member. */
6292
childLevel?: IPivotDimension;
@@ -70,15 +100,24 @@ export interface IPivotDimension {
70100
* A predefined or defined via the `igxPivotSelector` filter expression tree for the current dimension to be applied in the filter pipe.
71101
* */
72102
filter?: FilteringExpressionsTree | null;
103+
/**
104+
* The sorting direction of the current dimension. Determines the order in which the values will appear in the related dimension.
105+
*/
73106
sortDirection?: SortingDirection;
107+
/**
108+
* The dataType of the related data field.
109+
*/
74110
dataType?: GridColumnDataType;
75-
// The width of the dimension cells to be rendered.Can be pixel or %.
76-
width? : string;
111+
/** The width of the dimension cells to be rendered.Can be pixel or %. */
112+
width?: string;
77113
}
78-
114+
/**
115+
* Configuration of a pivot value aggregation.
116+
*/
79117
export interface IPivotValue {
118+
/** Field name to use in order to extract value. */
80119
member: string;
81-
// display name if present shows instead of member for the column header of this value
120+
/** Display name to show instead of member for the column header of this value. **/
82121
displayName?: string;
83122
/**
84123
* Active aggregator definition with key, label and aggregator.
@@ -88,34 +127,51 @@ export interface IPivotValue {
88127
* List of aggregates to show in aggregate drop-down.
89128
*/
90129
aggregateList?: IPivotAggregator[];
91-
// Enables/Disables a particular value from pivot aggregation.
130+
/** Enables/Disables a particular value from pivot aggregation. */
92131
enabled: boolean;
93-
// Allow conditionally styling of the IgxPivotGrid cells
132+
/** Allow conditionally styling of the IgxPivotGrid cells. */
94133
styles?: any;
95-
// Enables a data type specific template of the cells
134+
/** Enables a data type specific template of the cells */
96135
dataType?: GridColumnDataType;
97-
// Applies display format to cell values.
136+
/** Applies display format to cell values. */
98137
formatter?: (value: any, rowData?: any) => any;
99138
}
100139

140+
/** Interface describing the Pivot data keys used for data generation.
141+
* Can be used for custom remote scenarios where the data is pre-populated.
142+
*/
101143
export interface IPivotKeys {
144+
/** Field that stores children for hierarchy building. */
102145
children: string;
146+
/** Field that stores reference to the original data records. */
103147
records: string;
148+
/** Field that stores aggregation values. */
104149
aggregations: string;
150+
/** Field that stores dimension level based on its hierarchy. */
105151
level: string;
152+
/** Separator used when generating the unique column field values. */
106153
columnDimensionSeparator: string;
154+
/** Separator used when generating the unique row field values. */
107155
rowDimensionSeparator: string;
108156
}
109157

158+
/** The dimension types - Row, Column or Filter. */
110159
export enum PivotDimensionType {
111160
Row,
112161
Column,
113162
Filter
114163
}
115164

165+
/** Interface describing the pivot dimension data.
166+
* Contains additional information needed to render dimension headers.
167+
*/
116168
export interface IPivotDimensionData {
169+
/** Associated column definition. */
117170
column: ColumnType;
171+
/** Associated dimension definition. */
118172
dimension: IPivotDimension;
173+
/** List of previous dimension groups. */
119174
prevDimensions: IPivotDimension[];
175+
/** Whether this a child dimension. */
120176
isChild?: boolean;
121177
}

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6161
super(ref, cdr);
6262
}
6363

64+
/**
65+
* @hidden
66+
* @internal
67+
*/
6468
@ViewChildren('notifyChip')
6569
public notificationChips: QueryList<IgxChipComponent>;
6670

71+
/**
72+
* @hidden
73+
* @internal
74+
*/
6775
public onDimDragStart(event, area) {
6876
this.cdr.detectChanges();
6977
for (let chip of this.notificationChips) {
@@ -76,17 +84,29 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
7684
}
7785
}
7886

87+
/**
88+
* @hidden
89+
* @internal
90+
*/
7991
public onDimDragEnd() {
8092
for (let chip of this.notificationChips) {
8193
chip.nativeElement.hidden = true;
8294
}
8395
}
8496

97+
/**
98+
* @hidden
99+
* @internal
100+
*/
85101
public getAreaHeight(area: IgxChipsAreaComponent) {
86102
const chips = area.chipsList;
87103
return chips && chips.length > 0 ? chips.first.nativeElement.clientHeight : 0;
88104
}
89105

106+
/**
107+
* @hidden
108+
* @internal
109+
*/
90110
public getAggregateList(val: IPivotValue): IPivotAggregator[] {
91111
if (!val.aggregateList) {
92112
let defaultAggr = this.getAggregatorsForValue(val);
@@ -106,6 +126,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
106126
return val.aggregateList;
107127
}
108128

129+
/**
130+
* @hidden
131+
* @internal
132+
*/
109133
public rowRemoved(event: IBaseChipEventArgs) {
110134
const row = this.grid.pivotConfiguration.rows.find(x => x.memberName === event.owner.id);
111135
row.enabled = false;
@@ -114,6 +138,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
114138
this.grid.dimensionsChange.emit({ dimensions: this.grid.pivotConfiguration.rows, dimensionCollectionType: PivotDimensionType.Row });
115139
}
116140

141+
/**
142+
* @hidden
143+
* @internal
144+
*/
117145
public columnRemoved(event: IBaseChipEventArgs) {
118146
const col = this.grid.pivotConfiguration.columns.find(x => x.memberName === event.owner.id);
119147
col.enabled = false;
@@ -124,6 +152,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
124152
this.grid.reflow();
125153
}
126154

155+
/**
156+
* @hidden
157+
* @internal
158+
*/
127159
public valueRemoved(event: IBaseChipEventArgs) {
128160
const value = this.grid.pivotConfiguration.values.find(x => x.member === event.owner.id || x.displayName === event.owner.id);
129161
value.enabled = false;
@@ -132,6 +164,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
132164
this.grid.valuesChange.emit({ values: this.grid.pivotConfiguration.values });
133165
}
134166

167+
/**
168+
* @hidden
169+
* @internal
170+
*/
135171
public filterRemoved(event: IBaseChipEventArgs) {
136172
const filter = this.grid.pivotConfiguration.filters.find(x => x.memberName === event.owner.id);
137173
filter.enabled = false;
@@ -140,11 +176,19 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
140176
this.grid.dimensionsChange.emit({ dimensions: this.grid.pivotConfiguration.filters, dimensionCollectionType: PivotDimensionType.Filter });
141177
}
142178

179+
/**
180+
* @hidden
181+
* @internal
182+
*/
143183
public onFilteringIconPointerDown(event) {
144184
event.stopPropagation();
145185
event.preventDefault();
146186
}
147187

188+
/**
189+
* @hidden
190+
* @internal
191+
*/
148192
public onFilteringIconClick(event, dimension) {
149193
event.stopPropagation();
150194
event.preventDefault();
@@ -161,6 +205,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
161205
this.grid.filteringService.toggleFilterDropdown(event.target, col);
162206
}
163207

208+
/**
209+
* @hidden
210+
* @internal
211+
*/
164212
public onSummaryClick(eventArgs, value: IPivotValue, dropdown: IgxDropDownComponent, chip: IgxChipComponent) {
165213
this._subMenuOverlaySettings.target = eventArgs.currentTarget;
166214
if (dropdown.collapsed) {
@@ -174,17 +222,29 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
174222
}
175223
}
176224

225+
/**
226+
* @hidden
227+
* @internal
228+
*/
177229
public onAggregationChange(event: ISelectionEventArgs) {
178230
if (!this.isSelected(event.newSelection.value)) {
179231
this.value.aggregate = event.newSelection.value;
180232
this.grid.pipeTrigger++;
181233
}
182234
}
183235

236+
/**
237+
* @hidden
238+
* @internal
239+
*/
184240
public isSelected(val: IPivotAggregator) {
185241
return this.value.aggregate.key === val.key;
186242
}
187243

244+
/**
245+
* @hidden
246+
* @internal
247+
*/
188248
public onChipSort(event, dimension: IPivotDimension, dimensionType: PivotDimensionType) {
189249
if (!dimension.sortDirection) {
190250
dimension.sortDirection = SortingDirection.None;
@@ -203,6 +263,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
203263
}
204264
}
205265

266+
/**
267+
* @hidden
268+
* @internal
269+
*/
206270
public onDimDragOver(event, dimension?: PivotDimensionType) {
207271
const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id
208272
|| x.displayName === event.dragChip.id) :
@@ -226,12 +290,20 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
226290
}
227291
}
228292

293+
/**
294+
* @hidden
295+
* @internal
296+
*/
229297
public onDimDragLeave(event) {
230298
event.owner.nativeElement.previousElementSibling.style.visibility = 'hidden';
231299
event.owner.nativeElement.nextElementSibling.style.visibility = 'hidden';
232300
this._dropPos = DropPosition.AfterDropTarget;
233301
}
234302

303+
/**
304+
* @hidden
305+
* @internal
306+
*/
235307
public onAreaDragLeave(event, area) {
236308
const dataChips = area.chipsList.toArray().filter(x => this.notificationChips.toArray().indexOf(x) === -1);
237309
dataChips.forEach(element => {
@@ -242,6 +314,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
242314
});
243315
}
244316

317+
/**
318+
* @hidden
319+
* @internal
320+
*/
245321
public onValueDrop(event, area) {
246322
//values can only be reordered
247323
const currentDim = this.grid.pivotConfiguration.values;
@@ -259,6 +335,10 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
259335
}
260336
}
261337

338+
/**
339+
* @hidden
340+
* @internal
341+
*/
262342
public onDimDrop(event, area, dimension: PivotDimensionType) {
263343
const dragId = event.dragChip?.id || event.dragData?.chip.id;
264344
const currentDim = this.getDimensionsByType(dimension);

projects/igniteui-angular/src/lib/grids/watch-changes.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,15 @@ export function notifyChanges(repaint = false) {
8282
if (originalSetter) {
8383
originalSetter.call(this, newValue);
8484
if (this.grid) {
85-
const shouldRepaint = this.grid.isPivot ? false : repaint;
86-
this.grid.notifyChanges(shouldRepaint);
85+
this.grid.notifyChanges(repaint && !this.grid.isPivot);
8786
}
8887
} else {
8988
if (newValue === this[key]) {
9089
return;
9190
}
9291
this[privateKey] = newValue;
9392
if (this.grid) {
94-
const shouldRepaint = this.grid.isPivot ? false : repaint;
95-
this.grid.notifyChanges(shouldRepaint);
93+
this.grid.notifyChanges(repaint && !this.grid.isPivot);
9694
}
9795
}
9896
};

0 commit comments

Comments
 (0)