Skip to content
Snippets Groups Projects
Unverified Commit 4252a066 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix table columns remapped fields (#39798)

parent e4dcb68b
Branches
Tags
No related merge requests found
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
getDraggableElements,
moveColumnDown,
visitQuestionAdhoc,
restore,
} from "e2e/support/helpers";
const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;
describe("issue 39795", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
//If you comment out this post, then the test will pass.
cy.request("post", `/api/field/${ORDERS.PRODUCT_ID}/dimension`, {
human_readable_field_id: PRODUCTS.TITLE,
name: "Product ID",
type: "external",
});
});
it("should allow me to re-order even when a field is set with a different display value (metabase#39795)", () => {
visitQuestionAdhoc({
dataset_query: {
database: SAMPLE_DB_ID,
query: {
"source-table": ORDERS_ID,
},
type: "query",
},
});
cy.findByTestId("viz-settings-button").click();
moveColumnDown(getDraggableElements().first(), 2);
// We are not able to re-order because the dataset will also contain values a column for Product ID
// This causes the isValid() check to fire, and you are always forced into the default value for table.columns
getDraggableElements().eq(2).should("contain.text", "ID");
});
});
......@@ -515,7 +515,7 @@ class Question {
return this;
}
_syncTableColumnSettings({ data: { cols = [] } = {} }: Dataset) {
_syncTableColumnSettings({ data = {} }: Dataset) {
const columnSettings = this.setting("table.columns") || [];
// "table.columns" receive a value only if there are custom settings
// e.g. some columns are hidden. If it's empty, it means everything is visible
......@@ -524,6 +524,8 @@ class Question {
return this;
}
// remove columns used for remapping only
const cols = data.cols.filter(col => col.remapped_from == null);
const columnIndexes = findColumnIndexesForColumnSettings(
cols,
columnSettings,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment