From a2b5d6fa996ad76f422b77e85ce6a85f87b79437 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sat, 31 Dec 2022 08:06:10 +0800 Subject: [PATCH] fix: number cell format (#1623) Co-authored-by: nathan --- .../rust-lib/flowy-grid/src/event_handler.rs | 13 +- .../src/services/cell/cell_operation.rs | 6 +- .../src/services/cell/type_cell_data.rs | 7 +- .../checkbox_type_option.rs | 4 +- .../date_type_option/date_tests.rs | 8 +- .../date_type_option/date_type_option.rs | 6 +- .../date_type_option_entities.rs | 2 +- .../number_type_option/number_type_option.rs | 6 +- .../checklist_type_option.rs | 11 +- .../multi_select_type_option.rs | 27 +- .../select_type_option.rs | 2 +- .../single_select_type_option.rs | 21 +- .../text_type_option/text_type_option.rs | 5 +- .../field/type_options/type_option.rs | 2 +- .../field/type_options/type_option_cell.rs | 34 +- .../type_options/url_type_option/url_tests.rs | 2 +- .../url_type_option/url_type_option.rs | 7 +- .../url_type_option_entities.rs | 2 +- .../src/services/sort/controller.rs | 4 + .../src/services/view_editor/editor.rs | 7 + .../flowy-grid/tests/grid/field_test/test.rs | 6 +- .../src/client_grid/grid_revision_pad.rs | 11 +- shared-lib/Cargo.lock | 936 +----------------- shared-lib/grid-rev-model/src/grid_rev.rs | 4 +- 24 files changed, 132 insertions(+), 1001 deletions(-) diff --git a/frontend/rust-lib/flowy-grid/src/event_handler.rs b/frontend/rust-lib/flowy-grid/src/event_handler.rs index 72330e3b40..f66d7accc6 100644 --- a/frontend/rust-lib/flowy-grid/src/event_handler.rs +++ b/frontend/rust-lib/flowy-grid/src/event_handler.rs @@ -229,11 +229,14 @@ pub(crate) async fn move_field_handler( /// The [FieldRevision] contains multiple data, each of them belongs to a specific FieldType. async fn get_type_option_data(field_rev: &FieldRevision, field_type: &FieldType) -> FlowyResult> { - let s = field_rev.get_type_option_str(field_type).unwrap_or_else(|| { - default_type_option_builder_from_type(field_type) - .serializer() - .json_str() - }); + let s = field_rev + .get_type_option_str(field_type) + .map(|value| value.to_owned()) + .unwrap_or_else(|| { + default_type_option_builder_from_type(field_type) + .serializer() + .json_str() + }); let field_type: FieldType = field_rev.ty.into(); let builder = type_option_builder_from_json_str(&s, &field_type); let type_option_data = builder.serializer().protobuf_bytes().to_vec(); diff --git a/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs b/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs index 46aa411338..396248ae52 100644 --- a/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs +++ b/frontend/rust-lib/flowy-grid/src/services/cell/cell_operation.rs @@ -41,7 +41,7 @@ pub trait CellDataChangeset: TypeOption { &self, changeset: ::CellChangeset, type_cell_data: Option, - ) -> FlowyResult<::CellData>; + ) -> FlowyResult<(String, ::CellData)>; } /// changeset: It will be deserialized into specific data base on the FieldType. @@ -65,13 +65,13 @@ pub fn apply_cell_data_changeset None, }); - let cell_data = match TypeOptionCellExt::new_with_cell_data_cache(field_rev, cell_data_cache) + let cell_str = match TypeOptionCellExt::new_with_cell_data_cache(field_rev, cell_data_cache) .get_type_option_cell_data_handler(&field_type) { None => "".to_string(), Some(handler) => handler.handle_cell_changeset(changeset, type_cell_data, field_rev)?, }; - Ok(TypeCellData::new(cell_data, field_type).to_json()) + Ok(TypeCellData::new(cell_str, field_type).to_json()) } pub fn decode_type_cell_data + Debug>( diff --git a/frontend/rust-lib/flowy-grid/src/services/cell/type_cell_data.rs b/frontend/rust-lib/flowy-grid/src/services/cell/type_cell_data.rs index 0637804926..4c71065cc5 100644 --- a/frontend/rust-lib/flowy-grid/src/services/cell/type_cell_data.rs +++ b/frontend/rust-lib/flowy-grid/src/services/cell/type_cell_data.rs @@ -82,11 +82,8 @@ impl std::convert::TryFrom for TypeCellData { } impl TypeCellData { - pub fn new(content: String, field_type: FieldType) -> Self { - TypeCellData { - cell_str: content, - field_type, - } + pub fn new(cell_str: String, field_type: FieldType) -> Self { + TypeCellData { cell_str, field_type } } pub fn to_json(&self) -> String { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs index 1ca6ef8002..9d6732c4ea 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs @@ -87,9 +87,9 @@ impl CellDataChangeset for CheckboxTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let checkbox_cell_data = CheckboxCellData::from_str(&changeset)?; - Ok(checkbox_cell_data) + Ok((checkbox_cell_data.to_string(), checkbox_cell_data)) } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs index ca20c811b5..e304bf3ef5 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs @@ -152,17 +152,17 @@ mod tests { time: include_time_str, is_utc: false, }; - let encoded_data = type_option.apply_changeset(changeset, None).unwrap(); + let (cell_str, _) = type_option.apply_changeset(changeset, None).unwrap(); assert_eq!( - decode_cell_data(encoded_data.to_string(), type_option, field_rev), + decode_cell_data(cell_str, type_option, field_rev), expected_str.to_owned(), ); } - fn decode_cell_data(encoded_data: String, type_option: &DateTypeOptionPB, field_rev: &FieldRevision) -> String { + fn decode_cell_data(cell_str: String, type_option: &DateTypeOptionPB, field_rev: &FieldRevision) -> String { let decoded_data = type_option - .decode_cell_str(encoded_data, &FieldType::DateTime, field_rev) + .decode_cell_str(cell_str, &FieldType::DateTime, field_rev) .unwrap(); let decoded_data = type_option.convert_to_protobuf(decoded_data); if type_option.include_time { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option.rs index 25dd9c64bc..c0b287162e 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option.rs @@ -157,7 +157,7 @@ impl CellDataChangeset for DateTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let cell_data = match changeset.date_timestamp() { None => 0, Some(date_timestamp) => match (self.include_time, changeset.time) { @@ -171,8 +171,8 @@ impl CellDataChangeset for DateTypeOptionPB { _ => date_timestamp, }, }; - - Ok(DateCellData(Some(cell_data))) + let date_cell_data = DateCellData(Some(cell_data)); + Ok((date_cell_data.to_string(), date_cell_data)) } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option_entities.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option_entities.rs index fe8a0e6537..8e349168cc 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option_entities.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_type_option_entities.rs @@ -70,7 +70,7 @@ impl ToCellChangesetString for DateCellChangeset { } } -#[derive(Default, Clone)] +#[derive(Default, Clone, Debug)] pub struct DateCellData(pub Option); impl std::convert::From for i64 { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option/number_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option/number_type_option.rs index 7fcae02b66..ddd324af19 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option/number_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option/number_type_option.rs @@ -155,10 +155,10 @@ impl CellDataChangeset for NumberTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let data = changeset.trim().to_string(); - let _ = self.format_cell_data(&data)?; - Ok(StrCellData(data)) + let number_cell_data = self.format_cell_data(&data)?; + Ok((data, number_cell_data.to_string().into())) } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/checklist_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/checklist_type_option.rs index 38ad7236a8..0434f7a972 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/checklist_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/checklist_type_option.rs @@ -60,15 +60,15 @@ impl CellDataChangeset for ChecklistTypeOptionPB { &self, changeset: ::CellChangeset, type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let insert_option_ids = changeset .insert_option_ids .into_iter() .filter(|insert_option_id| self.options.iter().any(|option| &option.id == insert_option_id)) .collect::>(); - match type_cell_data { - None => Ok(SelectOptionIds::from(insert_option_ids)), + let select_option_ids = match type_cell_data { + None => SelectOptionIds::from(insert_option_ids), Some(type_cell_data) => { let mut select_ids: SelectOptionIds = type_cell_data.cell_str.into(); for insert_option_id in insert_option_ids { @@ -81,9 +81,10 @@ impl CellDataChangeset for ChecklistTypeOptionPB { select_ids.retain(|id| id != &delete_option_id); } - Ok(select_ids) + select_ids } - } + }; + Ok((select_option_ids.to_string(), select_option_ids)) } } impl TypeOptionCellDataFilter for ChecklistTypeOptionPB { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/multi_select_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/multi_select_type_option.rs index 45f40d2ba4..613f93256e 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/multi_select_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/multi_select_type_option.rs @@ -61,15 +61,15 @@ impl CellDataChangeset for MultiSelectTypeOptionPB { &self, changeset: ::CellChangeset, type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let insert_option_ids = changeset .insert_option_ids .into_iter() .filter(|insert_option_id| self.options.iter().any(|option| &option.id == insert_option_id)) .collect::>(); - match type_cell_data { - None => Ok(SelectOptionIds::from(insert_option_ids)), + let select_option_ids = match type_cell_data { + None => SelectOptionIds::from(insert_option_ids), Some(type_cell_data) => { let mut select_ids: SelectOptionIds = type_cell_data.cell_str.into(); for insert_option_id in insert_option_ids { @@ -83,9 +83,10 @@ impl CellDataChangeset for MultiSelectTypeOptionPB { } tracing::trace!("Multi-select cell data: {}", select_ids.to_string()); - Ok(select_ids) + select_ids } - } + }; + Ok((select_option_ids.to_string(), select_option_ids)) } } @@ -210,7 +211,7 @@ mod tests { let type_option = MultiSelectTypeOptionPB::from(&field_rev); let option_ids = vec![google.id, facebook.id]; let changeset = SelectOptionCellChangeset::from_insert_options(option_ids.clone()); - let select_option_ids: SelectOptionIds = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids: SelectOptionIds = type_option.apply_changeset(changeset, None).unwrap().1; assert_eq!(&*select_option_ids, &option_ids); } @@ -229,12 +230,12 @@ mod tests { // insert let changeset = SelectOptionCellChangeset::from_insert_options(option_ids.clone()); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert_eq!(&*select_option_ids, &option_ids); // delete let changeset = SelectOptionCellChangeset::from_delete_options(option_ids); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert!(select_option_ids.is_empty()); } @@ -250,7 +251,7 @@ mod tests { let type_option = MultiSelectTypeOptionPB::from(&field_rev); let changeset = SelectOptionCellChangeset::from_insert_option_id(&google.id); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert_eq!(select_option_ids.to_string(), google.id); } @@ -265,7 +266,7 @@ mod tests { let type_option = MultiSelectTypeOptionPB::from(&field_rev); let changeset = SelectOptionCellChangeset::from_insert_option_id(&google.id); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let (_, select_option_ids) = type_option.apply_changeset(changeset, None).unwrap(); assert!(select_option_ids.is_empty()); } @@ -283,11 +284,11 @@ mod tests { // empty option id string let changeset = SelectOptionCellChangeset::from_insert_option_id(""); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); - assert_eq!(select_option_ids.to_string(), ""); + let (cell_str, _) = type_option.apply_changeset(changeset, None).unwrap(); + assert_eq!(cell_str, ""); let changeset = SelectOptionCellChangeset::from_insert_option_id("123,456"); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert!(select_option_ids.is_empty()); } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs index f1f1602fc7..9565394fd3 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs @@ -254,7 +254,7 @@ pub fn new_select_option_color(options: &Vec) -> SelectOptionCol /// Calls [to_string] will return a string consists list of ids, /// placing a commas separator between each /// -#[derive(Default, Clone)] +#[derive(Default, Clone, Debug)] pub struct SelectOptionIds(Vec); impl SelectOptionIds { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/single_select_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/single_select_type_option.rs index b4999a53bc..1369628c0c 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/single_select_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/single_select_type_option.rs @@ -63,7 +63,7 @@ impl CellDataChangeset for SingleSelectTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let mut insert_option_ids = changeset .insert_option_ids .into_iter() @@ -73,13 +73,14 @@ impl CellDataChangeset for SingleSelectTypeOptionPB { // In single select, the insert_option_ids should only contain one select option id. // Sometimes, the insert_option_ids may contain list of option ids. For example, // copy/paste a ids string. - if insert_option_ids.is_empty() { - Ok(SelectOptionIds::from(insert_option_ids)) + let select_option_ids = if insert_option_ids.is_empty() { + SelectOptionIds::from(insert_option_ids) } else { // Just take the first select option let _ = insert_option_ids.drain(1..); - Ok(SelectOptionIds::from(insert_option_ids)) - } + SelectOptionIds::from(insert_option_ids) + }; + Ok((select_option_ids.to_string(), select_option_ids)) } } @@ -195,7 +196,7 @@ mod tests { let type_option = SingleSelectTypeOptionPB::from(&field_rev); let option_ids = vec![google.id.clone(), facebook.id]; let changeset = SelectOptionCellChangeset::from_insert_options(option_ids); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert_eq!(&*select_option_ids, &vec![google.id]); } @@ -213,12 +214,12 @@ mod tests { // insert let changeset = SelectOptionCellChangeset::from_insert_options(option_ids.clone()); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert_eq!(&*select_option_ids, &vec![google.id]); // delete let changeset = SelectOptionCellChangeset::from_delete_options(option_ids); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert!(select_option_ids.is_empty()); } @@ -231,7 +232,7 @@ mod tests { let option_ids = vec![google.id]; let changeset = SelectOptionCellChangeset::from_insert_options(option_ids); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert!(select_option_ids.is_empty()); } @@ -243,7 +244,7 @@ mod tests { let type_option = SingleSelectTypeOptionPB::from(&field_rev); let changeset = SelectOptionCellChangeset::from_insert_option_id(""); - let select_option_ids = type_option.apply_changeset(changeset, None).unwrap(); + let select_option_ids = type_option.apply_changeset(changeset, None).unwrap().1; assert!(select_option_ids.is_empty()); } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs index 1d404fb92e..2e69ed8a38 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs @@ -104,11 +104,12 @@ impl CellDataChangeset for RichTextTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { if changeset.len() > 10000 { Err(FlowyError::text_too_long().context("The len of the text should not be more than 10000")) } else { - Ok(StrCellData(changeset)) + let text_cell_data = StrCellData(changeset); + Ok((text_cell_data.to_string(), text_cell_data)) } } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option.rs index 1b96e404d2..6318f669d1 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option.rs @@ -20,7 +20,7 @@ pub trait TypeOption { /// /// Uses `StrCellData` for any `TypeOption` if their cell data is pure `String`. /// - type CellData: FromCellString + ToString + Default + Send + Sync + Clone + 'static; + type CellData: FromCellString + ToString + Default + Send + Sync + Clone + Debug + 'static; /// Represents as the corresponding field type cell changeset. /// The changeset must implements the `FromCellChangesetString` and the `ToCellChangesetString` trait. diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option_cell.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option_cell.rs index 02713b6e38..295a24833d 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option_cell.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/type_option_cell.rs @@ -13,7 +13,7 @@ use flowy_error::FlowyResult; use grid_rev_model::{FieldRevision, TypeOptionDataDeserializer, TypeOptionDataSerializer}; use std::cmp::Ordering; use std::collections::hash_map::DefaultHasher; -use std::hash::Hasher; +use std::hash::{Hash, Hasher}; /// 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. @@ -55,6 +55,9 @@ struct CellDataCacheKey(u64); impl CellDataCacheKey { pub fn new(field_rev: &FieldRevision, decoded_field_type: FieldType, cell_str: &str) -> Self { let mut hasher = DefaultHasher::new(); + if let Some(type_option_str) = field_rev.get_type_option_str(&decoded_field_type) { + type_option_str.hash(&mut hasher); + } hasher.write(field_rev.id.as_bytes()); hasher.write_u8(decoded_field_type as u8); hasher.write(cell_str.as_bytes()); @@ -112,7 +115,12 @@ where if let Some(cell_data_cache) = self.cell_data_cache.as_ref() { let read_guard = cell_data_cache.read(); if let Some(cell_data) = read_guard.get(key.as_ref()).cloned() { - tracing::trace!("Cell cache hit: {}:{}", decoded_field_type, cell_str); + tracing::trace!( + "Cell cache hit: field_type:{}, cell_str: {}, cell_data: {:?}", + decoded_field_type, + cell_str, + cell_data + ); return Ok(cell_data); } } @@ -124,12 +132,20 @@ where Ok(cell_data) } - fn set_decoded_cell_data(&self, cell_data: ::CellData, field_rev: &FieldRevision) { + fn set_decoded_cell_data( + &self, + cell_str: &str, + cell_data: ::CellData, + field_rev: &FieldRevision, + ) { if let Some(cell_data_cache) = self.cell_data_cache.as_ref() { let field_type: FieldType = field_rev.ty.into(); - let cell_str = cell_data.to_string(); - tracing::trace!("Update cell cache {}:{}", field_type, cell_str); - let key = CellDataCacheKey::new(field_rev, field_type, &cell_str); + tracing::trace!( + "Update cell cache field_type: {}, cell_data: {:?}", + field_type, + cell_data + ); + let key = CellDataCacheKey::new(field_rev, field_type, cell_str); cell_data_cache.write().insert(key.as_ref(), cell_data); } } @@ -187,9 +203,9 @@ where field_rev: &FieldRevision, ) -> FlowyResult { let changeset = ::CellChangeset::from_changeset(cell_changeset)?; - let cell_data = self.apply_changeset(changeset, old_type_cell_data)?; - self.set_decoded_cell_data(cell_data.clone(), field_rev); - Ok(cell_data.to_string()) + let (cell_str, cell_data) = self.apply_changeset(changeset, old_type_cell_data)?; + self.set_decoded_cell_data(&cell_str, cell_data, field_rev); + Ok(cell_str) } fn handle_cell_compare(&self, left_cell_data: &str, right_cell_data: &str, field_rev: &FieldRevision) -> Ordering { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs index 1816ef1308..bf9a183ec1 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs @@ -157,7 +157,7 @@ mod tests { expected_url: &str, _field_rev: &FieldRevision, ) { - let decode_cell_data = type_option.apply_changeset(input_str.to_owned(), None).unwrap(); + let decode_cell_data = type_option.apply_changeset(input_str.to_owned(), None).unwrap().1; assert_eq!(expected_str.to_owned(), decode_cell_data.content); assert_eq!(expected_url.to_owned(), decode_cell_data.url); } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option.rs index 6c17327281..b456082844 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option.rs @@ -81,15 +81,16 @@ impl CellDataChangeset for URLTypeOptionPB { &self, changeset: ::CellChangeset, _type_cell_data: Option, - ) -> FlowyResult<::CellData> { + ) -> FlowyResult<(String, ::CellData)> { let mut url = "".to_string(); if let Ok(Some(m)) = URL_REGEX.find(&changeset) { url = auto_append_scheme(m.as_str()); } - Ok(URLCellData { + let url_cell_data = URLCellData { url, content: changeset, - }) + }; + Ok((url_cell_data.to_string(), url_cell_data)) } } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option_entities.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option_entities.rs index 9f1d3eec0d..2e7bd5f440 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option_entities.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_type_option_entities.rs @@ -30,7 +30,7 @@ impl DecodedCellData for URLCellDataPB { } } -#[derive(Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct URLCellData { pub url: String, pub content: String, diff --git a/frontend/rust-lib/flowy-grid/src/services/sort/controller.rs b/frontend/rust-lib/flowy-grid/src/services/sort/controller.rs index db2960bc16..6eb82caca0 100644 --- a/frontend/rust-lib/flowy-grid/src/services/sort/controller.rs +++ b/frontend/rust-lib/flowy-grid/src/services/sort/controller.rs @@ -142,6 +142,10 @@ impl SortController { }); } + pub async fn did_update_view_field_type_option(&self, _field_rev: &FieldRevision) { + // + } + #[tracing::instrument(level = "trace", skip(self))] pub async fn did_receive_changes(&mut self, changeset: SortChangeset) -> SortChangesetNotificationPB { let mut notification = SortChangesetNotificationPB::default(); diff --git a/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs b/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs index bbb784c896..8eeff98e61 100644 --- a/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs +++ b/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs @@ -537,6 +537,13 @@ impl GridViewRevisionEditor { let new = FilterType::from(&field_rev); let filter_type = UpdatedFilterType::new(old, new); let filter_changeset = FilterChangeset::from_update(filter_type); + + self.sort_controller + .read() + .await + .did_update_view_field_type_option(&field_rev) + .await; + if let Some(changeset) = self .filter_controller .write() diff --git a/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs b/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs index c79090c3af..f89740ed47 100644 --- a/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs +++ b/frontend/rust-lib/flowy-grid/tests/grid/field_test/test.rs @@ -15,7 +15,7 @@ async fn grid_create_field() { CreateField { params }, AssertFieldTypeOptionEqual { field_index: test.field_count(), - expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(), + expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap().to_owned(), }, ]; test.run_scripts(scripts).await; @@ -25,7 +25,7 @@ async fn grid_create_field() { CreateField { params }, AssertFieldTypeOptionEqual { field_index: test.field_count(), - expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(), + expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap().to_owned(), }, ]; test.run_scripts(scripts).await; @@ -63,7 +63,7 @@ async fn grid_update_field_with_empty_change() { UpdateField { changeset }, AssertFieldTypeOptionEqual { field_index: create_field_index, - expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(), + expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap().to_owned(), }, ]; test.run_scripts(scripts).await; diff --git a/frontend/rust-lib/flowy-sync/src/client_grid/grid_revision_pad.rs b/frontend/rust-lib/flowy-sync/src/client_grid/grid_revision_pad.rs index 286f8c5fc0..8f36280bc5 100644 --- a/frontend/rust-lib/flowy-sync/src/client_grid/grid_revision_pad.rs +++ b/frontend/rust-lib/flowy-sync/src/client_grid/grid_revision_pad.rs @@ -166,11 +166,16 @@ impl GridRevisionPad { Some(field_rev) => { let mut_field_rev = Arc::make_mut(field_rev); let old_field_type_rev = mut_field_rev.ty; - let old_field_type_option = mut_field_rev.get_type_option_str(mut_field_rev.ty); + let old_field_type_option = mut_field_rev + .get_type_option_str(mut_field_rev.ty) + .map(|value| value.to_owned()); match mut_field_rev.get_type_option_str(new_field_type) { Some(new_field_type_option) => { - let transformed_type_option = - type_option_transform(old_field_type_rev, old_field_type_option, new_field_type_option); + let transformed_type_option = type_option_transform( + old_field_type_rev, + old_field_type_option, + new_field_type_option.to_owned(), + ); mut_field_rev.insert_type_option_str(&new_field_type, transformed_type_option); } None => { diff --git a/shared-lib/Cargo.lock b/shared-lib/Cargo.lock index c0c35f34ae..194952cfdd 100644 --- a/shared-lib/Cargo.lock +++ b/shared-lib/Cargo.lock @@ -17,27 +17,6 @@ version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d9ff5d688f1c13395289f67db01d4826b46dd694e7580accdc3e8430f2d98e" -[[package]] -name = "async-stream" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" -dependencies = [ - "async-stream-impl", - "futures-core", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-trait" version = "0.1.59" @@ -72,72 +51,21 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "bit-set" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "memchr", -] - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "bytecount" version = "0.6.2" @@ -175,68 +103,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "chrono-tz" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58549f1842da3080ce63002102d5bc954c7bc843d4f47818e642abdc36253552" -dependencies = [ - "chrono", - "chrono-tz-build", - "phf 0.10.1", -] - -[[package]] -name = "chrono-tz-build" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db058d493fb2f65f41861bfed7e3fe6335264a9f0f92710cab5bdf01fef09069" -dependencies = [ - "parse-zoneinfo", - "phf 0.10.1", - "phf_codegen", -] - -[[package]] -name = "cmd_lib" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba0f413777386d37f85afa5242f277a7b461905254c1af3c339d4af06800f62" -dependencies = [ - "cmd_lib_macros", - "faccess", - "lazy_static", - "log", - "os_pipe", -] - -[[package]] -name = "cmd_lib_macros" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e66605092ff6c6e37e0246601ae6c3f62dc1880e0599359b5f303497c112dc0" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "console" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "regex", - "terminal_size", - "unicode-width", - "winapi", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -252,16 +118,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" -dependencies = [ - "cfg-if", - "lazy_static", -] - [[package]] name = "dashmap" version = "5.2.0" @@ -286,48 +142,15 @@ dependencies = [ "syn", ] -[[package]] -name = "deunicode" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] -[[package]] -name = "dissimilar" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ad93652f40969dead8d4bf897a41e9462095152eb21c56e5830537e41179dd" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "env_logger" version = "0.8.4" @@ -341,136 +164,17 @@ dependencies = [ "termcolor", ] -[[package]] -name = "faccess" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ae66425802d6a903e268ae1a08b8c38ba143520f227a205edf4e9c7e3e26d5" -dependencies = [ - "bitflags", - "libc", - "winapi", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fancy-regex" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766" -dependencies = [ - "bit-set", - "regex", -] - -[[package]] -name = "fastrand" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" -dependencies = [ - "instant", -] - -[[package]] -name = "flowy-ast" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "flowy-codegen" -version = "0.1.0" -dependencies = [ - "cmd_lib", - "console", - "fancy-regex", - "flowy-ast", - "itertools", - "lazy_static", - "log", - "phf 0.8.0", - "protoc-bin-vendored", - "protoc-rust", - "quote", - "serde", - "serde_json", - "similar", - "syn", - "tera", - "toml", - "walkdir", -] - -[[package]] -name = "flowy-derive" -version = "0.1.0" -dependencies = [ - "dashmap", - "flowy-ast", - "flowy-codegen", - "lazy_static", - "log", - "proc-macro2", - "quote", - "serde_json", - "syn", - "tokio", - "trybuild", - "walkdir", -] - [[package]] name = "flowy-http-model" version = "0.1.0" dependencies = [ "bytes", - "flowy-codegen", - "flowy-derive", - "lib-infra", "md5", - "protobuf", "serde", "serde_json", "serde_repr", ] -[[package]] -name = "flowy-sync" -version = "0.1.0" -dependencies = [ - "async-stream", - "bytes", - "chrono", - "dashmap", - "dissimilar", - "flowy-derive", - "flowy-http-model", - "folder-rev-model", - "futures", - "grid-rev-model", - "lib-infra", - "lib-ot", - "log", - "parking_lot 0.12.1", - "protobuf", - "serde", - "serde_json", - "strum", - "strum_macros", - "tokio", - "tracing", - "url", -] - [[package]] name = "fnv" version = "1.0.7" @@ -595,15 +299,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -614,17 +309,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.3" @@ -633,37 +317,7 @@ checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", -] - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "globset" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - -[[package]] -name = "globwalk" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" -dependencies = [ - "bitflags", - "ignore", - "walkdir", + "wasi", ] [[package]] @@ -719,12 +373,6 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" -[[package]] -name = "humansize" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" - [[package]] name = "humantime" version = "2.1.0" @@ -742,24 +390,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "ignore" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" -dependencies = [ - "crossbeam-utils", - "globset", - "lazy_static", - "log", - "memchr", - "regex", - "same-file", - "thread_local", - "walkdir", - "winapi-util", -] - [[package]] name = "indexmap" version = "1.9.1" @@ -786,15 +416,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "0.4.8" @@ -816,7 +437,7 @@ dependencies = [ "chrono", "futures-core", "pin-project", - "rand 0.8.5", + "rand", "tokio", ] @@ -851,7 +472,6 @@ dependencies = [ "bytes", "dashmap", "env_logger", - "flowy-codegen", "futures", "futures-channel", "futures-core", @@ -897,12 +517,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "matches" version = "0.1.9" @@ -949,7 +563,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -996,28 +610,12 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "os_pipe" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "parking_lot" version = "0.11.2" @@ -1066,15 +664,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "parse-zoneinfo" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" -dependencies = [ - "regex", -] - [[package]] name = "paste" version = "1.0.6" @@ -1096,123 +685,6 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "pest_derive" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pest_meta" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" -dependencies = [ - "maplit", - "pest", - "sha-1 0.8.2", -] - -[[package]] -name = "phf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" -dependencies = [ - "phf_macros", - "phf_shared 0.8.0", - "proc-macro-hack", -] - -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_shared 0.10.0", -] - -[[package]] -name = "phf_codegen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", -] - -[[package]] -name = "phf_generator" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" -dependencies = [ - "phf_shared 0.8.0", - "rand 0.7.3", -] - -[[package]] -name = "phf_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" -dependencies = [ - "phf_shared 0.10.0", - "rand 0.8.5", -] - -[[package]] -name = "phf_macros" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" -dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", - "uncased", -] - [[package]] name = "pin-project" version = "1.0.12" @@ -1251,30 +723,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -1302,87 +750,6 @@ version = "2.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47c327e191621a2158159df97cdbc2e7074bb4e940275e35abf38eb3d2595754" -[[package]] -name = "protobuf-codegen" -version = "2.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df8c98c08bd4d6653c2dbae00bd68c1d1d82a360265a5b0bbc73d48c63cb853" -dependencies = [ - "protobuf", -] - -[[package]] -name = "protoc" -version = "2.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac70cfc8935f5db2a29c0929db697035d02284011a9b78a5ef5d48092ce9673" -dependencies = [ - "log", - "which", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005ca8623e5633e298ad1f917d8be0a44bcf406bf3cde3b80e63003e49a3f27d" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb9fc9cce84c8694b6ea01cc6296617b288b703719b725b8c9c65f7c5874435" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d2a07dcf7173a04d49974930ccbfb7fd4d74df30ecfc8762cf2f895a094516" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54fef0b04fcacba64d1d80eed74a20356d96847da8497a59b0a0a436c9165b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8782f2ce7d43a9a5c74ea4936f001e9e8442205c244f7a3d4286bd4c37bc924" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5de656c7ee83f08e0ae5b81792ccfdc1d04e7876b1d9a38e6876a9e09e02537" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9653c3ed92974e34c5a6e0a510864dab979760481714c172e0a34e437cb98804" - -[[package]] -name = "protoc-rust" -version = "2.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bad71c8404e3e09024fccbab55aae36e3662662167dc4530a242c8cc8ef8d20" -dependencies = [ - "protobuf", - "protobuf-codegen", - "protoc", - "tempfile", -] - [[package]] name = "quote" version = "1.0.10" @@ -1392,20 +759,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", - "rand_pcg", -] - [[package]] name = "rand" version = "0.8.5" @@ -1413,18 +766,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -1434,16 +777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1452,25 +786,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.3", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -1499,15 +815,6 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -1523,15 +830,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -1598,29 +896,17 @@ dependencies = [ "syn", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha-1" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -1632,33 +918,12 @@ dependencies = [ "libc", ] -[[package]] -name = "similar" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad1d488a557b235fc46dae55512ffbfc429d2482b08b4d9435ab07384ca8aec" - -[[package]] -name = "siphasher" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e" - [[package]] name = "slab" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" -[[package]] -name = "slug" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" -dependencies = [ - "deunicode", -] - [[package]] name = "smallvec" version = "1.7.0" @@ -1694,42 +959,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "tera" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3cac831b615c25bcef632d1cabf864fa05813baad3d526829db18eb70e8b58d" -dependencies = [ - "chrono", - "chrono-tz", - "globwalk", - "humansize", - "lazy_static", - "percent-encoding", - "pest", - "pest_derive", - "rand 0.8.5", - "regex", - "serde", - "serde_json", - "slug", - "unic-segment", -] - [[package]] name = "termcolor" version = "1.1.2" @@ -1739,16 +968,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "thiserror" version = "1.0.30" @@ -1769,15 +988,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" -dependencies = [ - "once_cell", -] - [[package]] name = "time" version = "0.1.44" @@ -1785,7 +995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", "winapi", ] @@ -1848,15 +1058,6 @@ dependencies = [ "tungstenite", ] -[[package]] -name = "toml" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" -dependencies = [ - "serde", -] - [[package]] name = "tracing" version = "0.1.29" @@ -1890,20 +1091,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "trybuild" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150e726dc059e6fbd4fce3288f5bb3cf70128cf63b0dde23b938a3cad810fb23" -dependencies = [ - "glob", - "lazy_static", - "serde", - "serde_json", - "termcolor", - "toml", -] - [[package]] name = "tungstenite" version = "0.14.0" @@ -1916,8 +1103,8 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", - "sha-1 0.9.8", + "rand", + "sha-1", "thiserror", "url", "utf-8", @@ -1935,65 +1122,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" -[[package]] -name = "uncased" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baeed7327e25054889b9bd4f975f32e5f4c5d434042d59ab6cd4142c0a76ed0" -dependencies = [ - "version_check", -] - -[[package]] -name = "unic-char-property" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" -dependencies = [ - "unic-char-range", -] - -[[package]] -name = "unic-char-range" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" - -[[package]] -name = "unic-common" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" - -[[package]] -name = "unic-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" -dependencies = [ - "unic-ucd-segment", -] - -[[package]] -name = "unic-ucd-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - -[[package]] -name = "unic-ucd-version" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" -dependencies = [ - "unic-common", -] - [[package]] name = "unicode-bidi" version = "0.3.7" @@ -2021,12 +1149,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "url" version = "2.2.2" @@ -2051,40 +1173,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" -[[package]] -name = "which" -version = "4.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2" -dependencies = [ - "either", - "lazy_static", - "libc", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/shared-lib/grid-rev-model/src/grid_rev.rs b/shared-lib/grid-rev-model/src/grid_rev.rs index 5bf7b8c4ab..88fe42839e 100644 --- a/shared-lib/grid-rev-model/src/grid_rev.rs +++ b/shared-lib/grid-rev-model/src/grid_rev.rs @@ -165,10 +165,10 @@ impl FieldRevision { self.type_options.insert(id, json_str); } - pub fn get_type_option_str>(&self, field_type: T) -> Option { + pub fn get_type_option_str>(&self, field_type: T) -> Option<&str> { let field_type_rev = field_type.into(); let id = field_type_rev.to_string(); - self.type_options.get(&id).map(|s| s.to_owned()) + self.type_options.get(&id).map(|s| s.as_str()) } }