File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
frontend/rust-lib/flowy-grid/src/services/field/type_options Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,17 @@ impl CellDataOperation for NumberTypeOption {
8585
8686 let cell_data = type_option_cell_data. data ;
8787 match self . format {
88- NumberFormat :: Number => cell_data. parse :: < i64 > ( ) . map_or ( String :: new ( ) , |v| v. to_string ( ) ) ,
88+ NumberFormat :: Number => {
89+ if let Ok ( v) = cell_data. parse :: < f64 > ( ) {
90+ return v. to_string ( ) ;
91+ }
92+
93+ if let Ok ( v) = cell_data. parse :: < i64 > ( ) {
94+ return v. to_string ( ) ;
95+ }
96+
97+ return String :: new ( ) ;
98+ }
8999 NumberFormat :: Percent => cell_data. parse :: < f64 > ( ) . map_or ( String :: new ( ) , |v| v. to_string ( ) ) ,
90100 _ => self . money_from_str ( & cell_data) ,
91101 }
@@ -100,7 +110,8 @@ impl CellDataOperation for NumberTypeOption {
100110 _cell_meta : Option < CellMeta > ,
101111 ) -> Result < String , FlowyError > {
102112 let changeset = changeset. into ( ) ;
103- let data = self . strip_symbol ( changeset) ;
113+ let data = changeset. to_string ( ) ;
114+ let data = self . strip_symbol ( data. trim ( ) ) ;
104115
105116 if !data. chars ( ) . all ( char:: is_numeric) {
106117 return Err ( FlowyError :: invalid_data ( ) . context ( "Should only contain numbers" ) ) ;
You can’t perform that action at this time.
0 commit comments