Skip to content
Snippets Groups Projects
Unverified Commit 308090f1 authored by Dalton's avatar Dalton Committed by GitHub
Browse files

use column settings instead of display_name for pivot table value header (#20435)

parent 4a76c4b0
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ import _ from "underscore"; ...@@ -2,7 +2,7 @@ import _ from "underscore";
import { getIn } from "icepick"; import { getIn } from "icepick";
import { t } from "ttag"; import { t } from "ttag";
import { formatValue } from "metabase/lib/formatting"; import { formatValue, formatColumn } from "metabase/lib/formatting";
export function isPivotGroupColumn(col) { export function isPivotGroupColumn(col) {
return col.name === "pivot-grouping"; return col.name === "pivot-grouping";
...@@ -141,7 +141,10 @@ export function multiLevelPivot(data, settings) { ...@@ -141,7 +141,10 @@ export function multiLevelPivot(data, settings) {
const columnIndex = addEmptyIndexItem( const columnIndex = addEmptyIndexItem(
formattedColumnTreeWithoutValues.flatMap(root => enumeratePaths(root)), formattedColumnTreeWithoutValues.flatMap(root => enumeratePaths(root)),
); );
const valueColumns = valueColumnIndexes.map(index => columns[index]); const valueColumns = valueColumnIndexes.map(index => [
columns[index],
columnSettings[index],
]);
const formattedColumnTree = addValueColumnNodes( const formattedColumnTree = addValueColumnNodes(
formattedColumnTreeWithoutValues, formattedColumnTreeWithoutValues,
valueColumns, valueColumns,
...@@ -334,11 +337,13 @@ function formatValuesInTree( ...@@ -334,11 +337,13 @@ function formatValuesInTree(
// We display the value column names if there are multiple // We display the value column names if there are multiple
// or if there are no columns pivoted to the top header. // or if there are no columns pivoted to the top header.
function addValueColumnNodes(nodes, valueColumns) { function addValueColumnNodes(nodes, valueColumns) {
const leafNodes = valueColumns.map(column => ({ const leafNodes = valueColumns.map(([column, columnSettings]) => {
value: column.display_name, return {
children: [], value: columnSettings.column_title || formatColumn(column),
isValueColumn: true, children: [],
})); isValueColumn: true,
};
});
if (nodes.length === 0) { if (nodes.length === 0) {
return leafNodes; return leafNodes;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment