Merge pull request #705 from AppFlowy-IO/refactor/grid_event_params_type

chore: rename structs
This commit is contained in:
Nathan.fooo 2022-07-25 14:14:48 +08:00 committed by GitHub
commit 45397935cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 191 additions and 112 deletions

View File

@ -58,8 +58,8 @@ class DateCellDataPersistence implements IGridCellDataPersistence<CalendarData>
}
}
GridCellIdentifierPayloadPB _makeCellIdPayload(GridCellIdentifier cellId) {
return GridCellIdentifierPayloadPB.create()
GridCellIdPB _makeCellIdPayload(GridCellIdentifier cellId) {
return GridCellIdPB.create()
..gridId = cellId.gridId
..fieldId = cellId.fieldId
..rowId = cellId.rowId;

View File

@ -46,7 +46,7 @@ class CellService {
Future<Either<GridCellPB, FlowyError>> getCell({
required GridCellIdentifier cellId,
}) {
final payload = GridCellIdentifierPayloadPB.create()
final payload = GridCellIdPB.create()
..gridId = cellId.gridId
..fieldId = cellId.fieldId
..rowId = cellId.rowId;

View File

@ -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<Either<SelectOptionCellDataPB, FlowyError>> 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;

View File

@ -103,7 +103,7 @@ class FieldService {
}
Future<Either<Unit, FlowyError>> deleteField() {
final payload = GridFieldIdentifierPayloadPB.create()
final payload = DeleteFieldPayloadPB.create()
..gridId = gridId
..fieldId = fieldId;
@ -111,7 +111,7 @@ class FieldService {
}
Future<Either<Unit, FlowyError>> duplicateField() {
final payload = GridFieldIdentifierPayloadPB.create()
final payload = DuplicateFieldPayloadPB.create()
..gridId = gridId
..fieldId = fieldId;
@ -121,7 +121,7 @@ class FieldService {
Future<Either<FieldTypeOptionDataPB, FlowyError>> 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<Either<FieldTypeOptionDataPB, FlowyError>> load() {
final payload = EditFieldPayloadPB.create()
final payload = CreateFieldPayloadPB.create()
..gridId = gridId
..fieldType = FieldType.RichText;
@ -185,7 +185,7 @@ class FieldTypeOptionLoader extends IFieldTypeOptionLoader {
@override
Future<Either<FieldTypeOptionDataPB, FlowyError>> load() {
final payload = EditFieldPayloadPB.create()
final payload = GridFieldTypeOptionIdPB.create()
..gridId = gridId
..fieldId = field.id
..fieldType = field.fieldType;

View File

@ -21,13 +21,10 @@ class TypeOptionService {
Future<Either<SelectOptionPB, FlowyError>> 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();
}

View File

@ -191,7 +191,7 @@ class GridRowCache {
}
Future<void> _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<Either<OptionalRowPB, FlowyError>> getRow() {
final payload = GridRowIdPayloadPB.create()
final payload = GridRowIdPB.create()
..gridId = gridId
..blockId = blockId
..rowId = rowId;
@ -306,7 +306,7 @@ class RowService {
}
Future<Either<Unit, FlowyError>> deleteRow() {
final payload = GridRowIdPayloadPB.create()
final payload = GridRowIdPB.create()
..gridId = gridId
..blockId = blockId
..rowId = rowId;
@ -315,7 +315,7 @@ class RowService {
}
Future<Either<Unit, FlowyError>> duplicateRow() {
final payload = GridRowIdPayloadPB.create()
final payload = GridRowIdPB.create()
..gridId = gridId
..blockId = blockId
..rowId = rowId;

View File

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

View File

@ -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<CreateSelectOptionParams> for CreateSelectOptionPayloadPB {
@ -32,16 +29,18 @@ impl TryInto<CreateSelectOptionParams> for CreateSelectOptionPayloadPB {
fn try_into(self) -> Result<CreateSelectOptionParams, Self::Error> {
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<CellIdentifierParams> for GridCellIdentifierPayloadPB {
impl TryInto<GridCellIdParams> for GridCellIdPB {
type Error = ErrorCode;
fn try_into(self) -> Result<CellIdentifierParams, Self::Error> {
fn try_into(self) -> Result<GridCellIdParams, Self::Error> {
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,

View File

@ -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<CreateFieldParams> for CreateFieldPayloadPB {
type Error = ErrorCode;
fn try_into(self) -> Result<CreateFieldParams, Self::Error> {
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<EditFieldParams> 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<CreateFieldParams> for EditFieldPayloadPB {
pub struct GridFieldTypeOptionIdParams {
pub grid_id: String,
pub field_id: String,
pub field_type: FieldType,
}
impl TryInto<GridFieldTypeOptionIdParams> for GridFieldTypeOptionIdPB {
type Error = ErrorCode;
fn try_into(self) -> Result<CreateFieldParams, Self::Error> {
fn try_into(self) -> Result<GridFieldTypeOptionIdParams, Self::Error> {
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<FieldTypeRevision> 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<FieldIdentifierParams> for GridFieldIdentifierPayloadPB {
impl TryInto<GridFieldIdParams> for DuplicateFieldPayloadPB {
type Error = ErrorCode;
fn try_into(self) -> Result<FieldIdentifierParams, Self::Error> {
fn try_into(self) -> Result<GridFieldIdParams, Self::Error> {
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<GridFieldIdParams> for DeleteFieldPayloadPB {
type Error = ErrorCode;
fn try_into(self) -> Result<GridFieldIdParams, Self::Error> {
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,
}

View File

@ -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<GridRowIdPB> for GridRowIdPayloadPB {
pub struct GridRowIdParams {
pub grid_id: String,
pub block_id: String,
pub row_id: String,
}
impl TryInto<GridRowIdParams> for GridRowIdPB {
type Error = ErrorCode;
fn try_into(self) -> Result<GridRowIdPB, Self::Error> {
fn try_into(self) -> Result<GridRowIdParams, Self::Error> {
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,

View File

@ -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<GridFieldIdentifierPayloadPB>,
data: Data<DeleteFieldPayloadPB>,
manager: AppData<Arc<GridManager>>,
) -> Result<(), FlowyError> {
let params: FieldIdentifierParams = data.into_inner().try_into()?;
let params: GridFieldIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
let _ = editor.delete_field(&params.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<GridFieldIdentifierPayloadPB>,
data: Data<DuplicateFieldPayloadPB>,
manager: AppData<Arc<GridManager>>,
) -> Result<(), FlowyError> {
let params: FieldIdentifierParams = data.into_inner().try_into()?;
let params: GridFieldIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
let _ = editor.duplicate_field(&params.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<EditFieldPayloadPB>,
data: Data<GridFieldTypeOptionIdPB>,
manager: AppData<Arc<GridManager>>,
) -> DataResult<FieldTypeOptionDataPB, FlowyError> {
let params: EditFieldParams = data.into_inner().try_into()?;
let params: GridFieldTypeOptionIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
match editor.get_field_rev(&params.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<EditFieldPayloadPB>,
data: Data<CreateFieldPayloadPB>,
manager: AppData<Arc<GridManager>>,
) -> DataResult<FieldTypeOptionDataPB, FlowyError> {
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<GridRowIdPayloadPB>,
data: Data<GridRowIdPB>,
manager: AppData<Arc<GridManager>>,
) -> DataResult<OptionalRowPB, FlowyError> {
let params: GridRowIdPB = data.into_inner().try_into()?;
let params: GridRowIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
let row = editor
.get_row_rev(&params.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<GridRowIdPayloadPB>,
data: Data<GridRowIdPB>,
manager: AppData<Arc<GridManager>>,
) -> Result<(), FlowyError> {
let params: GridRowIdPB = data.into_inner().try_into()?;
let params: GridRowIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
let _ = editor.delete_row(&params.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<GridRowIdPayloadPB>,
data: Data<GridRowIdPB>,
manager: AppData<Arc<GridManager>>,
) -> Result<(), FlowyError> {
let params: GridRowIdPB = data.into_inner().try_into()?;
let params: GridRowIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
let _ = editor.duplicate_row(&params.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<GridCellIdentifierPayloadPB>,
data: Data<GridCellIdPB>,
manager: AppData<Arc<GridManager>>,
) -> DataResult<GridCellPB, FlowyError> {
let params: CellIdentifierParams = data.into_inner().try_into()?;
let params: GridCellIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
match editor.get_cell(&params).await {
None => data_result(GridCellPB::empty(&params.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<GridCellIdentifierPayloadPB>,
data: Data<GridCellIdPB>,
manager: AppData<Arc<GridManager>>,
) -> DataResult<SelectOptionCellDataPB, FlowyError> {
let params: CellIdentifierParams = data.into_inner().try_into()?;
let params: GridCellIdParams = data.into_inner().try_into()?;
let editor = manager.get_grid_editor(&params.grid_id)?;
match editor.get_field_rev(&params.field_id).await {
None => {

View File

@ -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")]

View File

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

View File

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

View File

@ -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<String>,
@ -34,7 +34,7 @@ pub struct DateChangesetPayloadPB {
}
pub struct DateChangesetParams {
pub cell_identifier: CellIdentifierParams,
pub cell_identifier: GridCellIdParams,
pub date: Option<String>,
pub time: Option<String>,
}
@ -43,7 +43,7 @@ impl TryInto<DateChangesetParams> for DateChangesetPayloadPB {
type Error = ErrorCode;
fn try_into(self) -> Result<DateChangesetParams, Self::Error> {
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,

View File

@ -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<String>,
@ -235,7 +235,7 @@ pub struct SelectOptionCellChangesetPayloadPB {
}
pub struct SelectOptionCellChangesetParams {
pub cell_identifier: CellIdentifierParams,
pub cell_identifier: GridCellIdParams,
pub insert_option_id: Option<String>,
pub delete_option_id: Option<String>,
}
@ -260,7 +260,7 @@ impl TryInto<SelectOptionCellChangesetParams> for SelectOptionCellChangesetPaylo
type Error = ErrorCode;
fn try_into(self) -> Result<SelectOptionCellChangesetParams, Self::Error> {
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<SelectOptionPB>,
@ -347,7 +347,7 @@ pub struct SelectOptionChangesetPayloadPB {
}
pub struct SelectOptionChangeset {
pub cell_identifier: CellIdentifierParams,
pub cell_identifier: GridCellIdParams,
pub insert_option: Option<SelectOptionPB>,
pub update_option: Option<SelectOptionPB>,
pub delete_option: Option<SelectOptionPB>,

View File

@ -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<GridCellPB> {
pub async fn get_cell(&self, params: &GridCellIdParams) -> Option<GridCellPB> {
let cell_bytes = self.get_cell_bytes(params).await?;
Some(GridCellPB::new(&params.field_id, cell_bytes.to_vec()))
}
pub async fn get_cell_bytes(&self, params: &CellIdentifierParams) -> Option<CellBytes> {
pub async fn get_cell_bytes(&self, params: &GridCellIdParams) -> Option<CellBytes> {
let field_rev = self.get_field_rev(&params.field_id).await?;
let row_rev = self.block_manager.get_row_rev(&params.row_id).await.ok()??;

View File

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