From 8cdecd50fe1105593749f096a04f209c277aefe3 Mon Sep 17 00:00:00 2001 From: appflowy Date: Mon, 25 Jul 2022 13:15:11 +0800 Subject: [PATCH] chore: rename structs --- .../cell_service/cell_data_persistence.dart | 4 +- .../grid/cell/cell_service/cell_service.dart | 2 +- .../grid/cell/select_option_service.dart | 8 +- .../application/grid/field/field_service.dart | 10 +- .../type_option/type_option_service.dart | 7 +- .../application/grid/row/row_service.dart | 8 +- frontend/app_flowy/pubspec.lock | 6 +- .../flowy-grid/src/entities/cell_entities.rs | 33 +++-- .../flowy-grid/src/entities/field_entities.rs | 114 ++++++++++++++++-- .../flowy-grid/src/entities/row_entities.rs | 23 ++-- .../rust-lib/flowy-grid/src/event_handler.rs | 34 +++--- frontend/rust-lib/flowy-grid/src/event_map.rs | 18 +-- .../checkbox_type_option/checkbox_tests.rs | 2 +- .../date_type_option/date_tests.rs | 2 +- .../date_type_option_entities.rs | 8 +- .../selection_type_option/select_option.rs | 12 +- .../flowy-grid/src/services/grid_editor.rs | 6 +- .../tests/grid/block_test/script.rs | 6 +- 18 files changed, 191 insertions(+), 112 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart index a38a771158..71927bae14 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart @@ -58,8 +58,8 @@ class DateCellDataPersistence implements IGridCellDataPersistence } } -GridCellIdentifierPayloadPB _makeCellIdPayload(GridCellIdentifier cellId) { - return GridCellIdentifierPayloadPB.create() +GridCellIdPB _makeCellIdPayload(GridCellIdentifier cellId) { + return GridCellIdPB.create() ..gridId = cellId.gridId ..fieldId = cellId.fieldId ..rowId = cellId.rowId; diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart index 3e8746c20a..47cd67a55f 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart @@ -46,7 +46,7 @@ class CellService { Future> getCell({ required GridCellIdentifier cellId, }) { - final payload = GridCellIdentifierPayloadPB.create() + final payload = GridCellIdPB.create() ..gridId = cellId.gridId ..fieldId = cellId.fieldId ..rowId = cellId.rowId; diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart index 54ac384267..b6966a3e4e 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart @@ -19,7 +19,7 @@ class SelectOptionService { (result) { return result.fold( (option) { - final cellIdentifier = GridCellIdentifierPayloadPB.create() + final cellIdentifier = GridCellIdPB.create() ..gridId = gridId ..fieldId = fieldId ..rowId = rowId; @@ -54,7 +54,7 @@ class SelectOptionService { } Future> getOpitonContext() { - final payload = GridCellIdentifierPayloadPB.create() + final payload = GridCellIdPB.create() ..gridId = gridId ..fieldId = fieldId ..rowId = rowId; @@ -76,8 +76,8 @@ class SelectOptionService { return GridEventUpdateSelectOptionCell(payload).send(); } - GridCellIdentifierPayloadPB _cellIdentifier() { - return GridCellIdentifierPayloadPB.create() + GridCellIdPB _cellIdentifier() { + return GridCellIdPB.create() ..gridId = gridId ..fieldId = fieldId ..rowId = rowId; diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart b/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart index a0c6fc7d21..9274770b21 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart @@ -103,7 +103,7 @@ class FieldService { } Future> deleteField() { - final payload = GridFieldIdentifierPayloadPB.create() + final payload = DeleteFieldPayloadPB.create() ..gridId = gridId ..fieldId = fieldId; @@ -111,7 +111,7 @@ class FieldService { } Future> duplicateField() { - final payload = GridFieldIdentifierPayloadPB.create() + final payload = DuplicateFieldPayloadPB.create() ..gridId = gridId ..fieldId = fieldId; @@ -121,7 +121,7 @@ class FieldService { Future> getFieldTypeOptionData({ required FieldType fieldType, }) { - final payload = EditFieldPayloadPB.create() + final payload = GridFieldTypeOptionIdPB.create() ..gridId = gridId ..fieldId = fieldId ..fieldType = fieldType; @@ -165,7 +165,7 @@ class NewFieldTypeOptionLoader extends IFieldTypeOptionLoader { @override Future> load() { - final payload = EditFieldPayloadPB.create() + final payload = CreateFieldPayloadPB.create() ..gridId = gridId ..fieldType = FieldType.RichText; @@ -185,7 +185,7 @@ class FieldTypeOptionLoader extends IFieldTypeOptionLoader { @override Future> load() { - final payload = EditFieldPayloadPB.create() + final payload = GridFieldTypeOptionIdPB.create() ..gridId = gridId ..fieldId = field.id ..fieldType = field.fieldType; diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart b/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart index b45cc6f869..fca6995b3f 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart @@ -21,13 +21,10 @@ class TypeOptionService { Future> newOption({ required String name, }) { - final fieldIdentifier = GridFieldIdentifierPayloadPB.create() - ..gridId = gridId - ..fieldId = fieldId; - final payload = CreateSelectOptionPayloadPB.create() ..optionName = name - ..fieldIdentifier = fieldIdentifier; + ..gridId = gridId + ..fieldId = fieldId; return GridEventNewSelectOption(payload).send(); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart b/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart index f8f9c7ee3c..893ebb719b 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart @@ -191,7 +191,7 @@ class GridRowCache { } Future _loadRow(String rowId) async { - final payload = GridRowIdPayloadPB.create() + final payload = GridRowIdPB.create() ..gridId = gridId ..blockId = block.id ..rowId = rowId; @@ -297,7 +297,7 @@ class RowService { } Future> getRow() { - final payload = GridRowIdPayloadPB.create() + final payload = GridRowIdPB.create() ..gridId = gridId ..blockId = blockId ..rowId = rowId; @@ -306,7 +306,7 @@ class RowService { } Future> deleteRow() { - final payload = GridRowIdPayloadPB.create() + final payload = GridRowIdPB.create() ..gridId = gridId ..blockId = blockId ..rowId = rowId; @@ -315,7 +315,7 @@ class RowService { } Future> duplicateRow() { - final payload = GridRowIdPayloadPB.create() + final payload = GridRowIdPB.create() ..gridId = gridId ..blockId = blockId ..rowId = rowId; diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index 958debd9dd..505280115f 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "38.0.0" + version: "42.0.0" analyzer: - dependency: transitive + dependency: "direct overridden" description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "3.4.1" + version: "4.3.0" animations: dependency: transitive description: diff --git a/frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs b/frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs index 11cbdeb88e..30e8d65018 100644 --- a/frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs +++ b/frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs @@ -1,4 +1,4 @@ -use crate::entities::{FieldIdentifierParams, GridFieldIdentifierPayloadPB}; + use flowy_derive::ProtoBuf; use flowy_error::ErrorCode; use flowy_grid_data_model::parser::NotEmptyStr; @@ -8,23 +8,20 @@ use std::collections::HashMap; #[derive(ProtoBuf, Default)] pub struct CreateSelectOptionPayloadPB { #[pb(index = 1)] - pub field_identifier: GridFieldIdentifierPayloadPB, + pub field_id: String, #[pb(index = 2)] + pub grid_id: String, + + #[pb(index = 3)] pub option_name: String, } pub struct CreateSelectOptionParams { - pub field_identifier: FieldIdentifierParams, + pub field_id: String, + pub grid_id: String, pub option_name: String, -} -impl std::ops::Deref for CreateSelectOptionParams { - type Target = FieldIdentifierParams; - - fn deref(&self) -> &Self::Target { - &self.field_identifier - } } impl TryInto for CreateSelectOptionPayloadPB { @@ -32,16 +29,18 @@ impl TryInto for CreateSelectOptionPayloadPB { fn try_into(self) -> Result { let option_name = NotEmptyStr::parse(self.option_name).map_err(|_| ErrorCode::SelectOptionNameIsEmpty)?; - let field_identifier = self.field_identifier.try_into()?; + let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; + let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; Ok(CreateSelectOptionParams { - field_identifier, + field_id: field_id.0, option_name: option_name.0, + grid_id: grid_id.0, }) } } #[derive(Debug, Clone, Default, ProtoBuf)] -pub struct GridCellIdentifierPayloadPB { +pub struct GridCellIdPB { #[pb(index = 1)] pub grid_id: String, @@ -52,20 +51,20 @@ pub struct GridCellIdentifierPayloadPB { pub row_id: String, } -pub struct CellIdentifierParams { +pub struct GridCellIdParams { pub grid_id: String, pub field_id: String, pub row_id: String, } -impl TryInto for GridCellIdentifierPayloadPB { +impl TryInto for GridCellIdPB { type Error = ErrorCode; - fn try_into(self) -> Result { + fn try_into(self) -> Result { let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; let row_id = NotEmptyStr::parse(self.row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?; - Ok(CellIdentifierParams { + Ok(GridCellIdParams { grid_id: grid_id.0, field_id: field_id.0, row_id: row_id.0, diff --git a/frontend/rust-lib/flowy-grid/src/entities/field_entities.rs b/frontend/rust-lib/flowy-grid/src/entities/field_entities.rs index c769b4f08b..760b820233 100644 --- a/frontend/rust-lib/flowy-grid/src/entities/field_entities.rs +++ b/frontend/rust-lib/flowy-grid/src/entities/field_entities.rs @@ -155,6 +155,45 @@ pub struct GetEditFieldContextPayloadPB { pub field_type: FieldType, } + + +#[derive(Debug, Default, ProtoBuf)] +pub struct CreateFieldPayloadPB { + #[pb(index = 1)] + pub grid_id: String, + + #[pb(index = 2)] + pub field_id: String, + + #[pb(index = 3)] + pub field_type: FieldType, + + #[pb(index = 4)] + pub create_if_not_exist: bool, +} + +pub struct CreateFieldParams { + pub grid_id: String, + pub field_id: String, + pub field_type: FieldType, +} + +impl TryInto for CreateFieldPayloadPB { + type Error = ErrorCode; + + fn try_into(self) -> Result { + let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; + let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; + Ok(CreateFieldParams { + grid_id: grid_id.0, + field_id: field_id.0, + field_type: self.field_type, + }) + } +} + + + #[derive(Debug, Default, ProtoBuf)] pub struct EditFieldPayloadPB { #[pb(index = 1)] @@ -190,19 +229,34 @@ impl TryInto for EditFieldPayloadPB { } } -pub struct CreateFieldParams { +#[derive(Debug, Default, ProtoBuf)] +pub struct GridFieldTypeOptionIdPB { + #[pb(index = 1)] pub grid_id: String, + + #[pb(index = 2)] + pub field_id: String, + + #[pb(index = 3)] pub field_type: FieldType, } -impl TryInto for EditFieldPayloadPB { + +pub struct GridFieldTypeOptionIdParams { + pub grid_id: String, + pub field_id: String, + pub field_type: FieldType, +} + +impl TryInto for GridFieldTypeOptionIdPB { type Error = ErrorCode; - fn try_into(self) -> Result { + fn try_into(self) -> Result { let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; - - Ok(CreateFieldParams { + let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; + Ok(GridFieldTypeOptionIdParams { grid_id: grid_id.0, + field_id: field_id.0, field_type: self.field_type, }) } @@ -556,6 +610,16 @@ impl std::convert::From for FieldType { } } } +#[derive(Debug, Clone, Default, ProtoBuf)] +pub struct DuplicateFieldPayloadPB { + #[pb(index = 1)] + pub field_id: String, + + #[pb(index = 2)] + pub grid_id: String, +} + + #[derive(Debug, Clone, Default, ProtoBuf)] pub struct GridFieldIdentifierPayloadPB { #[pb(index = 1)] @@ -565,20 +629,44 @@ pub struct GridFieldIdentifierPayloadPB { pub grid_id: String, } -pub struct FieldIdentifierParams { - pub field_id: String, - pub grid_id: String, -} - -impl TryInto for GridFieldIdentifierPayloadPB { +impl TryInto for DuplicateFieldPayloadPB { type Error = ErrorCode; - fn try_into(self) -> Result { + fn try_into(self) -> Result { let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; - Ok(FieldIdentifierParams { + Ok(GridFieldIdParams { grid_id: grid_id.0, field_id: field_id.0, }) } } + +#[derive(Debug, Clone, Default, ProtoBuf)] +pub struct DeleteFieldPayloadPB { + #[pb(index = 1)] + pub field_id: String, + + #[pb(index = 2)] + pub grid_id: String, +} + +impl TryInto for DeleteFieldPayloadPB { + type Error = ErrorCode; + + fn try_into(self) -> Result { + let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; + let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?; + Ok(GridFieldIdParams { + grid_id: grid_id.0, + field_id: field_id.0, + }) + } +} + +pub struct GridFieldIdParams { + pub field_id: String, + pub grid_id: String, +} + + diff --git a/frontend/rust-lib/flowy-grid/src/entities/row_entities.rs b/frontend/rust-lib/flowy-grid/src/entities/row_entities.rs index f66e1c1d06..d8ae0eba7a 100644 --- a/frontend/rust-lib/flowy-grid/src/entities/row_entities.rs +++ b/frontend/rust-lib/flowy-grid/src/entities/row_entities.rs @@ -2,17 +2,6 @@ use flowy_derive::ProtoBuf; use flowy_error::ErrorCode; use flowy_grid_data_model::parser::NotEmptyStr; -#[derive(ProtoBuf, Default)] -pub struct GridRowIdPayloadPB { - #[pb(index = 1)] - pub grid_id: String, - - #[pb(index = 2)] - pub block_id: String, - - #[pb(index = 3)] - pub row_id: String, -} #[derive(Debug, Default, Clone, ProtoBuf)] pub struct GridRowIdPB { @@ -26,15 +15,21 @@ pub struct GridRowIdPB { pub row_id: String, } -impl TryInto for GridRowIdPayloadPB { +pub struct GridRowIdParams { + pub grid_id: String, + pub block_id: String, + pub row_id: String, +} + +impl TryInto for GridRowIdPB { type Error = ErrorCode; - fn try_into(self) -> Result { + fn try_into(self) -> Result { let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?; let block_id = NotEmptyStr::parse(self.block_id).map_err(|_| ErrorCode::BlockIdIsEmpty)?; let row_id = NotEmptyStr::parse(self.row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?; - Ok(GridRowIdPB { + Ok(GridRowIdParams { grid_id: grid_id.0, block_id: block_id.0, row_id: row_id.0, diff --git a/frontend/rust-lib/flowy-grid/src/event_handler.rs b/frontend/rust-lib/flowy-grid/src/event_handler.rs index 4c4bfe5559..b0ef43f5ad 100644 --- a/frontend/rust-lib/flowy-grid/src/event_handler.rs +++ b/frontend/rust-lib/flowy-grid/src/event_handler.rs @@ -113,10 +113,10 @@ pub(crate) async fn update_field_type_option_handler( #[tracing::instrument(level = "trace", skip(data, manager), err)] pub(crate) async fn delete_field_handler( - data: Data, + data: Data, manager: AppData>, ) -> Result<(), FlowyError> { - let params: FieldIdentifierParams = data.into_inner().try_into()?; + let params: GridFieldIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; let _ = editor.delete_field(¶ms.field_id).await?; Ok(()) @@ -151,10 +151,10 @@ pub(crate) async fn switch_to_field_handler( #[tracing::instrument(level = "trace", skip(data, manager), err)] pub(crate) async fn duplicate_field_handler( - data: Data, + data: Data, manager: AppData>, ) -> Result<(), FlowyError> { - let params: FieldIdentifierParams = data.into_inner().try_into()?; + let params: GridFieldIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; let _ = editor.duplicate_field(¶ms.field_id).await?; Ok(()) @@ -163,10 +163,10 @@ pub(crate) async fn duplicate_field_handler( /// Return the FieldTypeOptionData if the Field exists otherwise return record not found error. #[tracing::instrument(level = "trace", skip(data, manager), err)] pub(crate) async fn get_field_type_option_data_handler( - data: Data, + data: Data, manager: AppData>, ) -> DataResult { - let params: EditFieldParams = data.into_inner().try_into()?; + let params: GridFieldTypeOptionIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; match editor.get_field_rev(¶ms.field_id).await { None => Err(FlowyError::record_not_found()), @@ -186,7 +186,7 @@ pub(crate) async fn get_field_type_option_data_handler( /// Create FieldMeta and save it. Return the FieldTypeOptionData. #[tracing::instrument(level = "trace", skip(data, manager), err)] pub(crate) async fn create_field_type_option_data_handler( - data: Data, + data: Data, manager: AppData>, ) -> DataResult { let params: CreateFieldParams = data.into_inner().try_into()?; @@ -227,10 +227,10 @@ async fn get_type_option_data(field_rev: &FieldRevision, field_type: &FieldType) #[tracing::instrument(level = "debug", skip(data, manager), err)] pub(crate) async fn get_row_handler( - data: Data, + data: Data, manager: AppData>, ) -> DataResult { - let params: GridRowIdPB = data.into_inner().try_into()?; + let params: GridRowIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; let row = editor .get_row_rev(¶ms.row_id) @@ -242,10 +242,10 @@ pub(crate) async fn get_row_handler( #[tracing::instrument(level = "debug", skip(data, manager), err)] pub(crate) async fn delete_row_handler( - data: Data, + data: Data, manager: AppData>, ) -> Result<(), FlowyError> { - let params: GridRowIdPB = data.into_inner().try_into()?; + let params: GridRowIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; let _ = editor.delete_row(¶ms.row_id).await?; Ok(()) @@ -253,10 +253,10 @@ pub(crate) async fn delete_row_handler( #[tracing::instrument(level = "debug", skip(data, manager), err)] pub(crate) async fn duplicate_row_handler( - data: Data, + data: Data, manager: AppData>, ) -> Result<(), FlowyError> { - let params: GridRowIdPB = data.into_inner().try_into()?; + let params: GridRowIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; let _ = editor.duplicate_row(¶ms.row_id).await?; Ok(()) @@ -275,10 +275,10 @@ pub(crate) async fn create_row_handler( // #[tracing::instrument(level = "debug", skip_all, err)] pub(crate) async fn get_cell_handler( - data: Data, + data: Data, manager: AppData>, ) -> DataResult { - let params: CellIdentifierParams = data.into_inner().try_into()?; + let params: GridCellIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; match editor.get_cell(¶ms).await { None => data_result(GridCellPB::empty(¶ms.field_id)), @@ -357,10 +357,10 @@ pub(crate) async fn update_select_option_handler( #[tracing::instrument(level = "trace", skip(data, manager), err)] pub(crate) async fn get_select_option_handler( - data: Data, + data: Data, manager: AppData>, ) -> DataResult { - let params: CellIdentifierParams = data.into_inner().try_into()?; + let params: GridCellIdParams = data.into_inner().try_into()?; let editor = manager.get_grid_editor(¶ms.grid_id)?; match editor.get_field_rev(¶ms.field_id).await { None => { diff --git a/frontend/rust-lib/flowy-grid/src/event_map.rs b/frontend/rust-lib/flowy-grid/src/event_map.rs index 5abda48c1b..9165d8f7f9 100644 --- a/frontend/rust-lib/flowy-grid/src/event_map.rs +++ b/frontend/rust-lib/flowy-grid/src/event_map.rs @@ -69,28 +69,28 @@ pub enum GridEvent { #[event(input = "InsertFieldPayloadPB")] InsertField = 13, - #[event(input = "GridFieldIdentifierPayloadPB")] + #[event(input = "DeleteFieldPayloadPB")] DeleteField = 14, #[event(input = "EditFieldPayloadPB", output = "FieldTypeOptionDataPB")] SwitchToField = 20, - #[event(input = "GridFieldIdentifierPayloadPB")] + #[event(input = "DuplicateFieldPayloadPB")] DuplicateField = 21, #[event(input = "MoveItemPayloadPB")] MoveItem = 22, - #[event(input = "EditFieldPayloadPB", output = "FieldTypeOptionDataPB")] + #[event(input = "GridFieldTypeOptionIdPB", output = "FieldTypeOptionDataPB")] GetFieldTypeOption = 23, - #[event(input = "EditFieldPayloadPB", output = "FieldTypeOptionDataPB")] + #[event(input = "CreateFieldPayloadPB", output = "FieldTypeOptionDataPB")] CreateFieldTypeOption = 24, #[event(input = "CreateSelectOptionPayloadPB", output = "SelectOptionPB")] NewSelectOption = 30, - #[event(input = "GridCellIdentifierPayloadPB", output = "SelectOptionCellDataPB")] + #[event(input = "GridCellIdPB", output = "SelectOptionCellDataPB")] GetSelectOptionCellData = 31, #[event(input = "SelectOptionChangesetPayloadPB")] @@ -99,16 +99,16 @@ pub enum GridEvent { #[event(input = "CreateRowPayloadPB", output = "GridRowPB")] CreateRow = 50, - #[event(input = "GridRowIdPayloadPB", output = "OptionalRowPB")] + #[event(input = "GridRowIdPB", output = "OptionalRowPB")] GetRow = 51, - #[event(input = "GridRowIdPayloadPB")] + #[event(input = "GridRowIdPB")] DeleteRow = 52, - #[event(input = "GridRowIdPayloadPB")] + #[event(input = "GridRowIdPB")] DuplicateRow = 53, - #[event(input = "GridCellIdentifierPayloadPB", output = "GridCellPB")] + #[event(input = "GridCellIdPB", output = "GridCellPB")] GetCell = 70, #[event(input = "CellChangesetPB")] diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs index b9d155da7d..11d8b8f09e 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use crate::entities::FieldType; - use crate::services::cell::{apply_cell_data_changeset, decode_any_cell_data, CellDataOperation}; + use crate::services::cell::{CellDataOperation}; use crate::services::field::type_options::checkbox_type_option::*; use crate::services::field::FieldBuilder; use flowy_grid_data_model::revision::FieldRevision; 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 74b6ee6fd8..87e4efa4a8 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 @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use crate::entities::FieldType; - use crate::services::cell::{CellDataChangeset, CellDataOperation}; + use crate::services::cell::{CellDataOperation}; use crate::services::field::*; // use crate::services::field::{DateCellChangeset, DateCellData, DateFormat, DateTypeOption, TimeFormat}; use flowy_grid_data_model::revision::FieldRevision; 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 aa8fab221a..d5da516bf1 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 @@ -1,5 +1,5 @@ use crate::entities::CellChangesetPB; -use crate::entities::{CellIdentifierParams, GridCellIdentifierPayloadPB}; +use crate::entities::{GridCellIdParams, GridCellIdPB}; use crate::services::cell::{CellBytesParser, FromCellChangeset, FromCellString}; use bytes::Bytes; @@ -24,7 +24,7 @@ pub struct DateCellDataPB { #[derive(Clone, Debug, Default, ProtoBuf)] pub struct DateChangesetPayloadPB { #[pb(index = 1)] - pub cell_identifier: GridCellIdentifierPayloadPB, + pub cell_identifier: GridCellIdPB, #[pb(index = 2, one_of)] pub date: Option, @@ -34,7 +34,7 @@ pub struct DateChangesetPayloadPB { } pub struct DateChangesetParams { - pub cell_identifier: CellIdentifierParams, + pub cell_identifier: GridCellIdParams, pub date: Option, pub time: Option, } @@ -43,7 +43,7 @@ impl TryInto for DateChangesetPayloadPB { type Error = ErrorCode; fn try_into(self) -> Result { - let cell_identifier: CellIdentifierParams = self.cell_identifier.try_into()?; + let cell_identifier: GridCellIdParams = self.cell_identifier.try_into()?; Ok(DateChangesetParams { cell_identifier, date: self.date, diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_option.rs index dbffe79f56..8f441e1755 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_option.rs @@ -1,4 +1,4 @@ -use crate::entities::{CellChangesetPB, CellIdentifierParams, FieldType, GridCellIdentifierPayloadPB}; +use crate::entities::{CellChangesetPB, GridCellIdParams, FieldType, GridCellIdPB}; use crate::services::cell::{CellBytes, CellBytesParser, CellData, CellDisplayable, FromCellChangeset, FromCellString}; use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOptionPB}; use bytes::Bytes; @@ -225,7 +225,7 @@ impl CellBytesParser for SelectOptionCellDataParser { #[derive(Clone, Debug, Default, ProtoBuf)] pub struct SelectOptionCellChangesetPayloadPB { #[pb(index = 1)] - pub cell_identifier: GridCellIdentifierPayloadPB, + pub cell_identifier: GridCellIdPB, #[pb(index = 2, one_of)] pub insert_option_id: Option, @@ -235,7 +235,7 @@ pub struct SelectOptionCellChangesetPayloadPB { } pub struct SelectOptionCellChangesetParams { - pub cell_identifier: CellIdentifierParams, + pub cell_identifier: GridCellIdParams, pub insert_option_id: Option, pub delete_option_id: Option, } @@ -260,7 +260,7 @@ impl TryInto for SelectOptionCellChangesetPaylo type Error = ErrorCode; fn try_into(self) -> Result { - let cell_identifier: CellIdentifierParams = self.cell_identifier.try_into()?; + let cell_identifier: GridCellIdParams = self.cell_identifier.try_into()?; let insert_option_id = match self.insert_option_id { None => None, Some(insert_option_id) => Some( @@ -334,7 +334,7 @@ pub struct SelectOptionCellDataPB { #[derive(Clone, Debug, Default, ProtoBuf)] pub struct SelectOptionChangesetPayloadPB { #[pb(index = 1)] - pub cell_identifier: GridCellIdentifierPayloadPB, + pub cell_identifier: GridCellIdPB, #[pb(index = 2, one_of)] pub insert_option: Option, @@ -347,7 +347,7 @@ pub struct SelectOptionChangesetPayloadPB { } pub struct SelectOptionChangeset { - pub cell_identifier: CellIdentifierParams, + pub cell_identifier: GridCellIdParams, pub insert_option: Option, pub update_option: Option, pub delete_option: Option, diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs index 572665bd0c..5c7436022e 100644 --- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs +++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs @@ -1,5 +1,5 @@ use crate::dart_notification::{send_dart_notification, GridNotification}; -use crate::entities::CellIdentifierParams; +use crate::entities::GridCellIdParams; use crate::entities::*; use crate::manager::{GridTaskSchedulerRwLock, GridUser}; use crate::services::block_manager::GridBlockManager; @@ -339,12 +339,12 @@ impl GridRevisionEditor { Ok(()) } - pub async fn get_cell(&self, params: &CellIdentifierParams) -> Option { + pub async fn get_cell(&self, params: &GridCellIdParams) -> Option { let cell_bytes = self.get_cell_bytes(params).await?; Some(GridCellPB::new(¶ms.field_id, cell_bytes.to_vec())) } - pub async fn get_cell_bytes(&self, params: &CellIdentifierParams) -> Option { + pub async fn get_cell_bytes(&self, params: &GridCellIdParams) -> Option { let field_rev = self.get_field_rev(¶ms.field_id).await?; let row_rev = self.block_manager.get_row_rev(¶ms.row_id).await.ok()??; diff --git a/frontend/rust-lib/flowy-grid/tests/grid/block_test/script.rs b/frontend/rust-lib/flowy-grid/tests/grid/block_test/script.rs index 33548f97c5..9516fd1d03 100644 --- a/frontend/rust-lib/flowy-grid/tests/grid/block_test/script.rs +++ b/frontend/rust-lib/flowy-grid/tests/grid/block_test/script.rs @@ -2,7 +2,7 @@ use crate::grid::block_test::script::RowScript::{AssertCell, CreateRow}; use crate::grid::block_test::util::GridRowTestBuilder; use crate::grid::grid_editor::GridEditorTest; -use flowy_grid::entities::{CellIdentifierParams, FieldType, GridRowPB}; +use flowy_grid::entities::{GridCellIdParams, FieldType, GridRowPB}; use flowy_grid::services::field::*; use flowy_grid_data_model::revision::{ GridBlockMetaRevision, GridBlockMetaRevisionChangeset, RowMetaChangeset, RowRevision, @@ -109,7 +109,7 @@ impl GridRowTest { field_type, expected, } => { - let id = CellIdentifierParams { + let id = GridCellIdParams { grid_id: self.grid_id.clone(), field_id, row_id, @@ -154,7 +154,7 @@ impl GridRowTest { } } - async fn compare_cell_content(&self, cell_id: CellIdentifierParams, field_type: FieldType, expected: String) { + async fn compare_cell_content(&self, cell_id: GridCellIdParams, field_type: FieldType, expected: String) { match field_type { FieldType::RichText => { let cell_data = self