Compare commits

...

2 Commits

Author SHA1 Message Date
lbrdnk
ab4e9b5f06 Reproduction 2025-10-01 19:56:46 +02:00
lbrdnk
5169b2cba0 Fix incorrect separator on FE and add guard to setting 2025-10-01 19:50:32 +02:00
3 changed files with 34 additions and 2 deletions

View File

@@ -158,7 +158,7 @@ export function FormattingWidget() {
{ label: "100 000,00", value: ", " },
{ label: "100.000,00", value: ",." },
{ label: "100000.00", value: "." },
{ label: "100'000.00", value: ".'" },
{ label: "100’000.00", value: ".’" },
]}
onChange={(newValue) =>
handleChange({

View File

@@ -341,6 +341,23 @@ See [fonts](../configuring-metabase/fonts.md).")
:audit :getter
:feature :whitelabel)
(def avaialable-number-separators
"Number separators that are available to use in uploads csv parsing. Values match what is implemented
`metabase.upload.types` namespace, specifically e.g. [[metabase.upload.types/int-regex]]."
#{"."
".,"
",."
", "
".’"})
(defn- validate-custom-formatting!
[new-value]
(let [separators (some-> new-value :type/Number :number_separators)]
(when-not (avaialable-number-separators separators)
(throw (ex-info (tru "Invalid number separators.")
{:separators separators
:available-separators avaialable-number-separators})))))
(defsetting custom-formatting
(deferred-tru "Object keyed by type, containing formatting settings")
:encryption :no
@@ -348,7 +365,10 @@ See [fonts](../configuring-metabase/fonts.md).")
:export? true
:default {}
:visibility :public
:audit :getter)
:audit :getter
:setter (fn [new-value]
(validate-custom-formatting! new-value)
(setting/set-value-of-type! :json :custom-formatting new-value)))
(defsetting show-homepage-data
(deferred-tru

View File

@@ -178,3 +178,15 @@
(is (thrown-with-msg? clojure.lang.ExceptionInfo
#"Loading message set to an unsupported value"
(appearance.settings/loading-message! :unsupported-value))))))
(deftest custom-formatting-number-separators-test
(testing "Only valid values can be set as number separators (#61854)"
(let [violating-separators ".'"]
(is (thrown-with-msg?
Exception #"Invalid number separators."
(appearance.settings/custom-formatting!
#:type{:Temporal {:date_style "MMMM D, YYYY"
:time_style "h:mm A"
:date_abbreviate false}
:Number {:number_separators violating-separators}
:Currency {:currency "USD" :currency_style "symbol"}}))))))