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

Fix default formatting options for numeric types (#17978)

parent 14e742b8
Branches
Tags
No related merge requests found
......@@ -70,20 +70,17 @@ export function columnSettings({
}
import MetabaseSettings from "metabase/lib/settings";
import { isa } from "metabase/lib/types";
export function getGlobalSettingsForColumn(column: Column) {
const settings = {};
const columnSettings = {};
const customFormatting = MetabaseSettings.get("custom-formatting") || {};
const customFormatting = MetabaseSettings.get("custom-formatting");
// NOTE: the order of these doesn't matter as long as there's no overlap between settings
for (const [type, globalSettings] of Object.entries(customFormatting || {})) {
if (isa(column.semantic_type || column.base_type, type)) {
Object.assign(settings, globalSettings);
}
for (const [, globalSettings] of Object.entries(customFormatting)) {
Object.assign(columnSettings, globalSettings);
}
return settings;
return columnSettings;
}
function getLocalSettingsForColumn(column: Column): Settings {
......
import { restore } from "__support__/e2e/cypress";
import { restore, visitQuestionAdhoc } from "__support__/e2e/cypress";
import { SAMPLE_DATASET } from "__support__/e2e/cypress_sample_dataset";
const { ORDERS, ORDERS_ID } = SAMPLE_DATASET;
......@@ -120,6 +120,36 @@ describe("scenarios > admin > localization", () => {
cy.findByText(/Localization options/i);
cy.contains(/Column title/i).should("not.exist");
});
it("should use currency settings for number columns with style set to currency (metabase#10787)", () => {
cy.visit("/admin/settings/localization");
cy.findByText("Unit of currency");
cy.findByText("US Dollar").click();
cy.findByText("Euro").click();
cy.findByText("Saved");
visitQuestionAdhoc({
display: "scalar",
dataset_query: {
type: "native",
native: {
query: "SELECT 10 as A",
"template-tags": {},
},
database: 1,
},
visualization_settings: {
column_settings: {
'["name","A"]': {
number_style: "currency",
},
},
},
});
cy.findByText("€10.00");
});
});
function setFirstWeekDayTo(day) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment