-
-
Notifications
You must be signed in to change notification settings - Fork 457
Description
Current behavior
-
For Number and Money UI types, the API supports two display options:
minimum_fraction_digitsandmaximum_fraction_digits. -
When formatting the cell values, these two display options are passed into Intl.NumberFormat as
minimumFractionDigitsandmaximumFractionDigits. -
The use-case for having two separate values is as follows:
Let's pretend I'm storing money amounts in USD and I have the following values:
dollars 1.4 2.8191 Also, for my task at-hand I'd like to see the full values, with all their stored precision, but I don't happen to know the maximum number of decimal places in my data set (and indeed it could change as I add new data). For this reason I don't want to set a maximum number of decimal places. But I do want to set a minimum number of decimal places to 2 because it's currency. I'd like to see:
dollars $1.40 $2.8191 -
However, currently our type configuration UI, lumps these separate values into the same singular "Decimal Places" field as shown below.
When the user enters a value into that field it gets written to
minimum_fraction_digitsandmaximum_fraction_digitsin tandem. And if the API happens to have different values for the field, the UI form is populated with the maximum of the two.
Design goals
-
The type configuration UI allows the user to set different values for
minimum_fraction_digitsandmaximum_fraction_digits. -
It should be possible for one or both values to be blank (
null). -
In most cases, the user will be likely to want only one value, and our UI should make it easy for the user to set both values identically without thinking too deeply about it.
-
It should not be possible for
maximum_fraction_digitsto be less thanminimum_fraction_digits, but we already have back-end validation in-place for that, so we may not necessarily need client-side validation for it.
