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

Pivot inline sort #1557

Merged
merged 15 commits into from
Sep 20, 2024
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
1 change: 1 addition & 0 deletions src/i18n-keysets/wizard/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"label_percent": "Percentage",
"label_pink-gray-green": "Lilac-Gray-Green",
"label_pivot-fallback": "Old pivot tables",
"label_pivot-inline-sort": "Sort by lines",
"label_pivot-measure-sort": "Sorting by indicator affects only the query to the source, but not the pivot table.",
"label_pivot-table-title-dialog-column-settings": "Column and row settings",
"label_pixels-shortname": "px",
Expand Down
1 change: 1 addition & 0 deletions src/i18n-keysets/wizard/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"label_percent": "В процентах",
"label_pink-gray-green": "Сиреневый-Серый-Салатовый",
"label_pivot-fallback": "Cтарые сводные таблицы",
"label_pivot-inline-sort": "Сортировка по строкам",
"label_pivot-measure-sort": "Сортировка по показателю влияет только на запрос в источник, но не на сводную таблицу.",
"label_pivot-table-title-dialog-column-settings": "Настройка столбцов и строк",
"label_pixels-shortname": "px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ const backendPivotTablePreparer = (args: PrepareFunctionArgs): BackendPivotTable
});

const isPaginatorEnabled = args.shared.extraSettings?.pagination === 'on';
const isInlineSortEnabled = !(args.shared.extraSettings?.pivotInlineSort === 'off');

const pivotTotals = getPivotTableSubTotals({rowsFields, columnsFields});
const sortSettings: PivotTableSortSettings = {
isSortByRowAllowed: isSortByRoleAllowed(pivotStructure, pivotTotals, 'pivot_row'),
isSortByRowAllowed:
isSortByRoleAllowed(pivotStructure, pivotTotals, 'pivot_row') && isInlineSortEnabled,
isSortByColumnAllowed: isSortByRoleAllowed(pivotStructure, pivotTotals, 'pivot_column'),
...backendSortMeta,
};
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/config/wizard/v11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface V11CommonSharedExtraSettings {
navigatorSeriesName?: string;
totals?: 'on' | 'off';
pivotFallback?: 'on' | 'off';
pivotInlineSort?: 'on' | 'off';
overlap?: 'on' | 'off';
feed?: string;
navigatorSettings?: V11NavigatorSettings;
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/wizard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface CommonSharedExtraSettings {
tooltipSum?: 'on' | 'off';
limit?: number;
pagination?: 'on' | 'off';
pivotInlineSort?: 'on' | 'off';
// For old charts, navigatorMode was specified in the body of extraSettings
navigatorMode?: string;
navigatorSeriesName?: string;
Expand Down
4 changes: 4 additions & 0 deletions src/ui/constants/visualizations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ export const CHART_SETTINGS = {
ON: 'on',
OFF: 'off',
},
PIVOT_INLINE_SORT: {
ON: 'on',
OFF: 'off',
},
};

export const VISUALIZATION_IDS = {
Expand Down
32 changes: 31 additions & 1 deletion src/ui/units/wizard/components/Dialogs/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const BASE_SETTINGS_KEYS: SettingsKeys[] = [
'feed',
'pivotFallback',
'navigatorSettings',
'pivotInlineSort',
];

const QL_SETTINGS_KEYS: SettingsKeys[] = [...BASE_SETTINGS_KEYS, 'qlAutoExecuteChart'];
Expand Down Expand Up @@ -162,6 +163,8 @@ interface State {
navigatorSeries: string[];
d3Fallback: string;
qlAutoExecuteChart?: string;
isPivotTable: boolean;
pivotInlineSort: string;
}

export const DIALOG_CHART_SETTINGS = Symbol('DIALOG_CHART_SETTINGS');
Expand Down Expand Up @@ -208,6 +211,7 @@ class DialogSettings extends React.PureComponent<InnerProps, State> {
feed = '',
pivotFallback = 'off',
qlAutoExecuteChart,
pivotInlineSort = CHART_SETTINGS.PIVOT_INLINE_SORT.ON,
} = extraSettings;

const navigatorSettings = this.prepareNavigatorSettings(visualization, extraSettings);
Expand Down Expand Up @@ -249,7 +253,8 @@ class DialogSettings extends React.PureComponent<InnerProps, State> {

this.state = {
valid: true,

isPivotTable,
pivotInlineSort,
titleMode,
indicatorTitleMode,
qlAutoExecuteChart: getQlAutoExecuteChartValue(qlAutoExecuteChart, props.chartType),
Expand Down Expand Up @@ -481,6 +486,12 @@ class DialogSettings extends React.PureComponent<InnerProps, State> {
});
};

handlePivotInlineSortUpdate = (value: string) => {
this.setState({
pivotInlineSort: value,
});
};

getXPlaceholderItemDataType() {
const {visualization} = this.props;
const placeholders = visualization.placeholders || [];
Expand Down Expand Up @@ -863,6 +874,24 @@ class DialogSettings extends React.PureComponent<InnerProps, State> {
);
}

renderInlineSortSwitch() {
const {isPivotTable, pivotInlineSort, pivotFallback} = this.state;

if (!isPivotTable || pivotFallback === 'on') {
return null;
}

return (
<SettingSwitcher
currentValue={pivotInlineSort}
checkedValue={CHART_SETTINGS.PIVOT_INLINE_SORT.ON}
uncheckedValue={CHART_SETTINGS.PIVOT_INLINE_SORT.OFF}
onChange={this.handlePivotInlineSortUpdate}
title={i18n('wizard', 'label_pivot-inline-sort')}
/>
);
}

renderModalBody() {
const {navigatorSettings} = this.state;
const {isPreviewLoading} = this.props;
Expand All @@ -887,6 +916,7 @@ class DialogSettings extends React.PureComponent<InnerProps, State> {
{this.renderNavigator()}
{this.renderD3Switch()}
{this.renderQlAutoExecutionChart()}
{this.renderInlineSortSwitch()}
</div>
);
}
Expand Down
Loading