From f9862c501ca28af2ce26ed78a7b4b08bcf6f8fcb Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Tue, 16 May 2023 08:53:09 +0800 Subject: [PATCH] chore: fix typo (#2540) --- .../checkbox_type_option_entities.rs | 17 ++++---- .../date_type_option_entities.rs | 6 +-- .../number_type_option/number_type_option.rs | 40 ++++++++++--------- .../selection_type_option/select_ids.rs | 12 +++--- .../text_type_option/text_type_option.rs | 27 +++++++------ .../field/type_options/type_option_cell.rs | 2 +- .../url_type_option_entities.rs | 14 ++++--- 7 files changed, 64 insertions(+), 54 deletions(-) diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs index a81001c09d..3a3254a0ca 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs @@ -1,12 +1,15 @@ -use crate::entities::FieldType; -use crate::services::cell::{CellProtobufBlobParser, DecodedCellData, FromCellString}; -use crate::services::field::CELL_DATE; +use std::str::FromStr; + use bytes::Bytes; use collab::core::any_map::AnyMapExtension; use collab_database::rows::{new_cell_builder, Cell}; -use flowy_error::{FlowyError, FlowyResult}; use protobuf::ProtobufError; -use std::str::FromStr; + +use flowy_error::{FlowyError, FlowyResult}; + +use crate::entities::FieldType; +use crate::services::cell::{CellProtobufBlobParser, DecodedCellData, FromCellString}; +use crate::services::field::CELL_DATA; pub const CHECK: &str = "Yes"; pub const UNCHECK: &str = "No"; @@ -36,7 +39,7 @@ impl AsRef<[u8]> for CheckboxCellData { impl From<&Cell> for CheckboxCellData { fn from(cell: &Cell) -> Self { - let value = cell.get_str_value(CELL_DATE).unwrap_or_default(); + let value = cell.get_str_value(CELL_DATA).unwrap_or_default(); CheckboxCellData::from_cell_str(&value).unwrap_or_default() } } @@ -44,7 +47,7 @@ impl From<&Cell> for CheckboxCellData { impl From for Cell { fn from(data: CheckboxCellData) -> Self { new_cell_builder(FieldType::Checkbox) - .insert_str_value(CELL_DATE, data.to_string()) + .insert_str_value(CELL_DATA, data.to_string()) .build() } } diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs index 026ac38dc2..e28587255b 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs @@ -15,7 +15,7 @@ use crate::entities::{DateCellDataPB, FieldType}; use crate::services::cell::{ CellProtobufBlobParser, DecodedCellData, FromCellChangeset, FromCellString, ToCellChangeset, }; -use crate::services::field::CELL_DATE; +use crate::services::field::CELL_DATA; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct DateCellChangeset { @@ -63,7 +63,7 @@ pub struct DateCellData { impl From<&Cell> for DateCellData { fn from(cell: &Cell) -> Self { let timestamp = cell - .get_str_value(CELL_DATE) + .get_str_value(CELL_DATA) .and_then(|data| data.parse::().ok()); let include_time = cell.get_bool_value("include_time").unwrap_or_default(); @@ -84,7 +84,7 @@ impl From for Cell { None => "".to_owned(), }; new_cell_builder(FieldType::DateTime) - .insert_str_value(CELL_DATE, timestamp_string) + .insert_str_value(CELL_DATA, timestamp_string) .insert_bool_value("include_time", data.include_time) .insert_str_value("timezone_id", data.timezone_id) .build() diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs index 41743cccbd..81b7e8405c 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs @@ -1,24 +1,26 @@ -use crate::entities::{FieldType, NumberFilterPB}; -use crate::services::cell::{CellDataChangeset, CellDataDecoder}; -use crate::services::field::type_options::number_type_option::format::*; -use crate::services::field::{ - NumberCellFormat, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare, - TypeOptionCellDataFilter, TypeOptionTransform, CELL_DATE, -}; -use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder}; - -use crate::services::field::type_options::util::ProtobufStr; -use collab::core::any_map::AnyMapExtension; -use collab_database::rows::{new_cell_builder, Cell}; -use fancy_regex::Regex; -use flowy_error::FlowyResult; -use lazy_static::lazy_static; -use rust_decimal::Decimal; -use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::default::Default; use std::str::FromStr; +use collab::core::any_map::AnyMapExtension; +use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder}; +use collab_database::rows::{new_cell_builder, Cell}; +use fancy_regex::Regex; +use lazy_static::lazy_static; +use rust_decimal::Decimal; +use serde::{Deserialize, Serialize}; + +use flowy_error::FlowyResult; + +use crate::entities::{FieldType, NumberFilterPB}; +use crate::services::cell::{CellDataChangeset, CellDataDecoder}; +use crate::services::field::type_options::number_type_option::format::*; +use crate::services::field::type_options::util::ProtobufStr; +use crate::services::field::{ + NumberCellFormat, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare, + TypeOptionCellDataFilter, TypeOptionTransform, CELL_DATA, +}; + // Number #[derive(Clone, Debug, Serialize, Deserialize)] pub struct NumberTypeOption { @@ -34,14 +36,14 @@ pub struct NumberCellData(pub String); impl From<&Cell> for NumberCellData { fn from(cell: &Cell) -> Self { - Self(cell.get_str_value(CELL_DATE).unwrap_or_default()) + Self(cell.get_str_value(CELL_DATA).unwrap_or_default()) } } impl From for Cell { fn from(data: NumberCellData) -> Self { new_cell_builder(FieldType::Number) - .insert_str_value(CELL_DATE, data.0) + .insert_str_value(CELL_DATA, data.0) .build() } } diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs index b0721ee445..c9719d6f04 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs @@ -1,10 +1,12 @@ -use crate::entities::FieldType; -use crate::services::cell::{DecodedCellData, FromCellString}; -use crate::services::field::CELL_DATE; use collab::core::any_map::AnyMapExtension; use collab_database::rows::{new_cell_builder, Cell}; + use flowy_error::FlowyResult; +use crate::entities::FieldType; +use crate::services::cell::{DecodedCellData, FromCellString}; +use crate::services::field::CELL_DATA; + pub const SELECTION_IDS_SEPARATOR: &str = ","; /// List of select option ids @@ -25,7 +27,7 @@ impl SelectOptionIds { pub fn to_cell_data(&self, field_type: FieldType) -> Cell { new_cell_builder(field_type) - .insert_str_value(CELL_DATE, self.to_string()) + .insert_str_value(CELL_DATA, self.to_string()) .build() } } @@ -41,7 +43,7 @@ impl FromCellString for SelectOptionIds { impl From<&Cell> for SelectOptionIds { fn from(cell: &Cell) -> Self { - let value = cell.get_str_value(CELL_DATE).unwrap_or_default(); + let value = cell.get_str_value(CELL_DATA).unwrap_or_default(); Self::from(value) } } diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs index 112086c6ab..d512b5f3ec 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs @@ -1,22 +1,23 @@ +use std::cmp::Ordering; + +use bytes::Bytes; +use collab::core::any_map::AnyMapExtension; +use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder}; +use collab_database::rows::{new_cell_builder, Cell}; +use serde::{Deserialize, Serialize}; + +use flowy_error::{FlowyError, FlowyResult}; + use crate::entities::{FieldType, TextFilterPB}; use crate::services::cell::{ stringify_cell_data, CellDataChangeset, CellDataDecoder, CellProtobufBlobParser, DecodedCellData, FromCellString, }; +use crate::services::field::type_options::util::ProtobufStr; use crate::services::field::{ TypeOption, TypeOptionCellData, TypeOptionCellDataCompare, TypeOptionCellDataFilter, - TypeOptionTransform, CELL_DATE, + TypeOptionTransform, CELL_DATA, }; -use bytes::Bytes; -use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder}; - -use crate::services::field::type_options::util::ProtobufStr; -use collab::core::any_map::AnyMapExtension; -use collab_database::rows::{new_cell_builder, Cell}; -use flowy_error::{FlowyError, FlowyResult}; - -use serde::{Deserialize, Serialize}; -use std::cmp::Ordering; /// For the moment, the `RichTextTypeOptionPB` is empty. The `data` property is not /// used yet. @@ -35,7 +36,7 @@ impl TypeOption for RichTextTypeOption { impl From for RichTextTypeOption { fn from(data: TypeOptionData) -> Self { - let s = data.get_str_value(CELL_DATE).unwrap_or_default(); + let s = data.get_str_value(CELL_DATA).unwrap_or_default(); Self { inner: s } } } @@ -43,7 +44,7 @@ impl From for RichTextTypeOption { impl From for TypeOptionData { fn from(data: RichTextTypeOption) -> Self { TypeOptionDataBuilder::new() - .insert_str_value(CELL_DATE, data.inner) + .insert_str_value(CELL_DATA, data.inner) .build() } } diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs index f528d7ff8a..16b6dd2c32 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs @@ -19,7 +19,7 @@ use crate::services::field::{ TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionTransform, URLTypeOption, }; -pub const CELL_DATE: &str = "data"; +pub const CELL_DATA: &str = "data"; /// A helper trait that used to erase the `Self` of `TypeOption` trait to make it become a Object-safe trait /// Only object-safe traits can be made into trait objects. diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs index c797539dae..c289668dab 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs @@ -1,12 +1,14 @@ -use crate::entities::{FieldType, URLCellDataPB}; -use crate::services::cell::{CellProtobufBlobParser, DecodedCellData, FromCellString}; -use crate::services::field::CELL_DATE; use bytes::Bytes; use collab::core::any_map::AnyMapExtension; use collab_database::rows::{new_cell_builder, Cell}; -use flowy_error::{internal_error, FlowyResult}; use serde::{Deserialize, Serialize}; +use flowy_error::{internal_error, FlowyResult}; + +use crate::entities::{FieldType, URLCellDataPB}; +use crate::services::cell::{CellProtobufBlobParser, DecodedCellData, FromCellString}; +use crate::services::field::CELL_DATA; + #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct URLCellData { pub url: String, @@ -29,7 +31,7 @@ impl URLCellData { impl From<&Cell> for URLCellData { fn from(cell: &Cell) -> Self { let url = cell.get_str_value("url").unwrap_or_default(); - let content = cell.get_str_value(CELL_DATE).unwrap_or_default(); + let content = cell.get_str_value(CELL_DATA).unwrap_or_default(); Self { url, data: content } } } @@ -38,7 +40,7 @@ impl From for Cell { fn from(data: URLCellData) -> Self { new_cell_builder(FieldType::URL) .insert_str_value("url", data.url) - .insert_str_value(CELL_DATE, data.data) + .insert_str_value(CELL_DATA, data.data) .build() } }