chore: fix typo (#2540)

This commit is contained in:
Nathan.fooo 2023-05-16 08:53:09 +08:00 committed by GitHub
parent 6dcf69f151
commit f9862c501c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 54 deletions

View File

@ -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<CheckboxCellData> 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()
}
}

View File

@ -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::<i64>().ok());
let include_time = cell.get_bool_value("include_time").unwrap_or_default();
@ -84,7 +84,7 @@ impl From<DateCellData> 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()

View File

@ -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<NumberCellData> 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()
}
}

View File

@ -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)
}
}

View File

@ -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<TypeOptionData> 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<TypeOptionData> for RichTextTypeOption {
impl From<RichTextTypeOption> for TypeOptionData {
fn from(data: RichTextTypeOption) -> Self {
TypeOptionDataBuilder::new()
.insert_str_value(CELL_DATE, data.inner)
.insert_str_value(CELL_DATA, data.inner)
.build()
}
}

View File

@ -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.

View File

@ -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<URLCellData> 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()
}
}