mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: launch review 0.5.1 (#4855)
* feat: floating calculations row * fix: calculate cell overflow + tooltip * fix: empty text cell should be counted as empty * fix: empty text cell sohuld not be counted as not empty * fix: conversion of some field types for calculations * fix: tooltip + size of duplicate event button * fix: minor view meta info changes * fix: apply number format on word/char count * fix: dart format * fix: hide arrow for calc values --------- Co-authored-by: Richard Shiue <71320345+richardshiue@users.noreply.github.com>
This commit is contained in:
@ -116,8 +116,13 @@ impl CalculationType {
|
||||
| CalculationType::Sum => {
|
||||
matches!(field_type, FieldType::Number)
|
||||
},
|
||||
// Exclude some fields from CountNotEmpty & CountEmpty
|
||||
CalculationType::CountEmpty | CalculationType::CountNonEmpty => !matches!(
|
||||
field_type,
|
||||
FieldType::URL | FieldType::Checkbox | FieldType::CreatedTime | FieldType::LastEditedTime
|
||||
),
|
||||
// All fields
|
||||
CalculationType::Count | CalculationType::CountEmpty | CalculationType::CountNonEmpty => true,
|
||||
CalculationType::Count => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ impl CalculationsService {
|
||||
CalculationType::Min => self.calculate_min(field, row_cells),
|
||||
CalculationType::Sum => self.calculate_sum(field, row_cells),
|
||||
CalculationType::Count => self.calculate_count(row_cells),
|
||||
CalculationType::CountEmpty => self.calculate_count_empty(row_cells),
|
||||
CalculationType::CountNonEmpty => self.calculate_count_non_empty(row_cells),
|
||||
CalculationType::CountEmpty => self.calculate_count_empty(field, row_cells),
|
||||
CalculationType::CountNonEmpty => self.calculate_count_non_empty(field, row_cells),
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,34 +129,51 @@ impl CalculationsService {
|
||||
}
|
||||
}
|
||||
|
||||
fn calculate_count_empty(&self, row_cells: Vec<Arc<RowCell>>) -> String {
|
||||
if !row_cells.is_empty() {
|
||||
format!(
|
||||
"{}",
|
||||
row_cells
|
||||
.iter()
|
||||
.filter(|c| c.is_none())
|
||||
.collect::<Vec<_>>()
|
||||
.len()
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
fn calculate_count_empty(&self, field: &Field, row_cells: Vec<Arc<RowCell>>) -> String {
|
||||
let field_type = FieldType::from(field.field_type);
|
||||
if let Some(handler) = TypeOptionCellExt::new_with_cell_data_cache(field, None)
|
||||
.get_type_option_cell_data_handler(&field_type)
|
||||
{
|
||||
if !row_cells.is_empty() {
|
||||
return format!(
|
||||
"{}",
|
||||
row_cells
|
||||
.iter()
|
||||
.filter(|c| c.is_none()
|
||||
|| handler
|
||||
.handle_stringify_cell(&c.cell.clone().unwrap_or_default(), &field_type, field)
|
||||
.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn calculate_count_non_empty(&self, row_cells: Vec<Arc<RowCell>>) -> String {
|
||||
if !row_cells.is_empty() {
|
||||
format!(
|
||||
"{}",
|
||||
row_cells
|
||||
.iter()
|
||||
.filter(|c| c.is_some())
|
||||
.collect::<Vec<_>>()
|
||||
.len()
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
fn calculate_count_non_empty(&self, field: &Field, row_cells: Vec<Arc<RowCell>>) -> String {
|
||||
let field_type = FieldType::from(field.field_type);
|
||||
if let Some(handler) = TypeOptionCellExt::new_with_cell_data_cache(field, None)
|
||||
.get_type_option_cell_data_handler(&field_type)
|
||||
{
|
||||
if !row_cells.is_empty() {
|
||||
return format!(
|
||||
"{}",
|
||||
row_cells
|
||||
.iter()
|
||||
// Check the Cell has data and that the stringified version is not empty
|
||||
.filter(|c| c.is_some()
|
||||
&& !handler
|
||||
.handle_stringify_cell(&c.cell.clone().unwrap_or_default(), &field_type, field)
|
||||
.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn reduce_values_f64<F, T>(&self, field: &Field, row_cells: Vec<Arc<RowCell>>, f: F) -> T
|
||||
|
Reference in New Issue
Block a user