File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -70,26 +70,31 @@ const styles = {
70
70
*/
71
71
export function DisplayRounding ( { decimalAfterDot } ) {
72
72
const intl = useIntl ( ) ;
73
+ const roundedTo1 = decimalAfterDot === 0 ;
73
74
const displayAsPower10 = decimalAfterDot > 4 ;
74
75
const baseMessage =
75
76
intl . formatMessage ( {
76
- id : 'filter.rounded' ,
77
+ id : roundedTo1 ? 'filter.roundedToOne' : 'filter.rounded' ,
77
78
} ) + ' ' ;
78
79
79
80
const decimalAfterDotStr = - decimalAfterDot ;
81
+ let roundingPrecision = null ;
82
+ if ( ! roundedTo1 ) {
83
+ roundingPrecision = displayAsPower10 ? (
84
+ < >
85
+ 10
86
+ < Box component = "span" sx = { styles . exponent } >
87
+ { decimalAfterDotStr }
88
+ </ Box >
89
+ </ >
90
+ ) : (
91
+ 1 / Math . pow ( 10 , decimalAfterDot )
92
+ ) ;
93
+ }
80
94
return (
81
95
< FormHelperText >
82
96
{ baseMessage }
83
- { displayAsPower10 ? (
84
- < >
85
- 10
86
- < Box component = "span" sx = { styles . exponent } >
87
- { decimalAfterDotStr }
88
- </ Box >
89
- </ >
90
- ) : (
91
- 1 / Math . pow ( 10 , decimalAfterDot )
92
- ) }
97
+ { roundingPrecision }
93
98
</ FormHelperText >
94
99
) ;
95
100
}
@@ -491,7 +496,7 @@ const CustomHeaderComponent = ({
491
496
} }
492
497
/>
493
498
</ Grid >
494
- { isNumberInput && decimalAfterDot > 0 ? (
499
+ { isNumberInput && selectedFilterData ? (
495
500
< Grid item >
496
501
< DisplayRounding decimalAfterDot = { decimalAfterDot } />
497
502
</ Grid >
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const filter_locale_en = {
17
17
'filter.greaterThan' : 'Greater than' ,
18
18
'filter.filterOoo' : 'Filter...' ,
19
19
'filter.rounded' : 'Rounded to' ,
20
+ 'filter.roundedToOne' : 'Rounded to the nearest unit.' ,
20
21
'filter.warnRounding' : 'From 13 decimal places after the comma, filters become imprecise.' ,
21
22
} ;
22
23
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const filter_locale_fr = {
17
17
'filter.greaterThan' : 'Supérieur' ,
18
18
'filter.filterOoo' : 'Filtrer...' ,
19
19
'filter.rounded' : 'Arrondi à' ,
20
+ 'filter.roundedToOne' : "Arrondi à l'unité." ,
20
21
'filter.warnRounding' : 'À partir de 13 décimales après la virgule, les filtres deviennent imprécis.' ,
21
22
} ;
22
23
You can’t perform that action at this time.
0 commit comments