Skip to content
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

Add row number option to CCCS-Grid #181

Merged
merged 2 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,18 @@ config.controlPanelSections.push({
},
},
],
[
{
name: 'enable_row_numbers',
config: {
type: 'CheckboxControl',
label: t('Row numbers'),
renderTrigger: true,
default: true,
description: t('Whether to enable row numbers'),
},
},
],
[
{
name: 'page_length',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function transformProps(chartProps: CccsGridChartProps) {
include_search,
enable_grouping,
column_state,
enable_row_numbers,
}: CccsGridQueryFormData = { ...DEFAULT_FORM_DATA, ...formData };
const data = queriesData[0].data as TimeseriesDataRecord[];
const agGridLicenseKey = queriesData[0].agGridLicenseKey as String;
Expand Down Expand Up @@ -167,7 +168,7 @@ export default function transformProps(chartProps: CccsGridChartProps) {
COUNTRY: 'countryValueRenderer',
JSON: 'jsonValueRenderer',
};

const percentMetricValueFormatter = function (params: ValueFormatterParams) {
return getNumberFormatter(NumberFormats.PERCENT_3_POINT).format(
params.value,
Expand Down Expand Up @@ -271,6 +272,16 @@ export default function transformProps(chartProps: CccsGridChartProps) {
}
}

if (enable_row_numbers) {
columnDefs.splice(0, 0, {
headerName: '#',
colId: 'rowNum',
pinned: 'left',
valueGetter: (params: any) =>
params.node ? params.node.rowIndex + 1 : null,
} as any);
}

return {
formData,
setDataMask,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type CccsGridQueryFormData = QueryFormData & {
page_length: number;
enable_grouping: boolean;
column_state: ColumnState[];
enable_row_numbers: boolean;
};

export interface CccsGridStylesProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('CccsGrid buildQuery', () => {
enable_grouping: false,
viz_type: 'my_chart',
column_state: [],
enable_row_numbers: false,
reesercollins marked this conversation as resolved.
Show resolved Hide resolved
};

it('should build groupby with series in form data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('CccsGrid tranformProps', () => {
enable_grouping: false,
viz_type: 'my_chart',
column_state: [],
enable_row_numbers: false,
reesercollins marked this conversation as resolved.
Show resolved Hide resolved
};
const chartProps = new CccsGridChartProps({
formData,
Expand Down