chore: rename update at and create at (#2672)

This commit is contained in:
Nathan.fooo
2023-05-31 17:34:41 +08:00
committed by GitHub
parent 80f08d4bec
commit 09d61c79c9
31 changed files with 84 additions and 84 deletions

View File

@ -492,8 +492,8 @@ pub enum FieldType {
Checkbox = 5,
URL = 6,
Checklist = 7,
UpdatedAt = 8,
CreatedAt = 9,
LastEditedTime = 8,
CreatedTime = 9,
}
pub const RICH_TEXT_FIELD: FieldType = FieldType::RichText;
@ -504,8 +504,8 @@ pub const MULTI_SELECT_FIELD: FieldType = FieldType::MultiSelect;
pub const CHECKBOX_FIELD: FieldType = FieldType::Checkbox;
pub const URL_FIELD: FieldType = FieldType::URL;
pub const CHECKLIST_FIELD: FieldType = FieldType::Checklist;
pub const UPDATED_AT_FIELD: FieldType = FieldType::UpdatedAt;
pub const CREATED_AT_FIELD: FieldType = FieldType::CreatedAt;
pub const UPDATED_AT_FIELD: FieldType = FieldType::LastEditedTime;
pub const CREATED_AT_FIELD: FieldType = FieldType::CreatedTime;
impl std::default::Default for FieldType {
fn default() -> Self {
@ -539,7 +539,7 @@ impl FieldType {
pub fn default_cell_width(&self) -> i32 {
match self {
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => 180,
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => 180,
_ => 150,
}
}
@ -554,8 +554,8 @@ impl FieldType {
FieldType::Checkbox => "Checkbox",
FieldType::URL => "URL",
FieldType::Checklist => "Checklist",
FieldType::UpdatedAt => "Updated At",
FieldType::CreatedAt => "Created At",
FieldType::LastEditedTime => "Last edited time",
FieldType::CreatedTime => "Created time",
};
s.to_string()
}

View File

@ -35,7 +35,7 @@ impl std::convert::From<&Filter> for FilterPB {
let bytes: Bytes = match filter.field_type {
FieldType::RichText => TextFilterPB::from(filter).try_into().unwrap(),
FieldType::Number => NumberFilterPB::from(filter).try_into().unwrap(),
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
DateFilterPB::from(filter).try_into().unwrap()
},
FieldType::SingleSelect => SelectOptionFilterPB::from(filter).try_into().unwrap(),
@ -200,7 +200,7 @@ impl TryInto<UpdateFilterParams> for UpdateFilterPayloadPB {
condition = filter.condition as u8;
content = filter.content;
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
let filter = DateFilterPB::try_from(bytes).map_err(|_| ErrorCode::ProtobufSerde)?;
condition = filter.condition as u8;
content = DateFilterContentPB {

View File

@ -12,8 +12,8 @@ macro_rules! impl_into_field_type {
5 => FieldType::Checkbox,
6 => FieldType::URL,
7 => FieldType::Checklist,
8 => FieldType::UpdatedAt,
9 => FieldType::CreatedAt,
8 => FieldType::LastEditedTime,
9 => FieldType::CreatedTime,
_ => {
tracing::error!("Can't parser FieldType from value: {}", ty);
FieldType::RichText

View File

@ -330,7 +330,7 @@ impl<'a> CellBuilder<'a> {
cells.insert(field_id, insert_number_cell(num, field));
}
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
if let Ok(timestamp) = cell_str.parse::<i64>() {
cells.insert(field_id, insert_date_cell(timestamp, Some(false), field));
}
@ -362,7 +362,7 @@ impl<'a> CellBuilder<'a> {
for field in fields {
if !cell_by_field_id.contains_key(&field.id) {
let field_type = FieldType::from(field.field_type);
if field_type == FieldType::UpdatedAt || field_type == FieldType::CreatedAt {
if field_type == FieldType::LastEditedTime || field_type == FieldType::CreatedTime {
cells.insert(
field.id.clone(),
insert_date_cell(timestamp(), Some(true), field),

View File

@ -82,8 +82,8 @@ impl TypeCellData {
pub fn is_date(&self) -> bool {
self.field_type == FieldType::DateTime
|| self.field_type == FieldType::UpdatedAt
|| self.field_type == FieldType::CreatedAt
|| self.field_type == FieldType::LastEditedTime
|| self.field_type == FieldType::CreatedTime
}
pub fn is_single_select(&self) -> bool {

View File

@ -514,7 +514,7 @@ impl DatabaseEditor {
.lock()
.get_fields(view_id, None)
.into_iter()
.filter(|f| FieldType::from(f.field_type) == FieldType::UpdatedAt)
.filter(|f| FieldType::from(f.field_type) == FieldType::LastEditedTime)
.collect::<Vec<Field>>();
self.database.lock().update_row(&row_id, |row_update| {

View File

@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::str::FromStr;
/// The [DateTypeOption] is used by [FieldType::Date], [FieldType::UpdatedAt], and [FieldType::CreatedAt].
/// The [DateTypeOption] is used by [FieldType::Date], [FieldType::LastEditedTime], and [FieldType::CreatedTime].
/// So, storing the field type is necessary to distinguish the field type.
/// Most of the cases, each [FieldType] has its own [TypeOption] implementation.
#[derive(Clone, Default, Debug, Serialize, Deserialize)]

View File

@ -146,7 +146,7 @@ pub fn type_option_data_from_pb_or_default<T: Into<Bytes>>(
FieldType::Number => {
NumberTypeOptionPB::try_from(bytes).map(|pb| NumberTypeOption::from(pb).into())
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
DateTypeOptionPB::try_from(bytes).map(|pb| DateTypeOption::from(pb).into())
},
FieldType::SingleSelect => {
@ -181,7 +181,7 @@ pub fn type_option_to_pb(type_option: TypeOptionData, field_type: &FieldType) ->
.try_into()
.unwrap()
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
let date_type_option: DateTypeOption = type_option.into();
DateTypeOptionPB::from(date_type_option).try_into().unwrap()
},
@ -220,7 +220,7 @@ pub fn default_type_option_data_from_type(field_type: &FieldType) -> TypeOptionD
match field_type {
FieldType::RichText => RichTextTypeOption::default().into(),
FieldType::Number => NumberTypeOption::default().into(),
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => DateTypeOption {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => DateTypeOption {
field_type: field_type.clone(),
..Default::default()
}

View File

@ -352,7 +352,7 @@ impl<'a> TypeOptionCellExt<'a> {
self.cell_data_cache.clone(),
)
}),
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => self
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => self
.field
.get_type_option::<DateTypeOption>(field_type)
.map(|type_option| {
@ -472,7 +472,7 @@ fn get_type_option_transform_handler(
FieldType::Number => {
Box::new(NumberTypeOption::from(type_option_data)) as Box<dyn TypeOptionTransformHandler>
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
Box::new(DateTypeOption::from(type_option_data)) as Box<dyn TypeOptionTransformHandler>
},
FieldType::SingleSelect => Box::new(SingleSelectTypeOption::from(type_option_data))

View File

@ -325,7 +325,7 @@ impl FilterController {
.write()
.insert(field_id, NumberFilterPB::from_filter(filter.as_ref()));
},
FieldType::DateTime | FieldType::UpdatedAt | FieldType::CreatedAt => {
FieldType::DateTime | FieldType::LastEditedTime | FieldType::CreatedTime => {
self
.cell_filter_cache
.write()