diff --git a/src/i18n-keysets/wizard/en.json b/src/i18n-keysets/wizard/en.json index 6851d9faad..70b3c2536e 100644 --- a/src/i18n-keysets/wizard/en.json +++ b/src/i18n-keysets/wizard/en.json @@ -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", diff --git a/src/i18n-keysets/wizard/ru.json b/src/i18n-keysets/wizard/ru.json index e69795b40d..3595f72e18 100644 --- a/src/i18n-keysets/wizard/ru.json +++ b/src/i18n-keysets/wizard/ru.json @@ -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", diff --git a/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts b/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts index 2c2a775b8a..dd9071645e 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts @@ -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, }; diff --git a/src/shared/types/config/wizard/v11.ts b/src/shared/types/config/wizard/v11.ts index b3f2bd7e58..00917394b2 100644 --- a/src/shared/types/config/wizard/v11.ts +++ b/src/shared/types/config/wizard/v11.ts @@ -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; diff --git a/src/shared/types/wizard/index.ts b/src/shared/types/wizard/index.ts index cecb40155c..7c8c75701e 100644 --- a/src/shared/types/wizard/index.ts +++ b/src/shared/types/wizard/index.ts @@ -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; diff --git a/src/ui/constants/visualizations/index.ts b/src/ui/constants/visualizations/index.ts index 4ae451d021..87b78e718d 100644 --- a/src/ui/constants/visualizations/index.ts +++ b/src/ui/constants/visualizations/index.ts @@ -157,6 +157,10 @@ export const CHART_SETTINGS = { ON: 'on', OFF: 'off', }, + PIVOT_INLINE_SORT: { + ON: 'on', + OFF: 'off', + }, }; export const VISUALIZATION_IDS = { diff --git a/src/ui/units/wizard/components/Dialogs/Settings/Settings.tsx b/src/ui/units/wizard/components/Dialogs/Settings/Settings.tsx index 9e05641275..ba9377e85f 100644 --- a/src/ui/units/wizard/components/Dialogs/Settings/Settings.tsx +++ b/src/ui/units/wizard/components/Dialogs/Settings/Settings.tsx @@ -71,6 +71,7 @@ const BASE_SETTINGS_KEYS: SettingsKeys[] = [ 'feed', 'pivotFallback', 'navigatorSettings', + 'pivotInlineSort', ]; const QL_SETTINGS_KEYS: SettingsKeys[] = [...BASE_SETTINGS_KEYS, 'qlAutoExecuteChart']; @@ -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'); @@ -208,6 +211,7 @@ class DialogSettings extends React.PureComponent { feed = '', pivotFallback = 'off', qlAutoExecuteChart, + pivotInlineSort = CHART_SETTINGS.PIVOT_INLINE_SORT.ON, } = extraSettings; const navigatorSettings = this.prepareNavigatorSettings(visualization, extraSettings); @@ -249,7 +253,8 @@ class DialogSettings extends React.PureComponent { this.state = { valid: true, - + isPivotTable, + pivotInlineSort, titleMode, indicatorTitleMode, qlAutoExecuteChart: getQlAutoExecuteChartValue(qlAutoExecuteChart, props.chartType), @@ -481,6 +486,12 @@ class DialogSettings extends React.PureComponent { }); }; + handlePivotInlineSortUpdate = (value: string) => { + this.setState({ + pivotInlineSort: value, + }); + }; + getXPlaceholderItemDataType() { const {visualization} = this.props; const placeholders = visualization.placeholders || []; @@ -863,6 +874,24 @@ class DialogSettings extends React.PureComponent { ); } + renderInlineSortSwitch() { + const {isPivotTable, pivotInlineSort, pivotFallback} = this.state; + + if (!isPivotTable || pivotFallback === 'on') { + return null; + } + + return ( + + ); + } + renderModalBody() { const {navigatorSettings} = this.state; const {isPreviewLoading} = this.props; @@ -887,6 +916,7 @@ class DialogSettings extends React.PureComponent { {this.renderNavigator()} {this.renderD3Switch()} {this.renderQlAutoExecutionChart()} + {this.renderInlineSortSwitch()} ); }