mirror of
https://github.com/apache/superset.git
synced 2026-05-20 15:25:12 +00:00
Compare commits
1 Commits
embedded-e
...
msyavuz/fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
361b26f224 |
@@ -102,6 +102,7 @@ export interface AgGridTableProps {
|
||||
renderTimeComparisonDropdown: () => JSX.Element | null;
|
||||
cleanedTotals: DataRecord;
|
||||
showTotals: boolean;
|
||||
showRowGroupCounts: boolean;
|
||||
width: number;
|
||||
onColumnStateChange?: (state: AgGridChartStateWithMetadata) => void;
|
||||
onFilterChanged?: (filterModel: Record<string, any>) => void;
|
||||
@@ -142,6 +143,7 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
renderTimeComparisonDropdown,
|
||||
cleanedTotals,
|
||||
showTotals,
|
||||
showRowGroupCounts,
|
||||
width,
|
||||
onColumnStateChange,
|
||||
onFilterChanged,
|
||||
@@ -186,6 +188,15 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
[],
|
||||
);
|
||||
|
||||
const autoGroupColumnDef = useMemo<ColDef>(
|
||||
() => ({
|
||||
cellRendererParams: {
|
||||
suppressCount: !showRowGroupCounts,
|
||||
},
|
||||
}),
|
||||
[showRowGroupCounts],
|
||||
);
|
||||
|
||||
// Memoize container style
|
||||
const containerStyles = useMemo(
|
||||
() => ({
|
||||
@@ -510,6 +521,7 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
rowHeight={30}
|
||||
columnDefs={colDefsFromProps}
|
||||
defaultColDef={defaultColDef}
|
||||
autoGroupColumnDef={autoGroupColumnDef}
|
||||
onColumnGroupOpened={params => params.api.sizeColumnsToFit()}
|
||||
rowSelection="multiple"
|
||||
animateRows
|
||||
|
||||
@@ -80,6 +80,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
colorPositiveNegative,
|
||||
totals,
|
||||
showTotals,
|
||||
showRowGroupCounts,
|
||||
columnColorFormatters,
|
||||
basicColorFormatters,
|
||||
width,
|
||||
@@ -444,6 +445,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
}
|
||||
cleanedTotals={totals || {}}
|
||||
showTotals={showTotals}
|
||||
showRowGroupCounts={showRowGroupCounts}
|
||||
width={width}
|
||||
onColumnStateChange={handleColumnStateChange}
|
||||
chartState={chartState}
|
||||
|
||||
@@ -429,6 +429,22 @@ const config: ControlPanelConfig = {
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'show_row_group_counts',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Show row group counts'),
|
||||
renderTrigger: true,
|
||||
default: true,
|
||||
description: t(
|
||||
'Show the number of rows in each group next to the group label when row grouping is enabled.',
|
||||
),
|
||||
visibility: isAggMode,
|
||||
resetOnHide: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'show_totals',
|
||||
|
||||
@@ -504,6 +504,7 @@ const transformProps = (
|
||||
show_cell_bars: showCellBars = true,
|
||||
color_pn: colorPositiveNegative = true,
|
||||
show_totals: showTotals,
|
||||
show_row_group_counts: showRowGroupCounts = true,
|
||||
conditional_formatting: conditionalFormatting,
|
||||
comparison_color_enabled: comparisonColorEnabled = false,
|
||||
comparison_color_scheme: comparisonColorScheme = ColorSchemeEnum.Green,
|
||||
@@ -778,6 +779,7 @@ const transformProps = (
|
||||
colorPositiveNegative,
|
||||
totals,
|
||||
showTotals,
|
||||
showRowGroupCounts,
|
||||
columnColorFormatters,
|
||||
basicColorColumnFormatters,
|
||||
basicColorFormatters,
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface AgGridTableChartTransformedProps<
|
||||
colorPositiveNegative: boolean;
|
||||
totals: DataRecord | undefined;
|
||||
showTotals: boolean;
|
||||
showRowGroupCounts: boolean;
|
||||
columnColorFormatters: ColorFormatters;
|
||||
basicColorFormatters?: { [Key: string]: BasicColorFormatterType }[];
|
||||
basicColorColumnFormatters?: { [Key: string]: BasicColorFormatterType }[];
|
||||
|
||||
@@ -35,6 +35,22 @@ beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('transformProps defaults showRowGroupCounts to true', () => {
|
||||
expect(transformProps(testData.basic).showRowGroupCounts).toBe(true);
|
||||
});
|
||||
|
||||
test('transformProps respects show_row_group_counts=false', () => {
|
||||
expect(
|
||||
transformProps({
|
||||
...testData.basic,
|
||||
rawFormData: {
|
||||
...testData.basic.rawFormData,
|
||||
show_row_group_counts: false,
|
||||
},
|
||||
}).showRowGroupCounts,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test('transformProps parses pageLength to pageSize', () => {
|
||||
expect(transformProps(testData.basic).pageSize).toBe(20);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user