Skip to content

Commit 4e821be

Browse files
Merge branch 'master' into ganastasov/feat-14085-master
2 parents bcbc6aa + a14f577 commit 4e821be

File tree

9 files changed

+639
-22
lines changed

9 files changed

+639
-22
lines changed

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { CalendarDay } from "../common/model";
88
import { DateRangeDescriptor, DateRangeType } from "igniteui-webcomponents";
99
import { ScrollDirection } from "../calendar";
1010

11+
const TODAY = new Date(2024, 6, 12);
12+
1113
describe("Days View Component", () => {
1214
configureTestSuite();
1315
const baseClass = "igx-days-view";
@@ -71,10 +73,9 @@ describe("Days View Component", () => {
7173
});
7274

7375
it("should set activeDate to the first day of the current month when no value is provided", () => {
74-
const today = new Date();
7576
const firstMonthDay = new Date(
76-
today.getFullYear(),
77-
today.getMonth(),
77+
TODAY.getFullYear(),
78+
TODAY.getMonth(),
7879
1,
7980
);
8081
const fixture = TestBed.createComponent(InitDaysViewComponent);
@@ -115,12 +116,11 @@ describe("Days View Component", () => {
115116
let fixture: ComponentFixture<InitDaysViewComponent>;
116117
let el: HTMLElement;
117118
let instance: IgxDaysViewComponent;
118-
const today = new Date();
119119
const firstDay = CalendarDay.from(
120-
new Date(today.getFullYear(), today.getMonth(), 1),
120+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 1),
121121
);
122122
const lastDay = CalendarDay.from(
123-
new Date(today.getFullYear(), today.getMonth() + 1, 0),
123+
new Date(TODAY.getFullYear(), TODAY.getMonth() + 1, 0),
124124
);
125125

126126
beforeEach(waitForAsync(() => {
@@ -397,13 +397,13 @@ function getInactiveDays(fixture: ComponentFixture<InitDaysViewComponent>) {
397397
class InitDaysViewComponent {
398398
@ViewChild(IgxDaysViewComponent, { static: true })
399399
public instance: IgxDaysViewComponent;
400-
protected date = new Date();
400+
public date = TODAY;
401401
protected disabledDates: DateRangeDescriptor[] = [
402402
{
403403
type: DateRangeType.Specific,
404404
dateRange: [
405-
new Date(this.date.getFullYear(), this.date.getMonth(), 12),
406-
new Date(this.date.getFullYear(), this.date.getMonth(), 24),
405+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 12),
406+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 24),
407407
],
408408
},
409409
];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PivotUtil } from './pivot-util';
66
import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
77
import { IMultiRowLayoutNode } from '../public_api';
88
import { SortingDirection } from '../../data-operations/sorting-strategy';
9-
import { take, timeout } from 'rxjs';
9+
import { take, timeout } from 'rxjs/operators';
1010
import { IPivotDimension, IPivotGridRecord, PivotSummaryPosition } from './pivot-grid.interface';
1111

1212
@Injectable()

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

-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export interface IPivotDimensionStrategy {
5959
export type PivotAggregation = (members: any[], data: any[]) => any;
6060

6161
/* marshalByValue */
62-
/* jsonAPIComplexObject */
6362
/**
6463
* Interface describing a IPivotAggregator class.
6564
* Used for specifying custom aggregator lists.
@@ -85,7 +84,6 @@ export interface IPivotAggregator {
8584
}
8685

8786
/* marshalByValue */
88-
/* jsonAPIComplexObject */
8987
/**
9088
* Configuration of the pivot grid.
9189
*/
@@ -108,7 +106,6 @@ export interface IPivotConfiguration {
108106

109107
/* blazorElement */
110108
/* marshalByValue */
111-
/* jsonAPIComplexObject */
112109
/**
113110
* Configuration of a pivot dimension.
114111
*/
@@ -150,7 +147,6 @@ export interface IPivotDimension {
150147
}
151148

152149
/* marshalByValue */
153-
/* jsonAPIComplexObject */
154150
/**
155151
* Configuration of a pivot value aggregation.
156152
*/

projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts

+64-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
GridWithThreeLevelsOfMultiColumnHeadersAndTwoRowsExportComponent,
2121
GroupedGridWithSummariesComponent,
2222
GridCurrencySummariesComponent,
23-
GridUserMeetingDataComponent
23+
GridUserMeetingDataComponent,
24+
GridCustomSummaryComponent,
25+
GridCustomSummaryWithNullAndZeroComponent,
26+
GridCustomSummaryWithUndefinedZeroAndValidNumberComponent,
27+
GridCustomSummaryWithUndefinedAndNullComponent,
28+
GridCustomSummaryWithDateComponent
2429
} from '../../test-utils/grid-samples.spec';
2530
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
2631
import { first } from 'rxjs/operators';
@@ -75,7 +80,12 @@ describe('Excel Exporter', () => {
7580
IgxHierarchicalGridSummariesExportComponent,
7681
GroupedGridWithSummariesComponent,
7782
GridCurrencySummariesComponent,
78-
GridUserMeetingDataComponent
83+
GridUserMeetingDataComponent,
84+
GridCustomSummaryComponent,
85+
GridCustomSummaryWithNullAndZeroComponent,
86+
GridCustomSummaryWithUndefinedZeroAndValidNumberComponent,
87+
GridCustomSummaryWithUndefinedAndNullComponent,
88+
GridCustomSummaryWithDateComponent
7989
]
8090
}).compileComponents();
8191
}));
@@ -1355,6 +1365,58 @@ describe('Excel Exporter', () => {
13551365

13561366
await exportAndVerify(grid, options, actualData.exportHierarchicalGridWithSummaries);
13571367
});
1368+
1369+
it('should export grid with custom summaries, only with summary label as string', async () => {
1370+
fix = TestBed.createComponent(GridCustomSummaryComponent);
1371+
fix.detectChanges();
1372+
await wait(300);
1373+
1374+
grid = fix.componentInstance.grid;
1375+
1376+
await exportAndVerify(grid, options, actualData.exportGridWithCustomSummaryOnlyWithSummaryLabel);
1377+
});
1378+
1379+
it('should export grid with custom summaries, with null and zero (as number)', async () => {
1380+
fix = TestBed.createComponent(GridCustomSummaryWithNullAndZeroComponent);
1381+
fix.detectChanges();
1382+
await wait(300);
1383+
1384+
grid = fix.componentInstance.grid;
1385+
1386+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithNullAndZero);
1387+
});
1388+
1389+
it('should export grid with custom summaries, with undefined, zero and positive number (as number)', async () => {
1390+
fix = TestBed.createComponent(GridCustomSummaryWithUndefinedZeroAndValidNumberComponent);
1391+
fix.detectChanges();
1392+
await wait(300);
1393+
1394+
grid = fix.componentInstance.grid;
1395+
1396+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithUndefinedZeroAndValidNumber);
1397+
});
1398+
1399+
it('should export grid with custom summaries, with undefined and null', async () => {
1400+
fix = TestBed.createComponent(GridCustomSummaryWithUndefinedAndNullComponent);
1401+
fix.detectChanges();
1402+
await wait(300);
1403+
1404+
grid = fix.componentInstance.grid;
1405+
1406+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithUndefinedAndNull);
1407+
});
1408+
1409+
it('should export grid with custom summaries, with date', async () => {
1410+
fix = TestBed.createComponent(GridCustomSummaryWithDateComponent);
1411+
fix.detectChanges();
1412+
await wait(300);
1413+
1414+
grid = fix.componentInstance.grid;
1415+
1416+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithDate);
1417+
});
1418+
1419+
13581420
});
13591421

13601422
describe('', () => {

projects/igniteui-angular/src/lib/services/excel/excel-files.ts

+29-4
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,34 @@ export class WorksheetFile implements IExcelFile {
457457
summaryFunc = this.getSummaryFunction(cellValue.label, key, dimensionMapKey, level, targetCol);
458458

459459
if (!summaryFunc) {
460-
const cellStr = `${cellValue.label}: ${cellValue.value}`;
461-
const savedValue = dictionary.saveValue(cellStr, false);
462-
return `<c r="${columnName}" t="s" s="1"><v>${savedValue}</v></c>`;
460+
let summaryValue;
461+
462+
const label = cellValue.label?.toString();
463+
const value = cellValue.value?.toString();
464+
465+
if (label && value) {
466+
summaryValue = `${cellValue.label}: ${cellValue.value}`;
467+
} else if (label) {
468+
summaryValue = cellValue.label;
469+
} else if (value) {
470+
summaryValue = cellValue.value;
471+
}
472+
473+
const savedValue = dictionary.saveValue(summaryValue, false);
474+
const isSavedAsString = savedValue !== -1;
475+
const isSavedAsDate = !isSavedAsString && summaryValue instanceof Date;
476+
477+
if (isSavedAsDate) {
478+
const timeZoneOffset = summaryValue.getTimezoneOffset() * 60000;
479+
const isoString = (new Date(summaryValue - timeZoneOffset)).toISOString();
480+
summaryValue = isoString.substring(0, isoString.indexOf('.'));
481+
}
482+
483+
const resolvedValue = isSavedAsString ? savedValue : summaryValue;
484+
const type = isSavedAsString ? `t="s"` : isSavedAsDate ? `t="d"` : '';
485+
const style = isSavedAsDate ? `s="2"` : `s="1"`;
486+
487+
return `<c r="${columnName}" ${type} ${style}><v>${resolvedValue}</v></c>`;
463488
}
464489

465490
return `<c r="${columnName}"><f t="array" ref="${columnName}">${summaryFunc}</f></c>`;
@@ -536,7 +561,7 @@ export class WorksheetFile implements IExcelFile {
536561
let result = '';
537562
const currencyInfo = this.currencyStyleMap.get(col.currencyCode);
538563

539-
switch(type.toLowerCase()) {
564+
switch(type?.toString().toLowerCase()) {
540565
case "count":
541566
return `"Count: "&amp;_xlfn.COUNTIF(${levelDimensions.startCoordinate}:${levelDimensions.endCoordinate}, ${recordLevel})`
542567
case "min":

0 commit comments

Comments
 (0)