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:
parent
e3a1384f7f
commit
602f7e7b6c
@ -11,7 +11,10 @@ class NumberFormatBloc extends Bloc<NumberFormatEvent, NumberFormatState> {
|
||||
event.map(setFilter: (_SetFilter value) {
|
||||
final List<NumberFormat> formats = List.from(NumberFormat.values);
|
||||
if (value.filter.isNotEmpty) {
|
||||
formats.retainWhere((element) => element.title().toLowerCase().contains(value.filter.toLowerCase()));
|
||||
formats.retainWhere((element) => element
|
||||
.title()
|
||||
.toLowerCase()
|
||||
.contains(value.filter.toLowerCase()));
|
||||
}
|
||||
emit(state.copyWith(formats: formats, filter: value.filter));
|
||||
});
|
||||
@ -91,7 +94,7 @@ extension NumberFormatExtension on NumberFormat {
|
||||
case NumberFormat.Percent:
|
||||
return "Percent";
|
||||
case NumberFormat.PhilippinePeso:
|
||||
return "Percent";
|
||||
return "PhilippinePeso";
|
||||
case NumberFormat.Pound:
|
||||
return "Pound";
|
||||
case NumberFormat.Rand:
|
||||
|
@ -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()),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user