Skip to content

Commit 6579e31

Browse files
authored
Merge branch 'master' into simeonoff/fix-12622-15.1.x
2 parents f0ce419 + 5fd5c57 commit 6579e31

File tree

3 files changed

+63
-9
lines changed

3 files changed

+63
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 15.1.0
6+
7+
- `IgxPivotGrid`
8+
- The `IgxPivotDateDimension` properties `inBaseDimension` and `inOption` have been deprecated and renamed to `baseDimension` and `options` respectively.
9+
510
## 15.0.1
611

712
- `IgxGrid`

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

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
5353
*/
5454
public dataType?: GridColumnDataType;
5555

56-
/** Default options used for initialization. */
56+
/** Default options. */
5757
public defaultOptions = {
5858
total: true,
5959
years: true,
@@ -75,11 +75,57 @@ export class IgxPivotDateDimension implements IPivotDimension {
7575
return this._resourceStrings;
7676
}
7777

78+
/**
79+
* Gets/Sets the base dimension that is used by this class to determine the other dimensions and their values.
80+
* Having base dimension set is required in order for the Date Dimensions to show.
81+
*/
82+
public get baseDimension(): IPivotDimension {
83+
return this._baseDimension;
84+
}
85+
public set baseDimension(value: IPivotDimension) {
86+
this._baseDimension = value;
87+
this.initialize(this.baseDimension, this.options);
88+
}
89+
90+
/**
91+
* Gets/Sets the options for the predefined date dimensions whether to show quarter, years and etc.
92+
*/
93+
public get options(): IPivotDateDimensionOptions {
94+
return this._options;
95+
}
96+
public set options(value: IPivotDateDimensionOptions) {
97+
this._options = value;
98+
if (this.baseDimension) {
99+
this.initialize(this.baseDimension, this.options);
100+
}
101+
}
102+
103+
/**
104+
* @deprecated since version 15.1.x. Please use the new name `baseDimension` for future versions.
105+
*
106+
* Gets the base dimension that is used by this class to determine the other dimensions and their values.
107+
* Having base dimension set is required in order for the Date Dimensions to show.
108+
*/
109+
public get inBaseDimension(): IPivotDimension {
110+
return this._baseDimension;
111+
}
112+
113+
/**
114+
* @deprecated since version 15.1.x. Please use the new name `options` for future versions.
115+
*
116+
* Gets the options for the predefined date dimensions whether to show quarter, years and etc.
117+
*/
118+
public get inOptions(): IPivotDateDimensionOptions {
119+
return this._options;
120+
}
121+
78122
/** @hidden @internal */
79123
public childLevel?: IPivotDimension;
80124
/** @hidden @internal */
81125
public memberName = 'AllPeriods';
82126
private _resourceStrings = CurrentResourceStrings.GridResStrings;
127+
private _baseDimension: IPivotDimension;
128+
private _options: IPivotDateDimensionOptions = {};
83129
private _monthIntl = new Intl.DateTimeFormat('default', { month: 'long' });
84130

85131
/**
@@ -93,13 +139,16 @@ export class IgxPivotDateDimension implements IPivotDimension {
93139
* new IgxPivotDateDimension({ memberName: 'Date', enabled: true }, { total: false, months: false });
94140
* ```
95141
*/
96-
constructor(public inBaseDimension: IPivotDimension, public inOptions: IPivotDateDimensionOptions = {}) {
97-
const options = { ...this.defaultOptions, ...inOptions };
98-
99-
if (!inBaseDimension) {
100-
console.warn(`Please provide data child level to the pivot dimension.`);
101-
return;
142+
constructor(inBaseDimension: IPivotDimension, inOptions: IPivotDateDimensionOptions = {}) {
143+
this._baseDimension = inBaseDimension;
144+
this._options = inOptions;
145+
if (this.baseDimension && this.options) {
146+
this.initialize(this.baseDimension, this.options);
102147
}
148+
}
149+
150+
protected initialize(inBaseDimension, inOptions) {
151+
const options = { ...this.defaultOptions, ...inOptions };
103152

104153
this.dataType = GridColumnDataType.Date;
105154
inBaseDimension.dataType = GridColumnDataType.Date;

projects/igniteui-angular/src/lib/grids/state.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export class IgxGridStateDirective {
599599
* This method restores the IgxPivotDateDimension with its default functions and resource strings.
600600
*/
601601
private restoreDateDimension(dim: IgxPivotDateDimension) {
602-
const dateDim = new IgxPivotDateDimension((dim as any).inBaseDimension, (dim as any).inOptions);
602+
const dateDim = new IgxPivotDateDimension((dim as any)._baseDimension, (dim as any)._options);
603603
// restore functions and resource strings
604604
dim.resourceStrings = dateDim.resourceStrings;
605605
dim.memberFunction = dateDim.memberFunction;
@@ -616,7 +616,7 @@ export class IgxGridStateDirective {
616616
* Returns if this is a IgxPivotDateDimension.
617617
*/
618618
private isDateDimension(dim: IPivotDimension) {
619-
return (dim as any).inBaseDimension;
619+
return (dim as any)._baseDimension;
620620
}
621621

622622
/**

0 commit comments

Comments
 (0)