mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: support float number
This commit is contained in:
parent
a298f7c576
commit
bd0907b0a4
@ -85,7 +85,17 @@ impl CellDataOperation for NumberTypeOption {
|
||||
|
||||
let cell_data = type_option_cell_data.data;
|
||||
match self.format {
|
||||
NumberFormat::Number => cell_data.parse::<i64>().map_or(String::new(), |v| v.to_string()),
|
||||
NumberFormat::Number => {
|
||||
if let Ok(v) = cell_data.parse::<f64>() {
|
||||
return v.to_string();
|
||||
}
|
||||
|
||||
if let Ok(v) = cell_data.parse::<i64>() {
|
||||
return v.to_string();
|
||||
}
|
||||
|
||||
return String::new();
|
||||
}
|
||||
NumberFormat::Percent => cell_data.parse::<f64>().map_or(String::new(), |v| v.to_string()),
|
||||
_ => self.money_from_str(&cell_data),
|
||||
}
|
||||
@ -100,7 +110,8 @@ impl CellDataOperation for NumberTypeOption {
|
||||
_cell_meta: Option<CellMeta>,
|
||||
) -> Result<String, FlowyError> {
|
||||
let changeset = changeset.into();
|
||||
let data = self.strip_symbol(changeset);
|
||||
let data = changeset.to_string();
|
||||
let data = self.strip_symbol(data.trim());
|
||||
|
||||
if !data.chars().all(char::is_numeric) {
|
||||
return Err(FlowyError::invalid_data().context("Should only contain numbers"));
|
||||
|
Loading…
Reference in New Issue
Block a user