Skip to content
Snippets Groups Projects
Commit 8cbabd8d authored by Atte Keinänen's avatar Atte Keinänen Committed by GitHub
Browse files

Merge pull request #5550 from metabase/issue-4489

Show name of aggregation after sorting by it in sort list
parents abd88f10 34cf1b23
No related branches found
No related tags found
No related merge requests found
......@@ -541,6 +541,10 @@ export class AggregationDimension extends Dimension {
return this._displayName;
}
aggregationIndex(): number {
return this._args[0];
}
mbql() {
return ["aggregation", this._args[0]];
}
......
......@@ -5,7 +5,7 @@ import Clearable from "./Clearable.jsx";
import Query from "metabase/lib/query";
import Dimension from "metabase-lib/lib/Dimension";
import Dimension, { AggregationDimension } from "metabase-lib/lib/Dimension";
import _ from "underscore";
import cx from "classnames";
......@@ -15,7 +15,8 @@ export default class FieldName extends Component {
field: PropTypes.oneOfType([PropTypes.number, PropTypes.array]),
onClick: PropTypes.func,
removeField: PropTypes.func,
tableMetadata: PropTypes.object.isRequired
tableMetadata: PropTypes.object.isRequired,
query: PropTypes.object
};
static defaultProps = {
......@@ -30,14 +31,20 @@ export default class FieldName extends Component {
}
render() {
let { field, tableMetadata, className } = this.props;
let { field, tableMetadata, query, className } = this.props;
let parts = [];
if (field) {
const dimension = Dimension.parseMBQL(field, tableMetadata && tableMetadata.metadata);
if (dimension) {
parts = dimension.render();
if (dimension instanceof AggregationDimension) {
// Aggregation dimension doesn't know about its relation to the current query
// so we have to infer the display name of aggregation here
parts = <span key="field">{query.aggregations()[dimension.aggregationIndex()][0]}</span>
} else {
parts = <span key="field">{dimension.render()}</span>;
}
}
// TODO Atte Keinänen 6/23/17: Move nested queries logic to Dimension subclasses
// if the Field in question is a field literal, e.g. ["field-literal", <name>, <type>] just use name as-is
......
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