Skip to content

Commit

Permalink
refactor: 小计/总计配置重构
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Oct 19, 2023
1 parent b2d6f1f commit 131ead6
Show file tree
Hide file tree
Showing 38 changed files with 224 additions and 218 deletions.
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/bugs/issue-1668-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const s2Options: S2Options = {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['province'],
},
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['type'],
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/bugs/issue-1715-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const s2Options: S2Options = {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
},
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/bugs/issue-2164-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const s2Options: S2Options = {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseGrandTotalsLayout: true,
},
},
};
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/bugs/issue-368-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const s2Options = {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['row0', 'row1'],
},
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['col0', 'col1'],
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-372-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const s2Options: S2Options = {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['col0', 'col1'],
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-836-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const s2Options: S2Options = {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['col0', 'col1'],
},
},
Expand Down
16 changes: 8 additions & 8 deletions packages/s2-core/__tests__/spreadsheet/hidden-columns-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@ describe('SpreadSheet Hidden Columns Tests', () => {
col: {
showGrandTotals: true,
showSubTotals: false,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['type'],
},
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['province'],
},
},
Expand Down Expand Up @@ -465,15 +465,15 @@ describe('SpreadSheet Hidden Columns Tests', () => {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['type'],
},
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['province'],
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/spreadsheet/row-link-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const s2Options: S2Options = {
row: {
showSubTotals: true,
subTotalsDimensions: ['province'],
reverseSubLayout: true,
reverseSubTotalsLayout: true,
},
},
interaction: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ describe('Facet Layout API Tests', () => {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
},
},
},
Expand Down Expand Up @@ -851,8 +851,8 @@ describe('Facet Layout API Tests', () => {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/spreadsheet/theme-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ describe('SpreadSheet Theme Tests', () => {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: false,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: false,
},
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: false,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: false,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('Pivot Dataset Total Test', () => {
totals: {
row: {
...TOTALS_OPTIONS?.row,
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand All @@ -249,7 +249,7 @@ describe('Pivot Dataset Total Test', () => {
},
col: {
...TOTALS_OPTIONS?.col,
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand Down Expand Up @@ -359,7 +359,7 @@ describe('Pivot Dataset Total Test', () => {
showGrandTotals: true,
showSubTotals: true,
subTotalsDimensions: ['city'],
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand All @@ -370,7 +370,7 @@ describe('Pivot Dataset Total Test', () => {
showGrandTotals: true,
showSubTotals: true,
subTotalsDimensions: ['type'],
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand Down Expand Up @@ -447,7 +447,7 @@ describe('Pivot Dataset Total Test', () => {
totals: {
row: {
...TOTALS_OPTIONS?.row,
calcTotals: {
calcGrandTotals: {
calcFunc: calcFunc1,
},
calcSubTotals: {
Expand All @@ -456,7 +456,7 @@ describe('Pivot Dataset Total Test', () => {
},
col: {
...TOTALS_OPTIONS?.col,
calcTotals: {
calcGrandTotals: {
calcFunc: calcFunc2,
},
calcSubTotals: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ describe('Data Set Operate Test', () => {
beforeEach(() => {
totalsOptions = {
row: {
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
calcFunc: () => 'rowSubTotals',
},
},
col: {
calcTotals: {
calcGrandTotals: {
calcFunc: () => 'colTotals',
},
calcSubTotals: {
Expand Down
12 changes: 6 additions & 6 deletions packages/s2-core/__tests__/unit/utils/export/copy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ describe('Pivot Table Core Data Process', () => {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['province'],
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand All @@ -599,10 +599,10 @@ describe('Pivot Table Core Data Process', () => {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['type'],
calcTotals: {
calcGrandTotals: {
aggregation: Aggregation.SUM,
},
calcSubTotals: {
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/unit/utils/sort-action-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ describe('GetSortByMeasureValues Total Fallback Tests', () => {
calcSubTotals: {
aggregation: 'SUM',
},
calcTotals: {
calcGrandTotals: {
aggregation: 'SUM',
},
},
col: {
showSubTotals: true,
showGrandTotals: true,
subTotalsDimensions: ['type'],
calcTotals: {
calcGrandTotals: {
aggregation: 'SUM',
},
calcSubTotals: {
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,16 @@ describe('Tooltip Utils Tests', () => {
const rowTotalOptions: Total = {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: false,
reverseSubLayout: false,
reverseGrandTotalsLayout: false,
reverseSubTotalsLayout: false,
subTotalsDimensions: ['province'],
};

const colTotalOptions: Total = {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
subTotalsDimensions: ['type'],
};

Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/src/common/constant/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ export const getDefaultSeriesNumberText = (defaultText?: string) =>
defaultText ?? i18n('序号');

export const getDefaultCornerText = () => i18n('指标');

// 省略号
export const ELLIPSIS_SYMBOL = '...';
6 changes: 3 additions & 3 deletions packages/s2-core/src/common/constant/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const SPLIT_LINE_WIDTH = 1;

export const DEFAULT_TREE_ROW_WIDTH = 120;

export const DEFAULT_STYLE: Readonly<S2Style> = {
export const DEFAULT_STYLE: S2Style = {
layoutWidthType: LayoutWidthTypes.Adaptive,
dataCell: {
width: 96,
Expand All @@ -38,7 +38,7 @@ export const DEFAULT_STYLE: Readonly<S2Style> = {
},
};

export const DEFAULT_OPTIONS: Readonly<S2Options> = {
export const DEFAULT_OPTIONS: S2Options = {
width: 600,
height: 480,
debug: false,
Expand Down Expand Up @@ -108,7 +108,7 @@ export const DEFAULT_OPTIONS: Readonly<S2Options> = {

const mobileWidth = document.documentElement.clientWidth;

export const DEFAULT_MOBILE_OPTIONS: Readonly<S2Options> = {
export const DEFAULT_MOBILE_OPTIONS: S2Options = {
width: mobileWidth - 40,
height: 380,
style: {
Expand Down
Loading

0 comments on commit 131ead6

Please sign in to comment.