mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: don't use timestamp fields to make calendar (#3366)
This commit is contained in:
parent
1ca130d7de
commit
a4681a4042
@ -558,8 +558,6 @@ impl FieldType {
|
|||||||
|
|
||||||
pub fn is_date(&self) -> bool {
|
pub fn is_date(&self) -> bool {
|
||||||
matches!(self, FieldType::DateTime)
|
matches!(self, FieldType::DateTime)
|
||||||
|| matches!(self, FieldType::LastEditedTime)
|
|
||||||
|| matches!(self, FieldType::CreatedTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_single_select(&self) -> bool {
|
pub fn is_single_select(&self) -> bool {
|
||||||
|
@ -82,8 +82,6 @@ impl TypeCellData {
|
|||||||
|
|
||||||
pub fn is_date(&self) -> bool {
|
pub fn is_date(&self) -> bool {
|
||||||
self.field_type == FieldType::DateTime
|
self.field_type == FieldType::DateTime
|
||||||
|| self.field_type == FieldType::LastEditedTime
|
|
||||||
|| self.field_type == FieldType::CreatedTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_single_select(&self) -> bool {
|
pub fn is_single_select(&self) -> bool {
|
||||||
|
@ -51,7 +51,7 @@ impl DatabaseLayoutDepsResolver {
|
|||||||
.lock()
|
.lock()
|
||||||
.get_fields(None)
|
.get_fields(None)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|field| FieldType::from(field.field_type).is_date())
|
.find(|field| FieldType::from(field.field_type) == FieldType::DateTime)
|
||||||
{
|
{
|
||||||
Some(field) => {
|
Some(field) => {
|
||||||
let layout_setting = CalendarLayoutSetting::new(field.id).into();
|
let layout_setting = CalendarLayoutSetting::new(field.id).into();
|
||||||
|
@ -184,7 +184,10 @@ impl CellDataDecoder for NumberTypeOption {
|
|||||||
decoded_field_type: &FieldType,
|
decoded_field_type: &FieldType,
|
||||||
_field: &Field,
|
_field: &Field,
|
||||||
) -> FlowyResult<<Self as TypeOption>::CellData> {
|
) -> FlowyResult<<Self as TypeOption>::CellData> {
|
||||||
if decoded_field_type.is_date() {
|
if decoded_field_type.is_date()
|
||||||
|
|| decoded_field_type.is_created_time()
|
||||||
|
|| decoded_field_type.is_last_edited_time()
|
||||||
|
{
|
||||||
return Ok(Default::default());
|
return Ok(Default::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +130,8 @@ impl CellDataDecoder for TimestampTypeOption {
|
|||||||
decoded_field_type: &FieldType,
|
decoded_field_type: &FieldType,
|
||||||
_field: &Field,
|
_field: &Field,
|
||||||
) -> FlowyResult<<Self as TypeOption>::CellData> {
|
) -> FlowyResult<<Self as TypeOption>::CellData> {
|
||||||
// Return default data if the type_option_cell_data is not FieldType::DateTime.
|
// Return default data if the type_option_cell_data is not FieldType::CreatedTime nor FieldType::LastEditedTime
|
||||||
// It happens when switching from one field to another.
|
if !decoded_field_type.is_last_edited_time() && !decoded_field_type.is_created_time() {
|
||||||
// For example:
|
|
||||||
// FieldType::RichText -> FieldType::DateTime, it will display empty content on the screen.
|
|
||||||
if !decoded_field_type.is_date() {
|
|
||||||
return Ok(Default::default());
|
return Ok(Default::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +174,7 @@ impl TypeOptionCellDataFilter for TimestampTypeOption {
|
|||||||
field_type: &FieldType,
|
field_type: &FieldType,
|
||||||
cell_data: &<Self as TypeOption>::CellData,
|
cell_data: &<Self as TypeOption>::CellData,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if !field_type.is_date() {
|
if !field_type.is_last_edited_time() && !field_type.is_created_time() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user