mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: format number in percent format
This commit is contained in:
@ -70,6 +70,15 @@ define_currency_set!(
|
||||
symbol: "RUB",
|
||||
symbol_first: false,
|
||||
},
|
||||
PERCENT : {
|
||||
code: "",
|
||||
exponent: 2,
|
||||
locale: EnIn,
|
||||
minor_units: 1,
|
||||
name: "percent",
|
||||
symbol: "%",
|
||||
symbol_first: false,
|
||||
},
|
||||
USD : {
|
||||
code: "USD",
|
||||
exponent: 2,
|
||||
@ -435,7 +444,7 @@ impl NumberFormat {
|
||||
NumberFormat::Leu => number_currency::RON,
|
||||
NumberFormat::ArgentinePeso => number_currency::ARS,
|
||||
NumberFormat::UruguayanPeso => number_currency::UYU,
|
||||
NumberFormat::Percent => number_currency::USD,
|
||||
NumberFormat::Percent => number_currency::PERCENT,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,11 @@ mod tests {
|
||||
assert_number(&type_option, "€0.5", "€0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "€1844", "€1.844", &field_type, &field_rev);
|
||||
}
|
||||
NumberFormat::Percent => {
|
||||
assert_number(&type_option, "1", "1%", &field_type, &field_rev);
|
||||
assert_number(&type_option, "10.1", "10.1%", &field_type, &field_rev);
|
||||
assert_number(&type_option, "100", "100%", &field_type, &field_rev);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ impl NumberTypeOptionPB {
|
||||
|
||||
pub(crate) fn format_cell_data(&self, s: &str) -> FlowyResult<NumberCellData> {
|
||||
match self.format {
|
||||
NumberFormat::Num | NumberFormat::Percent => match Decimal::from_str(s) {
|
||||
NumberFormat::Num => match Decimal::from_str(s) {
|
||||
Ok(value, ..) => Ok(NumberCellData::from_decimal(value)),
|
||||
Err(_) => Ok(NumberCellData::new()),
|
||||
},
|
||||
|
Reference in New Issue
Block a user