-
Notifications
You must be signed in to change notification settings - Fork 160
fix(pivot-grid): fix date format based on the localization #17256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 21.2.x
Are you sure you want to change the base?
Changes from all commits
f054eb5
e86ce0f
b2b689e
440d496
bf31407
039f036
7595db4
179942e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,30 @@ describe('IgxPivotGrid #pivotGrid', () => { | |
| expect(actualDataTypeValue).toEqual('$71.89'); | ||
| }); | ||
|
|
||
| it('should provide context to dimension header formatter', () => { | ||
| const pivotGrid = fixture.componentInstance.pivotGrid; | ||
| const rowDimension = pivotGrid.pivotConfiguration.rows[0]; | ||
| const headerFormatter = jasmine.createSpy('headerFormatter') | ||
| .and.callFake((value, dimension, rowData) => { | ||
| expect(dimension).toEqual(jasmine.objectContaining({ memberName: rowDimension.memberName })); | ||
| expect(rowData).toBeDefined(); | ||
| return `formatted-${value}`; | ||
| }); | ||
| rowDimension.headerFormatter = headerFormatter; | ||
|
|
||
| pivotGrid.pipeTrigger++; | ||
| pivotGrid.setupColumns(); | ||
| fixture.detectChanges(); | ||
|
|
||
| const rowHeaders = fixture.debugElement.queryAll(By.directive(IgxPivotRowDimensionHeaderComponent)); | ||
| expect(rowHeaders[0].componentInstance.column.header).toBe('formatted-All'); | ||
|
|
||
| const [rawValue, dimension, rowData] = headerFormatter.calls.mostRecent().args; | ||
| expect(rawValue).toBe('All'); | ||
| expect(dimension).toEqual(jasmine.objectContaining({ memberName: rowDimension.memberName })); | ||
| expect(rowData.dimensionValues).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should apply css class to cells from measures', () => { | ||
| fixture.detectChanges(); | ||
| const pivotGrid = fixture.componentInstance.pivotGrid; | ||
|
|
@@ -1245,7 +1269,8 @@ describe('IgxPivotGrid #pivotGrid', () => { | |
| // check rows | ||
| const rows = pivotGrid.rowList.toArray(); | ||
| expect(rows.length).toBe(5); | ||
| const expectedHeaders = ['All Periods', '2021', 'Q4', 'December', '12/08/2021']; | ||
| const formattedDate = Intl.DateTimeFormat(undefined, { dateStyle: 'short' }).format(new Date(2021, 11, 8)); | ||
| const expectedHeaders = ['All Periods', '2021', 'Q4', 'December', formattedDate]; | ||
|
Comment on lines
+1272
to
+1273
|
||
| const rowHeaders = fixture.debugElement.queryAll( | ||
| By.directive(IgxPivotRowDimensionHeaderComponent)); | ||
| const rowDimensionHeaders = rowHeaders.map(x => x.componentInstance.column.header); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New branching behavior is introduced for
options.fullDatebased on whetherinBaseDimension.memberFunctionis provided. The updated spec covers locale formatting, but it doesn’t appear to cover thememberFunctionbranch (ensuring no formatter is attached/used). Add a unit test that setsfullDate: truewith a custommemberFunctionand asserts header rendering behaves as intended for that path.